Skip to content

Make tile scheduling linear instead of quadratic - #247

Merged
cpncf merged 2 commits into
mainfrom
tile_scheduling_linear
Aug 7, 2026
Merged

Make tile scheduling linear instead of quadratic#247
cpncf merged 2 commits into
mainfrom
tile_scheduling_linear

Conversation

@kpchoi

@kpchoi kpchoi commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

This adopts the tile scheduling change from #225 by @lordnn, with the original commit cherry-picked and authorship preserved.

Worker threads used to scan the tile status array from index 0 inside the critical section to find the next tile, making tile acquisition O(n) and a whole frame O(n^2). The scan is replaced with a shared next-tile counter, so acquisition is O(1). Since every tile is claimed exactly once in index order and the status array is initialized identically for full and partial decoding (every tile carries the DO flag, with DECODE or SKIP deciding the actual work), the processing semantics are unchanged.

Compared to #225 this adoption is conservative: volatile on the tile status stays, the completion status updates stay inside the critical section, and the claim invariants are asserted.

Verified against unpatched builds with identical outputs in all cases: the full test suite in Release and Debug, multithreaded encode bitstreams (plain and ABR rate control), full and cyclic tile-based partial decoding across 5 tile conformance streams and 1/2/4/8 threads, and partial decoding with tile index lists passed in non-ascending order. ThreadSanitizer reports no findings for multithreaded encode and decode. With a 3840x2160 stream at the RFC tile limits the scan cost is negligible, but combined with the small-tile extension in #236 (32,400 tiles of 16x16) the change reduces encode wall time from 1.3s to 0.11s and decode from 2.4s to 0.52s at 8 threads, with bit-identical results.

lordnn and others added 2 commits August 7, 2026 13:43
Signed-off-by: lordnn <lordnn@yahoo.com>
…invariants

Signed-off-by: KP Choi <kp5.choi@samsung.com>

@cpncf cpncf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@cpncf
cpncf merged commit 14a306f into main Aug 7, 2026
9 checks passed
@kpchoi
kpchoi deleted the tile_scheduling_linear branch August 8, 2026 06:09
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.

3 participants