4 ms·
A templating language would be a great case for using an arena allocator since objects will only live as long as it takes to fulfill the request.
by infogulch 2y ago
A templating language would be a great case for using an arena allocator since objects will only live as long as it takes to fulfill the request.
- the_mitsuhiko 2y agoYes! I did in fact try this but I was unable to find a good way to make the API work.
- infogulch 2y agoInteresting! I suspect a templating engine that uses arenas would be a holy grail for rust web perf, so I'm curious about your experience trying to use them. As for making the API work, do you mean that the arena API was difficult to use, or the object interface you built on top of it was difficult to implement in a way that was accessible to template execution?
- the_mitsuhiko 2y agoIt depends a bit on what you want to do. I made one attempt where I needed to carry a 'arena lifetime everywhere which was really tricky. A second attempt was to tag the Value internally with an ever increasing ID of arenas. However the latter becomes dangerous very quickly because nothing binds them together and you end up with a lot of unsafe code and I had no trust in my creation.
- infogulch 2y agoYeah that makes sense. Maybe arenas will be viable once the working group makes progress on allocators. https://github.com/rust-lang/wg-allocators https://github.com/rust-lang/wg-allocators