Heap-size-hint usage recommendations

Julia 1.9 got a new CLI option --heap-size-hint. See #45369 for details and Julia execution inside a container with restricted RAM

This option allows to set a soft limit of memory consumption when the garbage collector should start an intensive work. We can expect this value should be in between 50-80% of RAM available for the Julia-based application. For intensive query server applications, this value may be less than 50% and should be adjusted based on experimentation with the appropriate load.

I’m starting this topic to collect together receipts of usage of this option for exact environments like GitHub Actions, Docker, Helm, Terraform, etc. Please share your ideas and code.

Linux. Calculate the value based on free memory:

julia --project=. --threads=auto --startup-file=no --heap-size-hint=`grep MemFree /proc/meminfo | awk '{print int($2 * 0.8) "k"}'`...

Available memory make more sense to my work. So it’ s

julia --heap-size-hint=`grep MemAvailable /proc/meminfo | awk '{print int($2 * 0.3) "k"}'`

for me.

1 Like

Percent of MemAvailable only is not a good metric. The problem is that 1GB of available RAM is not the same as 8GB because in the first case the operating system uses half of it for it’s own purposes. In the second case, most of the RAM will be available. MemFree may be more reliable metric if the Julia application is running in a Docker-container and nothing memory consumptive was running before. The percent of MemFree might be hard coded inside the Dockerfile, but MemAvailable depends on a VM configurations outside the Dockerfile.

Note that the low value of --heap-size-hint forces GC to do excessive memory scans and eats CPU.