You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to documentation Bazel allows to instrument memory allocations. It seems that now this feature provides an incorrect information.
All values of memory consumption for rules are either 0 or values which are roughly multiples of 256kB. For example, the text dump for prof.gz shows:
The total memory consumption is also far from expected values.
It looks like the values of memory consumption are taken from shifted position in memory. It might be caused by changes in internal Java structures.
I believe, the problem is in outdated version of java-allocation-instrumenter-3.3.0.jar used for instrumenting. According to Release notes the support for Java 17 was added in 3.3.2, and support for Java 21 was added in 3.3.4.
However, my attempts to use a newer version of instrumenter were unsuccessful. Bazel crashes with any version higher than 3.3.0. The error message is unclear:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(Unknown Source)
at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(Unknown Source)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException: Cannot invoke "java.net.URL.openConnection()" because "url" is null
at com.google.monitoring.runtime.instrumentation.AllocationInstrumenterBootstrap.premain(AllocationInstrumenterBootstrap.java:50)
... 4 more
Caused by: java.lang.NullPointerException: Cannot invoke "java.net.URL.openConnection()" because "url" is null
at com.google.monitoring.runtime.instrumentation.AllocationInstrumenterBootstrap.premain(AllocationInstrumenterBootstrap.java:40)
... 4 more
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message Outstanding error when calling method in invokeJavaAgentMainMethod at s\src\java.instrument\share\native\libinstrument\JPLISAgent.c line: 627
*** java.lang.instrument ASSERTION FAILED ***: "success" with message invokeJavaAgentMainMethod failed at s\src\java.instrument\share\native\libinstrument\JPLISAgent.c line: 466
*** java.lang.instrument ASSERTION FAILED ***: "result" with message agent load/premain call failed at s\src\java.instrument\share\native\libinstrument\JPLISAgent.c line: 429
FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed
Which category does this issue belong to?
Performance
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Perform steps according to documentation:
Pass STARTUP_FLAGS to any Bazel invocation:
STARTUP_FLAGS=\
--host_jvm_args=-javaagent:<path to java-allocation-instrumenter-3.3.0.jar> \
--host_jvm_args=-DRULE_MEMORY_TRACKER=1
Run any bazel build
Run bazel dump --rules or bazel dump --skylark_memory=$HOME/prof.gz
Which operating system are you running Bazel on?
Windows, Linux, Mac
What is the output of bazel info release?
release 7.4.0
If bazel info release returns development version or (@non-git), tell us how you built Bazel.
No response
What's the output of git remote get-url origin; git rev-parse HEAD ?
No response
If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.
No response
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered:
AllocationTrackerModule forces a sample size of 256 KB, which results in all measurements being a multiple of that. I updated the version in #24783, but I can't reproduce the crash with it (on macOS). Could you try again with Bazel from that PR?
Thank you, @fmeum
I tried with your changes applied over Bazel 7.4.0 and java-allocation-instrumenter-3.3.4.jar. It doesn't crash any more. Also, memory consumption now looks much more real than before. For the same target as in initial comment, it shows 106.48Mb instead of 5.88Mb:
Description of the bug:
According to documentation Bazel allows to instrument memory allocations. It seems that now this feature provides an incorrect information.
All values of memory consumption for rules are either 0 or values which are roughly multiples of 256kB. For example, the text dump for prof.gz shows:
The total memory consumption is also far from expected values.
It looks like the values of memory consumption are taken from shifted position in memory. It might be caused by changes in internal Java structures.
I believe, the problem is in outdated version of
java-allocation-instrumenter-3.3.0.jar
used for instrumenting. According to Release notes the support for Java 17 was added in 3.3.2, and support for Java 21 was added in 3.3.4.However, my attempts to use a newer version of instrumenter were unsuccessful. Bazel crashes with any version higher than 3.3.0. The error message is unclear:
Which category does this issue belong to?
Performance
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Perform steps according to documentation:
bazel build
bazel dump --rules
orbazel dump --skylark_memory=$HOME/prof.gz
Which operating system are you running Bazel on?
Windows, Linux, Mac
What is the output of
bazel info release
?release 7.4.0
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse HEAD
?No response
If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.
No response
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: