-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
high CPU usage on CharPredicate.Digit #518
Comments
Is it the same bytecode that runs fine on 19 but "hangs" in 21? |
not exactly as we changed |
Hmm... if it's not deterministically exhibiting this behavior on one particular machine (setup) then I wonder how two different runs might differ from each other. |
There's one new instance per input, and also per thread
The input is coming from user, so it can be that it's partial. |
Can you show what your |
|
Hmm... this really is curious. In order to debug further it's be great to get a hold of a pathological input and try to reproduce the problem under the microscope... |
We're parsing Strings. I'm trying to get more data. But I cannot reproduce the issue locally, even with those inputs. |
Some update: this issue also occurs with JVM 19 (maybe less frequently, but I cannot be sure here). |
Hello! I carried on the analysis with this a bit after taking over the JVM21 upgrade from @yanns. This rule is what is causing the 100% CPU hang that @yanns saw. However it does not happen often and it only happens if the JVM gets fairly hot. In a unit test scenario it works perfectly each time and never hangs.
I was suspicious of the macros, so I replaced it with the code being generated:
Then I saw it hang at the recursive call to However this is impossible because every call does As unlikely as it seems, I can't help but conclude this is genuinely a JVM bug itself in the PGO. Not when making the standard first-pass bytecode but the highly optimized x86 code. It must be making some flawed assumption with the bitwise operators and spitting out an infinite loop. 🤷 This is also a very delicate error case. I tried some basic tweaks such as adding printlns or a loop counter with break and doing anything like that immediately "fixed" it. Trying to move this out of our fairly large Scala application into a minimal reproducer also failed. For now |
That is really curios. But I agree that it's definitely strange that the same code running on the same input behaves differently depending on the JVM being hot or cold. Aside from a bug in the JVM (as you suspect) the reason could be the different runtime performance triggering synchronization, caching or other issues that are indeterministic. |
Hmm... I see. Thank you for reporting this! One way to test for a genuine JVM bug could be to simply run different JVM implementations, i.e. Graal, Temurin, etc. against each other. Many probably share the same code somewhere deep down and thus might exhibit identical behavior but I could imagine that Graal for example is different enough to provide a good test subject. |
For what it's worth I did try OpenJDK 23 as well, which also fixed it.
Yes definitely still fast enough. :D |
Ah, ok. |
When updating from JVM 19 to JVM 21, we notice very high CPU usage.
A profiling reveals a method using a simple rule:
I don't know if anyone has already seen this behavior before, and/or has a clue where to look at.
The text was updated successfully, but these errors were encountered: