I discovered the New World, and so will send you the code. "
"Loud noise, and so excited."
"When will ..."
"I inserted consecutively in an ArrayList of 10 million pieces of data, the results are not as time-consuming, are not understood 2,346,797"
I looked at, I know this guy chassis instability.
"You add -XX: + PrintGCDetails -XX: + PrintGCDateStamps, is not there to see the first time under a Full GC"
"See, I try again."
After a few minutes...
2019-09-28T09:49:07.519-0800: [GC (Allocation Failure) [PSYoungGen: 54888K->10738K(76288K)] 54888K->36180K(251392K), 0.0520111 secs] [Times: user=0.24 sys=0.03, real=0.06 secs] 2019-09-28T09:49:07.590-0800: [GC (Allocation Failure) [PSYoungGen: 74092K ->10736K(141824K)] 99534K->80803K(316928K), 0.0693607 secs] [Times: user=0.39 sys=0.03, real=0.06 secs] 2019-09-28T09:49:07.751-0800: [GC (Allocation Failure) [PSYoungGen: 141808K->10736K(141824K)] 211875K->188026K(320512K), 0.1829926 secs ] [Times: user=1.02 sys=0.10, real=0.18 secs] 2019-09-28T09:49:07.934-0800: [Full GC (Ergonomics) [PSYoungGen: 10736K-> 0K(141824K)] [ParOldGen: 177290K->171620K(402432K)] 188026K->171620K(544256K), [Metaspace: 3062K->3062K(1056768K)], 1.8672996 secs] [Times: user=5.96 sys=0.03, real=1.87 secs] 2365 2019-09-28T09:49:09.832-0800: [GC (Allocation Failure) [PSYoungGen: 129254K->10738K(196608K)] 300875K->282609K(599040K), 0.1039307 secs] [Times: user=0.74 sys=0.07, real=0.10 secs] 2019-09-28T09:49:09.936-0800: [Full GC (Ergonomics) [PSYoungGen: 10738K->0K(196608K)] [ParOldGen: 271871K->36047K(372736K)] 282609K->36047K(569344K), [Metaspace: 3067K->3067K(1056768K)], 0.4510440 secs] [Times: user=1.82 sys=0.01, real=0.45 secs] 2019-09-28T09:49:10.440-0800: [GC (Allocation Failure) [PSYoungGen: 185856K->10752K(264704K)] 221903K->171359K(637440K), 0.1292143 secs] [Times: user=0.97 sys=0.01, real=0.12 secs] 772
Full GC for the first time really took the 1.87s, then I look at the pile turn up, avoid Full GC "
After a few minutes...
"This is not a GC, but each run after a time-consuming than the previous multi-point, how is this going?"
"You try on different threads running?"
"好"
After another few minutes ...
"Execute in different threads, both time-consuming almost the same, why is this?"
"You know OSR it?"
"do not know."
"I will probably talk with you."
OSR (On-Stack Replacement), an alternative technique is a function of stack frames / running method at runtime.
In modern mainstream JVM, both have the ability to compile multiple layers, beginning by way of explanation for execution, this performance is relatively (and c ++ ratio) will be a little slow, but once a certain function to perform very frequent discovery It will adopt JIT compiler to improve the implementation of the performance function (mostly faster than c ++).
However, if the JIT compiler function as a unit, then it can not cope with the case main function contains the loop body, this time, OSR came in handy.
Its entire compilation method, we can find a method, there are hot cycle time, choose only the compilation method in a loop, when the loop execution to i = 5000, the cycle counter reaches the threshold triggering OSR compiled , etc. generated after compilation is complete, the compiled code can be executed. So in the example above, when we execute the loop body a second time, after the execution of the code has been compiled OSR, then the performance will be faster than the previous one a little bit.
OSR more specific implementation principle, we will not pay more get to the bottom, interested students can read at larger R know almost. https://tinyurl.com/y3yxu8fc