Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If an HN reader wanted to play around with similar digging, what would be the essential tools to be aware of and where best could he start?

Assuming prior knowledge of assembly/C but without much experience decompiling or testing speed.



Learn how to use a decent profiler. if you're running linux, that's probably perf:

https://man7.org/linux/man-pages/man1/perf.1.html

https://www.brendangregg.com/perf.html

Here's a fun article from the cloudflare blog that gives an example of using of perf to diagnose performance of a small utility: https://blog.cloudflare.com/when-bloom-filters-dont-bloom/

Matt Godbolt's compiler explorer is also worth checking out: https://godbolt.org/


Your compiler can spit out assembly, you just need to know how to read it. Sounds like the author was also using Xcode Instruments https://help.apple.com/instruments/mac/current/#/dev7b09c84f... to check cpu counters. And they were using criterion https://crates.io/crates/criterion to microbenchmark.

My guess would be that the author is porting some C code to Rust and making sure not to regress performance along the way (probably hopefully trying to increase it). Likely their program was written in Rust and the section they were trying to optimize called some old c code. Sounds like they rewrote the section in Rust since Rust <-> C ffi calls break out of the happy realm the rust compiler likes and end up causing a performance hit themselves. You can write inline assembly in Rust using the macro https://doc.rust-lang.org/reference/inline-assembly.html.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: