microsoft / mimalloc

mimalloc is a compact general purpose allocator with excellent performance.
MIT License
10.57k stars 862 forks source link

Linux + mimalloc padding + NVidia driver: huge start-up times #615

Open jcelerier opened 2 years ago

jcelerier commented 2 years ago

Hello, here's a trace of my app's startup (stopped at when the GUI shows up) with MI_PADDING: it takes roughly 5-6 seconds to show up

mi

and without: (I highlighted the .init part which takes so much time above) ; it takes less than a second to startup in that case:

system

Everything else is fast, I wonder if it's something that could be fixed still ? My edit-compile-run cycle is around 2 seconds for development and it's nice to have as many safeties as possible but not at the cost of waiting 6 second between each code change :)

jcelerier commented 2 years ago

For reference, enabling the other debug options:

  set(MI_SECURE ON)
  set(MI_DEBUG_FULL ON)
  set(MI_SHOW_ERRORS ON)

doesn't have any measurable performance impact

daanx commented 2 years ago

ah, that is very strange; MI_PADDING by itself should not have this effect. I am not familiar with the graphs, but it looks there are mi_heap_realloc_zero calls that take a really long time? I wonder if there is some huge block that is reallocated to a different location with an expensive memcpy. -- but without MI_PADDING the mi_usable_size may be higher (as it is not precise) and the reallocation happens to fit and does not happen?? Still, taking a second for one reallocation is really slow -- it must be a giant block??

jcelerier commented 2 years ago

but it looks there are mi_heap_realloc_zero calls that take a really long time?

yes

it must be a giant block??

well sadly those allocations seem to come directly from the nvidia driver directly so no real way to know... what could I use for debugging this ?