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

Did you consider just making an array of HashMap, say 512 of them, and locking only one of them based on your key's hash?

Or, more generally, minimizing the odds of waiting on a lock, without resorting to a complex lock free scheme?



> Did you consider just making an array of HashMap, say 512 of them, and locking only one of them based on your key's hash?

A disadvantage of that approach is that even without any lock contention you would still have two writes to memory for every lock acquisition.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: