1 hour ago · Tech · hide · 0 comments

Custom memory allocations and arenas are notoriously hard to deal with in Rust due to the ownership model. In a lot of projects, they can significantly improve performance. For example, let's take databases. Sending a query to a database produces a lot of temporary objects, and if the default allocator is used, you will need to allocate and deallocate thousands of small objects for each query, which is wasteful. Almost every database engine uses custom memory pools to improve performance. Some go so far as to statically allocate all the memory before the program starts. Another good example is scripting languages. I have an article on how Python uses arenas to reduce the number of allocations for Python types. A simple web app in Python can allocate more than a million of objects after 100 HTTP requests.[......]

No comments yet. Log in to reply on the Fediverse. Comments will appear here.