Hacker News new | ask | show | jobs
by jakear 2072 days ago
I once got quite a bit of startup time improvement by simply swapping out cpython's malloc calls for a version that took a large amount of resources at first (~5GB, can be tuned to your workload), and allocated from that. CPython makes many many thousands of mallocs at startup so this gave significant improvement.
2 comments

This is a really interesting approach. I'd love to hear more. Were you patching cpython then? Is your work online somewhere?
See sibling. But yes I patched cpython, it’s pretty easy to build yourself.
Can you please share some numbers if you have them? How much improvement, etc.
60% decrease in startup time, 10% improvement in general runtime. Of course if you exceed the initial allocation the whole thing will crash. That could probably be worked around with a bit more intelligence in the allocator.

This was part of a class project so not available online unfortunately. It’s good practice to implement it yourself though! There are lots of resources online for implementing fast allocators.