Currently, WebKitFeatures.cmake enables bmalloc on aarch64, x86_64, arm, and mips. All other architectures build with USE_SYSTEM_MALLOC=ON. It seems one of the reasons that bmalloc does not work on many CPU architectures is that it doesn't support systems with 64 kB page size. We can be confident of this because bmalloc on aarch64 works in Fedora (which uses 4 kB pages) but not in RHEL (64 kB pages). Looking through bmalloc for potentially-problematic places, I found configSizeToProtect in Gigacage.h set to 16 kB, which is too small. I also found in Sizes.h: static constexpr size_t smallLineSize = 256; static constexpr size_t smallPageSize = 4 * kB; static constexpr size_t smallPageLineCount = smallPageSize / smallLineSize; static constexpr size_t maskSizeClassMax = 512; static constexpr size_t smallMax = 32 * kB; static constexpr size_t pageSizeMax = smallMax * 2; static constexpr size_t pageClassCount = pageSizeMax / smallPageSize; I guess we would need to raise smallPageSize and smallMax both to 64 kB? Before I try this, are there any other theoretical problems that would stop bmalloc from working on a given CPU architecture? Are there page size assumptions anywhere else? Does it make endianness assumptions?
If you change these values, please do not change them in the existing architectures. We are tuning performance / memory-consumption heavily on the current numbers.
I don't think that's right, since malloc is already tuned to 16kb pages. It's not obvious setting "smallPageSize" to 64kb actually makes bmalloc better
(In reply to Saam Barati from comment #2) > I don't think that's right, since malloc is already tuned to 16kb pages. > It's not obvious setting "smallPageSize" to 64kb actually makes bmalloc > better physical page size and smallPageSize are different concept, no? https://bugs.webkit.org/attachment.cgi?id=274931&action=review " smallPageSize is now unrelated to the OS's page size -- it just reflects the optimal unit of memory to recycle between small objects."
Your question is a more general one: does bmalloc work with 64kb pages. Why wouldn’t it? I’d guess the only thing needing to be changed is “configSizeToProtect” in Gigacage In the previous bug where you reference this bug, you say this is a bmalloc issue. What exactly is the issue?
Saam left some additional hints here: https://bugs.webkit.org/show_bug.cgi?id=209670#c22
*** Bug 200566 has been marked as a duplicate of this bug. ***
Carlos Lopez found there is also ConfigAlignment and another ConfigSizeToProtect in mbmalloc.cpp.