Open artemsolod opened 2 weeks ago
While there may be some performance wins from fewer TLB accesses and alike by using huge pages, the cost is the potential of increasing fragmentation for some workloads.
We actually went to the point of passing MADV_NOHUGEPAGE in a few places in our Julia fork at RelationalAI to avoid this: https://github.com/RelationalAI/julia/commit/2fbcf5ad301f04b1489ac3f62fa1c7447d184cf0.
While there may be some performance wins from fewer TLB accesses and alike by using huge pages, the cost is the potential of increasing fragmentation for some workloads.
Can this be circumvented somewhat by ensuring to only madvise(_, _, MADV_HUGEPAGE)
when the memory requested is known to be large?
While playing around with numpy arrays from julia (discource thread) I have noticed that code like
copy_np
outperformscopy_jl
(full benchmark hereFurther exploration revealed that disabling hugepages in
numpy
removes this gapENV["NUMPY_MADVISE_HUGEPAGE"] = "0"
. Apparentlynumpy
uses hugepages by default for large arrays (docs and source]). If I understand correctly/sys/kernel/mm/transparent_hugepage/enabled
is normally not set toalways
by default but rather tomadvise
which requires the underlying code to explicitly request this functionality - I have checked on Ubuntu 24.10 and 22.04.Can we have this in julia as well? Given people are routinely working with large arrays (and adoption in numpy) this will likely be useful at least as an option. I did some experiments and they indicate that manually constructing arrays from memory that was
madvise
'd for hugepage shows good improvement:timings
source
system