Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loop plus match #248

Merged
merged 10 commits into from
Nov 14, 2024
Merged

Loop plus match #248

merged 10 commits into from
Nov 14, 2024

Commits on Nov 14, 2024

  1. move from tail calls to loop+match

    folkertdev authored and rnijveld committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    6de9627 View commit details
    Browse the repository at this point in the history
  2. inflate: minor safety comments

    inahga authored and rnijveld committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    9e71c5a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c5c8534 View commit details
    Browse the repository at this point in the history
  4. inflate: more conservative bounds checking on gz header fields

    Paranoia: If self.length is miscalculated to be past {extra,name,comm}_max,
    it could result in us sending a pointer out of bounds when we do
    `ptr.add(self.length)`. Usually the number of bytes would be zero, but sending
    a pointer OOB with `ptr.add()` is automatic UB even if we don't actually count
    any bytes.
    
    We do have a guardrail against underflowing subtraction against self.length,
    but we should check and panic instead of saturating. Better safe than sorry.
    inahga authored and rnijveld committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    b7c36e1 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    ede7792 View commit details
    Browse the repository at this point in the history
  6. inflate: safety comment around unchecked unreachable

    Add a safety comment around this unchecked unreachable statement, and convert
    the integer literals to binary literals to make it more obvious that the match
    statement is matching against bits.
    inahga authored and rnijveld committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    8664a7a View commit details
    Browse the repository at this point in the history
  7. use safe unreachable! macro instead of unreachable_unchecked

    llvm is able to optimize the branch away anyway https://godbolt.org/z/x9srqoMjj so we can just have less unsafe code
    folkertdev authored and rnijveld committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    75efd27 View commit details
    Browse the repository at this point in the history
  8. fn dispatch: use break instead of return

    this does not yet cover the macros
    folkertdev authored and rnijveld committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    bb72819 View commit details
    Browse the repository at this point in the history
  9. load the inflate reader and writer to the stack

    Benchmark 2 (66 runs): target/release/examples/blogpost-uncompress rs-chunked 4 silesia-small.tar.gz
      measurement          mean ± σ            min … max           outliers         delta
      wall_time          76.8ms ± 2.42ms    75.6ms … 95.5ms          3 ( 5%)        ⚡-  3.9% ±  1.1%
      peak_rss           24.1MB ± 73.9KB    23.9MB … 24.1MB          0 ( 0%)          -  0.0% ±  0.1%
      cpu_cycles          308M  ± 9.07M      305M  …  378M           5 ( 8%)        ⚡-  4.0% ±  1.0%
      instructions        941M  ±  236       941M  …  941M           0 ( 0%)        ⚡-  2.3% ±  0.0%
      cache_references   3.08M  ±  335K     2.78M  … 5.42M           3 ( 5%)        💩+  4.5% ±  3.2%
      cache_misses        126K  ± 25.3K     87.0K  …  263K           2 ( 3%)        💩+ 94.9% ± 13.4%
      branch_misses      4.08M  ± 7.54K     4.07M  … 4.13M           3 ( 5%)          -  0.2% ±  0.1%
    folkertdev authored and rnijveld committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    d5a26df View commit details
    Browse the repository at this point in the history
  10. clippy

    folkertdev committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    6977768 View commit details
    Browse the repository at this point in the history