Specify default options at compile time
Is there a way to specify the default values for the options during compile time? From what I have seen in the code so far this does not seem to be the case. In particular we are concerned about the default value of arena_reserve because we have seen some OOM issues during the first tests.
Background: we are thinking about using mimalloc statically linked into a shared library which itself is used by some Java application. If we are setting the options at runtime after the library has been loaded it is probably too late.
Hi Manuel, hope you are doing well. In the src/options.c you can compile in the default options like arena_reserve .
Aside: Normally though, the memory for such arena is only "reserved", not "committed" yet so it should not lead to an OOM even though it reserve 1GiB at a time. This is controlled by arena_eager_commit which is by default 2 meaning it only eagerly commits the arena memory on OS's with overcommit (which is I think only Linux ). Maybe I made a wrong assumption here?
Hi Daan! All good, thanks for asking. :) I guess I wasn't clear enough. I would like to be able to change some options before mimalloc is initialized, but if possible without changing the mimalloc source code. Changing the default parameters just seem the obvious approach, but I would also take any other solution. Most importantly, we prefer to not have to change 3rdParty code (which includes mimalloc).
Regarding arena size and reserve/commit - ATM it is just a guess that the arena size is causing the OOM issues - we are still investigating.
Ah I see. There are some options that are read before user code can set them -- it'll still work from environment variables but that is probably not what you want. We could add some pre-processor definitions here for the defaults of those options that may be needed early in mimalloc -- like the MIMALLOC_ARENA_RESERVE. Would that work for you?
I guess the compile time options would be: eager_commit, arena_eager_commit, arena_reserve, allow_large_os_pages, and maybe reserve_huge_os_pages and reserve_os_memory.
I pushed an update to dev and dev-slice that let you set extra c definitions with cmake ../.. -DMI_EXTRA_CPPDEFS=MI_ARENA_RESERVE=128*1024L for example. Let me know if this would work for you.
Yes, I think that should work - thank you!