facebook / hhvm

A virtual machine for executing programs written in Hack.
https://hhvm.com
Other
18.15k stars 2.99k forks source link

Shouldn't disabling JIT also disable the JIT translation-cache? #7381

Open SjonHortensius opened 8 years ago

SjonHortensius commented 8 years ago

I'm attempting to lower hhvm's memory usage for 3v4l.org; and I expected that disabling the JIT would reduce the amount of memory that's being used for the translation cache to 0. However, this is not the case. I have tried disabling the JIT through the commandline (using both -d hhvm.jit=0 and -v Eval.Jit=false) and cli.hdf (using Eval { Jit = false }) and php.ini (using [hhvm] hhvm.jit = 0).

However; I still get this error:

could not allocate 218103807 bytes for translation cache

Alternatively I've also tried lowering the size itself by using

hhvm.jit_a_size = 16M
hhvm.jit_a_cold_size = 10M
hhvm.jit_a_frozen_size = 10M
hhvm.jit_global_data_size = 2M
hhvm.jit_a_hot_size = 10M
hhvm.jit_a_prof_size = 16M

and while this lowers the size to ~ 70 M; it still throws the same error (memory size is currently limited to 512M total). Complete config can be found at https://3v4l.org/6KJfh

Orvid commented 8 years ago

I agree that we definitely shouldn't be allocating anything for the JIT if it's disabled, I don't think the logic is currently in-place for that though....

For reducing the memory usage further, -v Eval.JitAutoTCShift=0 should drop that usage by another 2mb, but it definitely is odd that it's failing to allocate the memory when you have it set to a lower limit.

The actual code that does the allocation actually tries to allocate it in a few different ways, eventually falling back to malloc: https://github.com/facebook/hhvm/blob/3be5b8cd23a304e9da530ce6c0889da139843bb4/hphp/runtime/vm/jit/code-cache.cpp#L135

SjonHortensius commented 8 years ago

Well, 2 MiB is not an amount that really helps; currently it fails because it cannot allocate 220 M for a script that does nothing more then a simple echo.

The allocation fails if I lower RLIMIT_AS from 1G to 512M. Is this expected behavior?

photodude commented 7 years ago

@SjonHortensius, what is the code sample that is failing? I would like to run a check to see if this is still an issue in HHVM-3.15 and hhvm-3.16-dev

SjonHortensius commented 7 years ago

@photodude Actually I received this error for all (even the most basic) scripts. Unfortunately getting hhvm to fail (or work) sometimes requires some fiddling with various memory related settings

photodude commented 7 years ago

Thank @SjonHortensius I hope to see the recently released HHVM 3.15.4 and HHVM 3.17.0 on 3v4l someday (soon hopefully). I've seen improvements in memory related items on those. One specific item was an issue solved where you would get a Fatal error: request has exceeded memory limit if you called memory_get_peak_usage() and a certain amount of memory near 256mb was used. This was solved in HHVM 3.15.2 but affects all older versions (with no patch planned for those old eol versions).