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

Call session end async to avoid unnecessary blocking #2764

Merged
merged 3 commits into from
Mar 9, 2023

Conversation

mjh1
Copy link
Contributor

@mjh1 mjh1 commented Mar 2, 2023

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

Specific updates (required)

  • We are now calling session end asynchronously. Previously the blocking was causing delays in processing segments and ultimately transcode timeouts

How did you test each of these updates (required)

Ran local B/O/T and verified the session end notifications are working asynchronously.

Does this pull request close any open issues?

#2762

Checklist:

if err := EndTranscodingSession(ctx, sess); err != nil {
clog.Errorf(ctx, "Error completing transcoding session: %q", err)
}
go func() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yondonfu @iameli Are you guys happy with this? I've been looking at the B code downstream of here as well as the function that ends up being called on the O side and can't see a need for blocking.

Copy link
Member

Choose a reason for hiding this comment

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

AFAICT you seem to be right that this call doesn't need to block for B.

@mjh1 mjh1 marked this pull request as draft March 2, 2023 14:32
@mjh1
Copy link
Contributor Author

mjh1 commented Mar 2, 2023

Setting to draft until I fix the unit tests

@codecov
Copy link

codecov bot commented Mar 6, 2023

Codecov Report

Merging #2764 (8c17363) into master (854db02) will decrease coverage by 0.01337%.
The diff coverage is 100.00000%.

❗ Current head 8c17363 differs from pull request most recent head f85d5c2. Consider uploading reports for the commit f85d5c2 to get more accurate results

Impacted file tree graph

@@                 Coverage Diff                 @@
##              master       #2764         +/-   ##
===================================================
- Coverage   56.28293%   56.26956%   -0.01337%     
===================================================
  Files             88          88                 
  Lines          19171       19172          +1     
===================================================
- Hits           10790       10788          -2     
- Misses          7789        7792          +3     
  Partials         592         592                 
Impacted Files Coverage Δ
server/broadcast.go 77.48735% <100.00000%> (+0.01900%) ⬆️
discovery/db_discovery.go 69.11765% <0.00000%> (-1.10294%) ⬇️

Continue to review full report at Codecov.

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

Impacted Files Coverage Δ
server/broadcast.go 77.48735% <100.00000%> (+0.01900%) ⬆️
discovery/db_discovery.go 69.11765% <0.00000%> (-1.10294%) ⬇️

@mjh1 mjh1 marked this pull request as ready for review March 7, 2023 18:45
@mjh1 mjh1 requested a review from yondonfu March 7, 2023 18:45
Copy link
Contributor

@cyberj0g cyberj0g left a comment

Choose a reason for hiding this comment

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

LGTM, except the unit test question, if you want my opinion 👍

goleakOptions := common.IgnoreRoutines()
// allow enough time for the transcode end goroutines to finish
goleakOptions = append(goleakOptions, goleak.MaxSleepInterval(5*time.Second), goleak.MaxRetryAttempts(1000))
defer goleak.VerifyNone(t, goleakOptions...)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why 1000 retry attempts and 5 seconds delay (I believe it's a delay between attempts, not overall)? I think, the EndTranscodingSession goroutine will finish instantly here. Also maybe pass options to VerifyNone call directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @cyberj0g. Unfortunately for the tests the communication for the EndTranscodingSession call isn't set up so it simply times out after the 3 second timeout, so that's the reason for waiting. And the other annoying thing is the goleak library starts off with very small microsecond pauses between retries so that's the reason for the high number.
I've looked into a lot of different ways of abstracting this away for the tests without success, I think it'll have to wait for a later PR.

if err := EndTranscodingSession(ctx, sess); err != nil {
clog.Errorf(ctx, "Error completing transcoding session: %q", err)
}
go func() {
Copy link
Member

Choose a reason for hiding this comment

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

AFAICT you seem to be right that this call doesn't need to block for B.

@@ -48,7 +48,7 @@ jobs:
uses: actions/cache@v3
with:
path: /github/home/compiled
key: ${{ runner.os }}-ffmpeg-${{ hashFiles('**/install_ffmpeg.sh') }}
key: ${{ runner.os }}-ffmpeg-${{ hashFiles('install_ffmpeg.sh') }}
Copy link
Member

Choose a reason for hiding this comment

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

What was the reason for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Builds were failing on master like this: https://github.com/livepeer/go-livepeer/actions/runs/4309780285/jobs/7517555365
It seemed as though the wildcard matching was not working. @hjpotter92 made some changes in this area recently so I'll check with him when he's back but the change I've made has fixed the issue in any case.

@mjh1 mjh1 merged commit c65fed9 into master Mar 9, 2023
@mjh1 mjh1 deleted the mh/async-session-end branch March 9, 2023 18:06
This was referenced Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants