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

feat(dash): Improve DASH SegmentTemplate performance with on-demand segment references #5061

Merged
merged 13 commits into from
Apr 29, 2023

Conversation

nrcrast
Copy link
Contributor

@nrcrast nrcrast commented Mar 7, 2023

Background

This is a performance optimization intended to reduce the Video Start Time for DASH streams, both VOD and Live, by reducing the amount of processing done during manifest parse time. This is especially effective for long multi-period assets, assets with many variants, or on low end devices in general. I've provided some measurements showing the performance improvements at the conclusion of this PR.

Currently, during manifest parse time for a Segment Template, Shaka will loop through the entire timeline and create segment references for each timeline entry. For a long asset, or an asset with many tracks, this is a significant amount of processing.

Solution

I've created a new entity called the Timeline Segment Index that extends the SegmentIndex interface. The purpose of the Timeline Segment Index is to ingest a timeline during construction, and then use that information to build Segment References only on demand. This removes the need to parse the entire timeline and create all of the Segment References during parse time.

Results/Measurements

The effects of this change aren't quite as apparent on desktop web browsers, given their speed and power. This improvement really shines on lower end TVs on assets with a long timeline.

image

@avelad avelad added type: enhancement New feature or request priority: P2 Smaller impact or easy workaround component: DASH The issue involves the MPEG DASH manifest format labels Mar 7, 2023
@avelad avelad added this to the v4.4 milestone Mar 7, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2023

Incremental code coverage: 99.10%

@avelad
Copy link
Collaborator

avelad commented Mar 15, 2023

I have tested on several TVs and the performance is better than before, I still have to do the code review.

lib/dash/mpd_utils.js Outdated Show resolved Hide resolved
lib/dash/segment_template.js Outdated Show resolved Hide resolved
lib/dash/segment_template.js Outdated Show resolved Hide resolved
lib/dash/segment_template.js Show resolved Hide resolved
lib/dash/segment_template.js Show resolved Hide resolved
lib/dash/segment_template.js Outdated Show resolved Hide resolved
lib/dash/segment_template.js Outdated Show resolved Hide resolved
lib/media/presentation_timeline.js Outdated Show resolved Hide resolved
lib/dash/segment_template.js Outdated Show resolved Hide resolved
lib/dash/segment_template.js Show resolved Hide resolved
lib/dash/segment_template.js Show resolved Hide resolved
lib/dash/segment_template.js Outdated Show resolved Hide resolved
lib/dash/segment_template.js Outdated Show resolved Hide resolved
lib/dash/segment_template.js Outdated Show resolved Hide resolved
lib/media/presentation_timeline.js Outdated Show resolved Hide resolved
lib/media/segment_index.js Outdated Show resolved Hide resolved
lib/media/segment_index.js Outdated Show resolved Hide resolved
@joeyparrish
Copy link
Member

Overall, I'm very impressed with the performance improvements. Thank you so much for contributing! My main concern is that we take care of edge cases, especially around fitting segments to the period.

lib/media/presentation_timeline.js Outdated Show resolved Hide resolved
lib/media/presentation_timeline.js Outdated Show resolved Hide resolved
lib/media/segment_index.js Outdated Show resolved Hide resolved
@joeyparrish
Copy link
Member

Please merge with main. I just fixed some test failures, and I'd like to see a clean test pass before I merge this.

The PR looks good, though. Thanks!

@joeyparrish joeyparrish changed the title feat(dash): Create Segment References only upon demand feat(dash): Improve DASH SegmentTemplate performance with on-demand segment references Apr 26, 2023
@joeyparrish joeyparrish merged commit f1c5a1c into shaka-project:main Apr 29, 2023
15 checks passed
theodab pushed a commit that referenced this pull request May 4, 2023
A recent change to allow for on-demand segment references (#5061) ended up causing a
regression with an older issue (#4717), where the presence of an image track overrides
`bufferBehind` behavior.
This fixes the segment template handler to properly account for image tracks, once again.
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
component: DASH The issue involves the MPEG DASH manifest format priority: P2 Smaller impact or easy workaround status: archived Archived and locked; will not be updated type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants