logoalt Hacker News

logicchains • yesterday at 8:22 AM • 4 replies • view on HN

>My toy kernel says otherwise. There are many stages of boot at varying levels of abstraction and being able to conveniently express each one is wonderful.

You need tight allocation control and arena usage when squeezing the most performance possible out of your system is non-negotiable. Most people don't need to write such code.


Replies

eptcyka • yesterday at 11:29 AM

Rust is kind of targeting those users. I want Rust to cater to this usecase. It is fine not to use custom allocators if you don’t want to.

tliltocatl • yesterday at 10:50 AM

It's not only about performance. It is also about embedded system that don't have much memory, and have no fallback when they are out of memory. When ending up in some untested and faulty state you'd prefer getting some logs to just panicking and rebooting.

When the code uses dynamic allocation liberally, there is no such option: once a malloc fails you can only panic. You can reserve a piece of memory for recovery action, but it doesn't help much if recovery path engages most of the codebase. E. g. on IoT stuff most of the complexity is in the network stack - and you need the network stack if you want to get your logs.

And yes, recursion and stack is also a problem, even if more manageable than malloc. You can avoid recursion completely, but there still a risk of stack overflow on an untested code path. Zig promised staticaly-known stack depth once, but, afaik, didn't get there.

gf000 • yesterday at 10:21 AM

Even performance critical applications have non-performance critical parts.

E.g. in the aforementioned audio programming you may do the setup, init phase normally and only go for custom allocators afterwards.

wongarsu • yesterday at 9:47 AM

Object pools are somewhat popular. Hugely popular in game development. And they are essentially a custom allocator for languages that don't have custom allocators