←back to thread

498 points azhenley | 1 comments | | HN request time: 0.214s | source
Show context
Const-me ◴[] No.45771551[source]
For performance critical code, you want to reuse L1D cache lines as much as possible. In many cases, allocation of a new immutable object boils down to malloc(). Newly allocated memory is unlikely to be found on L1D cache. OTOH, replacing data in recently accessed memory and reusing the memory is very likely to become L1D cache hit in runtime.
replies(2): >>45771810 #>>45772624 #
1. marginalia_nu ◴[] No.45772624[source]
For performance critical code, you wouldn't use malloc()-allocation at all, though whether using an arena allocator or putting stuff on the stack, your argument is still sane. Data locality is speed.