Unofficial Hacker News companion — get notified on comment replies, and more.

Show HN: misa77 – Up to 3x faster decompression than zstd, with better ratios (opens external site)

247 points by nonadhocproblem 15 hours ago github.com 81 comments (opens Hacker News) Vote (opens Hacker News)

View full thread · View on Hacker News

Comment thread (12)

  1. I'm gonna try this later. I just got a 5x (single core, 5MB/s) - 10x (dual core 10MB/s) speedup on brotli in the last few days. It's been really surprising to realize how much storage and traffic bandwidth is going to waste because of unoptimized transit.

    brotli -11 is so slow nobody probably uses it right now but at 10x speed it actually becomes pretty ok. It's a more efficient encoding than zstd (and gzip by far) at their max compression settings.

    Haven't got a writeup yet but: https://claude.ai/share/0e8bf6c0-6d64-4a34-8f97-37ccbae19732

    Brotli/zstd are kind of in a class of their own in my view because of their direct browse integration and support. That's why I focused on brotli specifically. Didn't know so many others on hn were also working on this rn.

    I actually just did it in x86_64 but if you start there it's trivial to wrap that in C/Go/etc these days. Here's the Go+C shim: https://claude.ai/share/57ddeb9a-36bf-4690-99d5-621147b15a77

    Replies (3)
    1. Might have been better to ask Claude to emit C/C++ code with intrinsics (which is actually what Claude did at some point!).

      Compilers are pretty good at optimally scheduling instructions for different CPU architectures, so using assembler directly is counterproductive.

      Replies (2)
      1. I did this about 5x in parallel and I know at least half the attempts actually started with a C sanity check impl first anyway (I guess including this one). I do think you're right that the better order of operations would have been:

          1. establish a true C impl baseline
        
          2. hillclimb until satisfied
        
          2.5 establish a more rigorous profiling before/after/baseline and hotpath detection approach
        
          3. disassemble and strip out unnecessary binary overhead
        
          4. continue optimizing until satisfied
        
        FOr projects like this where a lot of the iteration is on ASM itself, I do want to challenge one notion though:

          1. compilers are pretty good but they are definitely not perfect
        
          2. Fable has pretty good judgment when it comes to handrolled impls, in my opinion
        
          3. hillclimbing performance gains is easily verifiable incrementally on low level code. fablemaxxing asm is basically what this thing was Born To Do
        
          4. past a certain point the tuned asm surpasses the compiler's output every time.
        
        you're basically just throwing world's most expensive/optimized compiler at it over and over and over until you're ready to call it quits. In other words

        > using assembler directly is counterproductive.

        I'm not! ain't nobody got time for that. this like the platonic ideal RL task for models to be trained on and they're better than me at it (at very least much more methodical and persistent)

        > for different CPU architectures

        Similarly, I don't see why I can't just do this independently on every CPU architecture I care about. I've been doing this kind of stuff a lot the past week and it just works tbh. Here's a 64 bit wasm example, I thought it was pretty interesting: https://claude.ai/share/62d4dae5-3cd5-4108-ad68-5e299a691479

        Replies (1)
        1. Different CPU models have different optimal instruction scheduling. So you'd hillclimb a certain CPU model and perform suboptimally on another.

          It's very easy to just let C-compiler do that work and compile the lib statically + LTO (optionally PGO). You'll get all of the benefits you think you're getting from the assembler version. LTO & PGO might even find more optimizations around the compression / decompression calls.

          Replies (1)
          1. right, I'm just saying that for my use case, I'd prefer to just run a specialized tune against each CPU model I use

            I think that over time an increasingly large portion of software will be built this way. For this project I'm ok with adding support for each new CPU taking an agent a few hours. If you're implementing against a known standard, until you find a security issue, these don't really ever need to change, which is a very nice property IMO

      2. They are actually not really that good at doing that if you are writing something like a memcopy or compression code using inline-assembly/intrinsics.

        Compiler is actaully not really good at that a lot of the time either.

        It is good if you don't want to spend too much time on it, but if you have the time and know how to write assembly then there is no comparison.

    2. Compression is really cool, and while bandwidth goes to waste without it there are (historically) so many bugs around it. Maybe this will get better with AI hammering at it, but there's so many buffer overflow bugs, chained decompression bugs, DoS attacks, etc. It's surprisingly difficult to get right.
      Replies (2)
      1. Yeah I find it pretty surprising how "intricate" most of these formats get by basically just stacking heuristics or having completely different impls across compression levels (this is not intuitive to me, I'd have expected more of a gradient or).

        Fortunately fuzzing has become really easy now, but this is a very easy target for an attacker to hit with a adversarial payload because it's not cryptographically secure. It's been pretty hit or miss for me whether I can get regular consumer agents to do "content/binary-aware security testing" on this stuff without freaking out.

        But this is itself a climbable problem so, I'm sure it's possible to address this. At a cost of $200 per binary :)

      2. How is it possible to hack some code that calls zstd::decompress on a bounded buffer? I am genuinely confused by this, but a lot people wrote this here so I assume there is some problem with it.

        Is this kind of like OpenSSL being terrible but the crypto libraries being good?

        Replies (1)
        1. The problems are not usually with the compression libraries themselves, but rather the users of the libraries.

          Things like MongoBleed (CVE-2025-14847), are what I am thinking of.

          Replies (1)
          1. People going crazy about writing compression libraries in rust are hallucinating then.

            I think this is the same in crypto as all crypto primitive libraries are ASM/C and they are really solid compared to something like OpenSSL

    3. Wait until you hear about something called JSON.