9fans / plan9port

Plan 9 from User Space
https://9fans.github.io/plan9port/
Other
1.64k stars 326 forks source link

idea: port pool(2) #654

Open ec1oud opened 5 months ago

ec1oud commented 5 months ago

On Plan 9, malloc() uses poolalloc(). I suppose plan9port just uses the underlying platform malloc() right? But I think memory pools are useful in other scenarios, for example to confine certain data types to specific memory blocks. So I'm trying to make the code portable to posix platforms. My goal is to do arena allocation exactly the same on all OSes and all platforms (at least on little-endian 64-bit architectures). I'm not sure how achievable that is; so far I just got it to compile, and already ended up with differences in behavior somehow, which I'm trying to troubleshoot. I just wondered if someone else has thought of it or tried it, or maybe someone knows of a better solution?

frobnitzem commented 5 months ago

Would jemalloc provide a useful backend? Perhaps YAKL's pool allocator?

ec1oud commented 5 months ago

Actually I got poolalloc() working well enough for my purposes so far, and figured I'd keep using it rather than something else, because I try to write portable software and poolalloc() is already there on Plan 9.

But I wouldn't be surprised if some newer implementation could be more efficient.