Hacker News new | past | comments | ask | show | jobs | submit login

I implemented a toy market ledger in Rust. I initially thought to use a B-Tree because that's the conventional wisdom right? It was sooooo slow. Running valgrind showed that 99.5% of the time was spent doing memory allocation and traversing pointers.

A hashmap of vectors was so stupidly fast. If you keep them sorted each insertion is dirt cheap, and binary search is dirt cheap.




Do you mean time was used as the key for the hashmap? What was the vector used for in that setup?


Vectors contain buy/sell orders and are sorted by price, the keys of the hashmap were different securities. Buy orders and sell orders lived in separate vectors




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

Search: