logoalt Hacker News

vardump • today at 12:12 PM • 1 reply • view on HN

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

weitendorf • today at 12:32 PM

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

➕ show 1 reply