Assign stream ids and save the ids file in slices too #51

Merged
namillis merged 1 commit from fix/ids-sliced into main 2026-11-20 22:09:30 +00:00
Owner

Follow-up to #50. In the live log after #50, the deferred view rebuilds still blocked 0.7 s now and then (stream id assignment after a big provider refresh), and the ids file save 5 s later blocked about 0.5 s.

  • XtreamIds.assignSteps is the assignment as a generator. assignStreams runs it in one go; assignStreamsSliced runs it in slices, one assignment at a time. A one-go call finishes a sliced one in progress first, so the two never mix their changes to the state. Both return the last result when asked again for the same channel list (each login's view used to redo it).
  • buildViewSliced takes the pool's channels and guide once at the start and assigns ids with the sliced assignment.
  • The ids file is built in slices (stateJson, the same JSON as JSON.stringify) and written with fs.promises. Saves never overlap. flush() still writes in one go.

On the real pool, deployed (#50) vs this branch, with identical views, id state and ids file every time:

Deployed longest block Branch longest block
View, first build 2.2 s 65 ms
View, nothing changed 0.7 s 54 ms
View after polar / happy8k refreshed 0.85-0.93 s 55-58 ms
Ids file save (13.6 MB) 340 ms 120 ms

Tests: 148/148 pass.

Follow-up to #50. In the live log after #50, the deferred view rebuilds still blocked 0.7 s now and then (stream id assignment after a big provider refresh), and the ids file save 5 s later blocked about 0.5 s. - `XtreamIds.assignSteps` is the assignment as a generator. `assignStreams` runs it in one go; `assignStreamsSliced` runs it in slices, one assignment at a time. A one-go call finishes a sliced one in progress first, so the two never mix their changes to the state. Both return the last result when asked again for the same channel list (each login's view used to redo it). - `buildViewSliced` takes the pool's channels and guide once at the start and assigns ids with the sliced assignment. - The ids file is built in slices (`stateJson`, the same JSON as `JSON.stringify`) and written with `fs.promises`. Saves never overlap. `flush()` still writes in one go. On the real pool, deployed (#50) vs this branch, with identical views, id state and ids file every time: | | Deployed longest block | Branch longest block | |---|---|---| | View, first build | 2.2 s | 65 ms | | View, nothing changed | 0.7 s | 54 ms | | View after polar / happy8k refreshed | 0.85-0.93 s | 55-58 ms | | Ids file save (13.6 MB) | 340 ms | 120 ms | Tests: 148/148 pass.
Assign stream ids and save the ids file in slices too
All checks were successful
CI / test (pull_request) Successful in 20s
1cbafc217e
After #50 the view rebuild's longest block was assignStreams (0.2-0.8 s), and the ids file save 5 s later blocked about 0.5 s. A view rebuilt after a merge now assigns ids in slices, one assignment at a time; a one-go assignment finishes one in progress first. The ids file is built in slices and written asynchronously. On the real pool the views, id state and file are identical, with no block over 120 ms.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
namillis/iptv-pool!51
No description provided.