Thorium-Win icon indicating copy to clipboard operation
Thorium-Win copied to clipboard

Build with mimalloc to further improve browser performance

Open enihcam opened this issue 10 months ago • 4 comments

Is your feature request related to a problem? Please describe. mimalloc is a high-performance memory allocator alternative to glibc malloc(). In Linux, it can be easily enabled as a drop-in replacement of glibc malloc(). In Windows, it has to be compiled together with the target project.

Describe the solution you'd like, including relevant patches or source Compile Thorium-Win with mimalloc enabled. https://github.com/microsoft/mimalloc?tab=readme-ov-file#override_on_windows

Additional Notes Add any other context or screenshots about the feature request here.

enihcam avatar Apr 05 '24 16:04 enihcam

Introducing mimalloc into Chromium compilation requires a lot of work. It seems that no developers are doing this at this stage, but it would be good if it can be done.

gz83 avatar Apr 05 '24 18:04 gz83

@enihcam This is something I would like to do, based on their benchmarks, however, getting this to work in Thorium, and for all the platforms (Linux, Windows, MacOS, Android, ChromiumOS) would take alot of work. @gz83 Perhaps with a .patch file and a script that uses sed and grep to replace all instances of malloc in the code with mimalloc. I can look into it. However, there is also the possibility that it would cause bugs, since although we use the gcc malloc function, Chromium is compiled with LLVM/Clang, not the GCC/G++ toolchain.

Getting it to work wouldn't necessarily make Thorium any faster at web rendering, but it would load faster on initial startup, and would be able to spawn renderer processes faster, due to memory loading occurring quicker.

malloc is a relic from very early Linux and very early C compilers. I think maybe it is starting to show its age, and isn't scaling well with the large sizes and multi-threads of today's applications.

Alex313031 avatar Apr 06 '24 06:04 Alex313031

@Alex313031 @gz83 Glad to hear you are considering this.

Maybe you can start from trying Dynamically overriding first?

enihcam avatar Apr 06 '24 07:04 enihcam

We may try, but there is no guarantee that mimalloc will be used and Chromium's compilation workflow does not support us using mimalloc directly.

gz83 avatar Apr 06 '24 09:04 gz83