Do compiler threads allocate metaspace?
vladimir.kozlov at oracle.com
Tue Nov 13 18:15:33 UTC 2018
Yes, compilers (C1 and C2) do allocations in Metaspace - MethodData and MethodCounter objects.
On 11/13/18 9:26 AM, Thomas Stüfe wrote:
> Hi all,
> can compiler threads allocate Metaspace?
> Clients of us use a "jvmkill" jvmti agent in their cloudfoundry
> infrastructure. That agent (see
> https://github.com/cloudfoundry/jvmkill) subscribes to the JVMTI
> ResourceExhausted Event and then, in the handler, uses JVMTI
> FollowReferences() to produce a heap histogram.
> What seems to happen is this: We run into a Metaspace OOM, then the
> JVMTI agent attempts to print its histogram, walks part of the heap,
> then we run into a "guarantee(!thread->is_Compiler_thread())".
> Therefore I wonder whether compiler threads can allocate Metaspace?
> Looking at the sources, I see potential call paths from the compiler,
> e.g. Method::build_interpreter_method_data(), which will allocate
> space in Metaspace for a MethodData object, and which in turn, to me,
> looks like it could be invoked from compiler code (e.g. during
MethodData and MethodCounter are used for profiling (the main purpose) and record deoptimization reasons as you pointed.
Interpreter and C1 generated code are accessing it to write profiling data. Both C1 and C2 can create such objects
during compilation if Interpreter did not create them yet. The profiling data is accesses by C2 during compilation -
this is the main purpose.
> If yes - compiler can allocate metaspace - how would they deal with
> Metaspace OOMs?
If MethodData is not available (failed to allocate) we create empty ciMethodData and use it during C2 compilation
(compilation will be similar to -Xcomp compilation):
We bailout C1 Tier3 compilation (with profiling) if no data available:
> Also note that I am not sure at all whether that type of usage -
> calling FollowReferences() when handling ResourceExhausted - is even
> allowed in JVMTI.
> Thanks a lot,
> Best Regards, Thomas
More information about the hotspot-compiler-dev