Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record current number of live pipelines running #3312

Merged
merged 1 commit into from
Dec 12, 2024
Merged

Record current number of live pipelines running #3312

merged 1 commit into from
Dec 12, 2024

Conversation

mjh1
Copy link
Contributor

@mjh1 mjh1 commented Dec 11, 2024

What does this pull request do? Explain your changes. (required)

Introduce a new metric to record the current number of inflight live AI pipelines.

How did you test each of these updates (required)

Does this pull request close any open issues?

Checklist:

@github-actions github-actions bot added go Pull requests that update Go code AI Issues and PR related to the AI-video branch. labels Dec 11, 2024
@@ -152,6 +152,9 @@ func startControlPublish(control *url.URL, params aiRequestParams) {
ControlPub: controlPub,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should probably move this initialisation of the LivePipeline somewhere more central now that we're using it to check stream existence as well as just storing these control related fields. Also do we need a mutex around it like we do in cleanupLive() @j0sh ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to you... I don't see a big issue right now. We might outgrow it at some point but if you want to be preemptive about refactoring, go ahead. Just want to avoid spreading initialization logic around too much, while it is kinda self contained right now.

Also do we need a mutex around it like we do in cleanupLive()

Yep we need the mutex but I believe we already hold it at this point. Only slight issue is that we also hold the mutex while calling stats.Record but that should be OK for the most part. Recording prom metrics is supposed to be fairly quick but its still kind of non-trivial IIRC

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah missed the mutex 👍

@mjh1 mjh1 requested review from j0sh and thomshutt December 11, 2024 20:18
Copy link

codecov bot commented Dec 11, 2024

Codecov Report

Attention: Patch coverage is 52.94118% with 8 lines in your changes missing coverage. Please review.

Project coverage is 34.04646%. Comparing base (abd997d) to head (1bf300f).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
server/ai_live_video.go 0.00000% 3 Missing ⚠️
server/ai_mediaserver.go 0.00000% 3 Missing ⚠️
monitor/census.go 81.81818% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                 @@
##              master       #3312         +/-   ##
===================================================
+ Coverage   34.03772%   34.04646%   +0.00874%     
===================================================
  Files            141         141                 
  Lines          37006       37020         +14     
===================================================
+ Hits           12596       12604          +8     
- Misses         23691       23697          +6     
  Partials         719         719                 
Files with missing lines Coverage Δ
monitor/census.go 61.81939% <81.81818%> (+0.14715%) ⬆️
server/ai_live_video.go 0.00000% <0.00000%> (ø)
server/ai_mediaserver.go 8.08989% <0.00000%> (-0.03652%) ⬇️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update abd997d...1bf300f. Read the comment docs.

Files with missing lines Coverage Δ
monitor/census.go 61.81939% <81.81818%> (+0.14715%) ⬆️
server/ai_live_video.go 0.00000% <0.00000%> (ø)
server/ai_mediaserver.go 8.08989% <0.00000%> (-0.03652%) ⬇️

... and 1 file with indirect coverage changes

@@ -152,6 +152,9 @@ func startControlPublish(control *url.URL, params aiRequestParams) {
ControlPub: controlPub,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to you... I don't see a big issue right now. We might outgrow it at some point but if you want to be preemptive about refactoring, go ahead. Just want to avoid spreading initialization logic around too much, while it is kinda self contained right now.

Also do we need a mutex around it like we do in cleanupLive()

Yep we need the mutex but I believe we already hold it at this point. Only slight issue is that we also hold the mutex while calling stats.Record but that should be OK for the most part. Recording prom metrics is supposed to be fairly quick but its still kind of non-trivial IIRC

@mjh1 mjh1 merged commit 183b8bc into master Dec 12, 2024
20 checks passed
@mjh1 mjh1 deleted the mh/inflight branch December 12, 2024 11:06
@@ -555,6 +556,9 @@ func (ls *LivepeerServer) cleanupLive(stream string) {
pub, ok := ls.LivepeerNode.LivePipelines[stream]
delete(ls.LivepeerNode.LivePipelines, stream)
ls.LivepeerNode.LiveMu.Unlock()
if monitor.Enabled {
monitor.AICurrentLiveSessions(len(ls.LivepeerNode.LivePipelines))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjh1 @j0sh Are we sure that cleanupLive() is called always, even in case of errors, panics, etc?

The number of used in-use orchestrators seems high https://eu-metrics-monitoring.livepeer.live/grafana/d/be6llteqebk00b/ai-overview-livestream?orgId=1&from=1734220800000&to=now&viewPanel=6

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we might be double counting somehow, the current number is 12 which is double Eric's number of 24/7 streams

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjh1 I think the versions with / without music are separate streams

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I was wondering that, I think the added music streams are just regular studio streams only though https://github.com/ericxtang/random-ai-stream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AI Issues and PR related to the AI-video branch. go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants