GrapheneOS/hardened_malloc

OOM when running the sh6bench benchmark

jvoisin opened this issue · 4 comments

As my of my recent efforts to benchmark (security-oriented) memory allocators in , I ~recently added hardened_malloc to the mimalloc-bench party, and it's doing pretty well, kudos!

Unfortunately, I'm getting an OOM on the sh6bench bench.

$ git clone https://github.com/daanx/mimalloc-bench
$ cd mimalloc-bench
$ ./build-bench-env.sh hm bench
$ cd ./out/bench
$ LD_PRELOAD=/home/jvoisin/dev/mimalloc-bench/extern/hm/libhardened_malloc.so ./sh6bench 4
Out of memory
$

Is this working as intended?

Have you increased vm.max_map_count to a higher default value?

vm.max_map_count = 1048576

The guard slab feature is what massively increases the amount of VMAs. The cost of the expensive optional hardening features dwarfs the cost of allocation. That's why it would be nice to test it in a lightweight configuration too, especially if you're measuring memory usage. It's meant to be configured for the use case. GrapheneOS doesn't use it in the configuration that you're testing, for example.

Would it then be possible to have the default configuration of hardened_malloc be a reasonable one that doesn't require tweaking for most of the programs?

The default is the most security-focused configuration sensible for regular use. It heavily leans towards security rather than performance in that default configuration. The thinking behind that is if people need better performance and/or lower memory usage they can configure it but security isn't something they'll be able to see or measure.