What does allocation rate means in JMH
Asked Answered
T

1

8

I'm trying to measure the memory consumed when running the benchmark. I found out on the internet that I can use GC profiler to measure that. I tried but I don't understand the answer as well as see the amount of consumed memory. Can anyone explain the results? Thanks.

MyBenchmark.testMethod_width_2_attribute_text                                     ss   60        32.345 ±       1.759   ms/op
MyBenchmark.testMethod_width_2_attribute_text:·gc.alloc.rate                      ss   60        26.904 ±       0.217  MB/sec
MyBenchmark.testMethod_width_2_attribute_text:·gc.alloc.rate.norm                 ss   60  14999630.400 ±      12.578    B/op
MyBenchmark.testMethod_width_2_attribute_text:·gc.churn.PS_Eden_Space             ss   60        28.282 ±      15.342  MB/sec
MyBenchmark.testMethod_width_2_attribute_text:·gc.churn.PS_Eden_Space.norm        ss   60  15903402.667 ± 8631257.013    B/op
MyBenchmark.testMethod_width_2_attribute_text:·gc.churn.PS_Survivor_Space         ss   60         0.654 ±       0.754  MB/sec
MyBenchmark.testMethod_width_2_attribute_text:·gc.churn.PS_Survivor_Space.norm    ss   60    368914.667 ±  425374.152    B/op
MyBenchmark.testMethod_width_2_attribute_text:·gc.count                           ss   60        26.000                counts
MyBenchmark.testMethod_width_2_attribute_text:·gc.time                            ss   60       105.000                    ms
Tempestuous answered 28/2, 2018 at 19:26 Comment(0)
H
3

Under covers, jmh uses ThreadMXBean so this looks like a report that says how many bytes per operation are allocated and how many MB/sec in each GC space (like Eden/Survivor)

.norm stands for normalized.

Hopscotch answered 28/2, 2018 at 20:3 Comment(4)
Some questions: 1. What doe PS stand for in PS_Eden_Space? 2. What is gc.count? The number of times the garbage collector was invoked? 3. What is gc.time? The total time taken by the garbage collector over all its invocations?Bret
Regarding the prefix: PS stands for Parallel Scavenge. It is the name of your garbage collector and it means you are using the GC -XX:+UseParallelGC. If you specify -XX:+UseParNewGC JVM argument, then the prefix will become Par and with -XX:+UseG1GC it will be G1Machree
The count and time are the number of garbage collections that were executed during a jmh iteration and the total time the jvm spent on these garbage collections. They are actually the between- and after- jmh iteration differences of java.lang.management.GarbageCollectorMXBean 's getCollectionCount() and getCollectionTime(). You can read these methods' javadoc for more informationMachree
The .norm fields indeed stand for normalized and correspond to the relevant metric but divided by the number of jmh operations. So if you ran a jmh iteration which invoked 1,000 operations (i.e. your test method), then e.g. ·gc.alloc (not reported) would be the size of memory allocated during that iteration, ·gc.alloc.rate would be the memory allocated per unit of time (second or millisecond) and ·gc.alloc.rate.norm the memory allocated per operation. This last one should give you an idea of how much new memory gets allocated by your code (i.e. your "operation")Machree

© 2022 - 2024 — McMap. All rights reserved.