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

Use errgroup to write segments to disk in background #998

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mjh1
Copy link
Contributor

@mjh1 mjh1 commented Dec 4, 2023

Replace the channel based logic with errgroup, makes it a little simpler and easier to reason about.

Copy link

codecov bot commented Feb 9, 2024

Codecov Report

Attention: 30 lines in your changes are missing coverage. Please review.

Comparison is base (1ba6bd7) 52.44519% compared to head (e211fe0) 52.43504%.

Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                 @@
##                main        #998         +/-   ##
===================================================
- Coverage   52.44519%   52.43504%   -0.01015%     
===================================================
  Files             70          70                 
  Lines           7709        7659         -50     
===================================================
- Hits            4043        4016         -27     
+ Misses          3344        3322         -22     
+ Partials         322         321          -1     
Files Coverage Δ
video/media.go 100.00000% <100.00000%> (+13.04348%) ⬆️
transcode/transcode.go 35.95506% <23.07692%> (+1.04127%) ⬆️

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 1ba6bd7...e211fe0. Read the comment docs.

Files Coverage Δ
video/media.go 100.00000% <100.00000%> (+13.04348%) ⬆️
transcode/transcode.go 35.95506% <23.07692%> (+1.04127%) ⬆️

@mjh1 mjh1 changed the title Mh/mp4 mem Use errgroup to write segments to disk in background Feb 9, 2024
@mjh1 mjh1 marked this pull request as ready for review February 9, 2024 12:59
@emranemran
Copy link
Collaborator

Why replace channel logic when it's been working alright? Also not saving that many lines of code IMO

@mjh1
Copy link
Contributor Author

mjh1 commented Feb 13, 2024

I just find it much easier to follow and really prefer to avoid channels wherever possible. I don't think the current implementation surfaces errors whereas with errgroup this is just built in.
current:

err := video.WriteSegmentsToDisk(transmuxTopLevelDir, renditionList, segmentBatch)
if err != nil {
return
}

@emranemran
Copy link
Collaborator

I just find it much easier to follow and really prefer to avoid channels wherever possible. I don't think the current implementation surfaces errors whereas with errgroup this is just built in. current:

err := video.WriteSegmentsToDisk(transmuxTopLevelDir, renditionList, segmentBatch)
if err != nil {
return
}

I'm the opposite - channels just kind of fit nicely into the produce-consumer model and the framework sort of made sense to me and I was able to reason around it. The errors are captured in various stages in the channel implementation and surfaced up (e.g. fail to get segment, or fail to write incorrect number of segments, etc).

What's the test plan if we decide to merge this? The main reason the original change was done was to handle OOM conditions and the refactor meant a lot of the logic around mp4s had to be re-tested i.e. short and very long MP4s will need to be tested.

Some other things that come to mind:

  • Resource usage - currently we never exceed 40% per pod during typical usage + mp4 generation.
  • Are transcoded segments arriving out of order handled?
  • Verifying all renditions are the same length and playable.

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