Repository navigation
feat: cap encoded block degree - #30
Merged
Merged
Conversation
Sample degrees from a Robust Soliton distribution (c = 0.2, delta = 0.5)
truncated at maxDegree (default 32) instead of the uncapped Ideal Soliton.
The CDF is now built once per encoder and sampled by binary search.
createEncoder() accepts an options object { compress, maxDegree, random }
as its third argument; a boolean is still accepted as compress. The frame
format and the decoder are unchanged, so existing scanners can decode the
new frames.
Use a seeded RNG for the fountain so the data-rate assertion no longer flakes, and tighten the threshold from 250% to the 180% target.
Also expose it as --max-degree in the CLI.
- robustSoliton falls back to ideal soliton when R is not positive (c = 0, delta >= k) instead of producing NaN - omit the spike when k / R lies beyond k, per the textbook definition - k = 0 (empty uncompressed input) yields empty index lists instead of [-1] - lt.test: add an uncompressed k = 1000 case and relax the deterministic threshold to 200% to leave margin (target is still 180%)
✅ Deploy Preview for qrss ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #23
Sender-only change: frames keep the existing
[degree, ...indices, k, bytes, checksum]layout fromshared.ts, anddecoder.tsis untouched, so existing scanners decode the new frames as before.Changes
packages/luby-transform/src/degree.ts: ideal / robust soliton, truncation (tail mass folded into the cap), CDF built once per encoder + binary-search sampling, partial Fisher–Yates index sampling (no infinite loop for k=1, empty for k=0).createEncoder(data, sliceSize, options)accepts{ compress?, maxDegree?, random? }; a boolean third argument still meanscompress.DEFAULT_MAX_DEGREE = 32. The web app and GIF export use it automatically.maxDegreeis plumbed throughpackages/generate; the CLI gets--max-degree <count>.__benchmarks__/degree-distribution.ts: seeded benchmark against this repo'sLtDecoder.lt.test.tsuses seeded RNG (fixes the ~5% statistical flake), adds ak=1000uncompressed case; threshold 250% → 200%.Benchmark (seeded, 30 runs, received blocks / k)
Mean header ≈ 50 B/frame, worst case bounded at 144 B. Plain truncated ideal soliton (cap 16/32) gets worse at large k with this decoder (k=3000 cap 16: 194%), hence robust soliton.
With 20% frame loss at k=1000: 170% / 267% → 159% / 168% (mean / worst sent blocks / k).
Verification
pnpm run lint,vue-tsc,pnpm run generate: passpnpm vitest run: all new/updated tests pass; the only failure is the pre-existingtest/slicing.test.tssnapshot onmain(fixed in the dependency-update branch).shared.tslayout.Not done / follow-ups