Alex313031 / Thorium-Win

Chromium fork for Windows named after radioactive element No. 90; Windows builds of https://github.com/Alex313031/Thorium
https://thorium.rocks/
BSD 3-Clause "New" or "Revised" License
1.28k stars 33 forks source link

Build with mimalloc to further improve browser performance #194

Open enihcam opened 2 months ago

enihcam commented 2 months ago

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.

gz83 commented 2 months ago

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.

Alex313031 commented 2 months ago

@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.

enihcam commented 2 months ago

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

Maybe you can start from trying Dynamically overriding first?

gz83 commented 2 months ago

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.