Visitar URL original
Add ZSTD_findFrameBoundaries() frame scanner API by ceedot-rock · Pull Request #4795 · facebook/zstd · GitHub
Skip to content

Add ZSTD_findFrameBoundaries() frame scanner API - #4795

Open
ceedot-rock wants to merge 1 commit into
facebook:devfrom
ceedot-rock:frame-scanner-4734
Open

ceedot-rock wants to merge 1 commit into
facebook:devfrom
ceedot-rock:frame-scanner-4734

Conversation

@ceedot-rock

@ceedot-rock ceedot-rock commented Sep 28, 2026 •

Copy link
Copy Markdown

Closes #4734.

Adds a public helper that scans a buffer and reports every frame's offset and compressed size without decompressing. Returns the frame count on success; validates the whole buffer strictly (bad magic -> prefix_unknown, truncation -> srcSize_wrong). Passing NULL for the output array gives a count-only pass so callers can allocate, then fill.

Why: parallel decompression at frame granularity needs frame boundaries up front, and there was no single helper doing it. The scan delegates to ZSTD_findFrameCompressedSize, so standard, skippable, and legacy frames behave exactly the way the library already handles them.

Tests: new unit test (tests/frameScannerTest.c) - mixed standard/skippable buffers, truncation points, corrupted magic, garbage input - plus each reported frame independently decompresses to its original bytes. Also extended tests/fuzz/zstd_frame_info.c with scanner invariants (contiguity, bounds, count-vs-fill agreement). Existing fuzzer (2729 tests) and zstreamtest (1773 tests) pass; ~70k mutated inputs under ASan/UBSan clean.


Slid Phi Labs accepts donations to keep the lab independent.

@meta-cla

meta-cla Bot commented Sep 28, 2026

Copy link
Copy Markdown

Hi @ceedot-rock!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Sep 28, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed label Sep 28, 2026
@meta-cla

meta-cla Bot commented Sep 28, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@ceedot-rock

Copy link
Copy Markdown
Author

Bump — CLA signed, CI green. This is the first of a 5-PR stack (#4795–#4799): frame boundary scanner, multithreaded decompress, file access API, COVER stale-pointer fix, scatter decompress. Each stands alone. Happy to rebase or split anything that doesn't fit your conventions.

New public helper that scans a buffer and reports every zstd frame's
offset and compressed size without decompressing, enabling
frame-granularity parallel decompression. Handles standard, skippable
and legacy frames; strict all-or-nothing validation.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

frame offset/size scanner without decompressing for concurrency

1 participant