Skip to content

perf(ebml): batch random-access element header reads - #2803

Merged
Borewit merged 1 commit into
masterfrom
perf/ebml-header-reads
Oct 14, 2026
Merged

Borewit merged 1 commit into
masterfrom
perf/ebml-header-reads

Conversation

@Borewit

@Borewit Borewit commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Address excessive tiny file reads during full Matroska traversal on network shares. Read the ID and size VINTs in one bounded peek for random-access inputs, preserving stream parsing and the fallback for small allocation limits. Document indexed parsing for large MKV files on network shares.

Reference: RFC 8794 (July 2020), sections 4–6, variable-size integers, Element ID and Element Data Size. https://www.rfc-editor.org/rfc/rfc8794.html#section-4

Summary by CodeRabbit

  • Performance
    • Large MKV files on network shares can benefit from enabling the index option when the file’s index is reliable, reducing time spent traversing cluster headers.
  • Documentation
    • Clarified when index-based seeking may improve performance and how default traversal affects network access.

Address excessive tiny file reads during full Matroska traversal on network shares. Read the ID and size VINTs in one bounded peek for random-access inputs, preserving stream parsing and the fallback for small allocation limits. Document indexed parsing for large MKV files on network shares.

Reference: RFC 8794 (July 2020), sections 4–6, variable-size integers, Element ID and Element Data Size. https://www.rfc-editor.org/rfc/rfc8794.html#section-4
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: Borewit/music-metadata/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: aada7e57-c9f2-47de-847a-cd27289db102

📥 Commits

Reviewing files that changed from the base of the PR and between efea8ed and f790e96.


📒 Files selected for processing (3)
  • README.md
  • lib/ebml/EbmlIterator.ts
  • test/test-ebml.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.



📝 Walkthrough

Walkthrough

EbmlIterator can read element ID and size VINTs together with a random-access tokenizer when its header buffer is 12 bytes. Tests cover this path and its fallback conditions. The README adds guidance for enabling mkvUseIndex on large MKV files on network shares.

Changes

EBML element-header reads

Layer / File(s) Summary
Combined element-header read
lib/ebml/EbmlIterator.ts, test/test-ebml.ts, README.md
EbmlIterator uses a capped reusable buffer to peek both VINTs when the tokenizer supports random access and the buffer is 12 bytes. It validates VINT widths and available bytes, then advances past the fields. Other cases use the existing sequential reads. Tests cover read positions, VINT widths, a one-byte allocation limit, and truncated input. The README documents mkvUseIndex guidance for large MKV files on network shares.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor


Merge Risk: ⚪ Minimal · up to f790e

This change reduces small header reads on random-access inputs, such as large MKV files on network shares, and keeps the existing parsing path elsewhere. No actionable merge-blocking risk was identified.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main performance change: batching random-access element header reads in EBML parsing.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)


  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@Borewit Borewit added the improvement Improvements to existing functionality, usability, or performance. label Oct 12, 2026
@codecov

codecov Bot commented Oct 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.01%. Comparing base (efea8ed) to head (f790e96).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2803      +/-   ##
==========================================
+ Coverage   96.99%   97.01%   +0.01%     
==========================================
  Files         106      106              
  Lines       15562    15591      +29     
  Branches     1662     1669       +7     
==========================================
+ Hits        15095    15126      +31     
+ Misses        461      459       -2     
  Partials        6        6              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Borewit
Borewit merged commit 32ce5f7 into master Oct 14, 2026
30 checks passed
@Borewit
Borewit deleted the perf/ebml-header-reads branch October 14, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvements to existing functionality, usability, or performance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant