Skip to content
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

Rdf4j-sesameclientimpl thread occupies 100% of the CPU (without any use) #1271

Closed
tomas-knap opened this issue Jan 31, 2019 · 7 comments
Closed
Assignees
Labels
📶 enhancement issue is a new feature or improvement ⏩ performance
Milestone

Comments

@tomas-knap
Copy link

tomas-knap commented Jan 31, 2019

When using rdf4j remote (so having a client connecting to RDF4j server), we experienced on couple of servers that rdf4j-sesameclientimpl-%d thread occupies 100% of the CPU (even if there is no load, no triples added etc.).

I was investigating further and realized that the issue is because of the way how thread pool for the client is created (see the link to see the particular line of code.

The problem is that you defined the thread pool with 0 core threads, but there is a bug in Java 8 core library (the version of Java used by all our 150+ customers) - https://bugs.openjdk.java.net/browse/JDK-8129861

The workaround (suggested in that bug report) is to set number of core threads to 1. So I changed that line of code to:

Executors.newScheduledThreadPool(1, new ThreadFactory() ...

After that change, I saw that immediately the CPU usage went down from 100% to 1% or so.

We are currently using 2.3.2. Can you please do that single line of code change for us and create a bugfix release 2.3.3?

Thank you! Tomas Knap, Semantic Web Company

@barthanssens
Copy link
Contributor

barthanssens commented Jan 31, 2019

Also present in newer releases apparently...

Since it's a bug in OpenJDK, perhaps it should be selectable (e.g. by setting a system property), whether or not the number of core threads should be 0 or 1 ?

@barthanssens barthanssens added 📶 enhancement issue is a new feature or improvement and removed 🐞 bug issue is a bug labels Jan 31, 2019
@barthanssens barthanssens self-assigned this Jan 31, 2019
@barthanssens
Copy link
Contributor

@tomas-knap there's a PR with slightly different code (using a system property), would this be a workable solution for you ?

@abrokenjester abrokenjester modified the milestones: 2.3.3, 2.4.4 Feb 1, 2019
@abrokenjester
Copy link
Contributor

Apparently, Github does not allow more than one milestone on an issue 👎

@tomas-knap Thanks for reporting this. Let us know if the fix as implemented by @barthanssens is workable for you. We can accomodate doing a 2.3.3 hotfix release for this. This release will only include a fix for this particular issue. We'll likely immediately follow that with a 2.4.4 patch release as well, so that this particular fix will also be available in the latest stable release.

@tomas-knap
Copy link
Author

@jeenbroekstra Thank you for the quick response!

Yes, the fix suggested by @barthanssens is OK - it is even better than change it in the code to 1, as the workaround (1 core thread instead of 0) includes one more idle thread, which is probably waste of resources from jdk9+.

So yes, please go ahead with the PR #1272 and please let me know when 2.3.3 hotfix release is ready (please create also the one-jar version with all RDF4j modules).

Thank you!

barthanssens added a commit that referenced this issue Feb 4, 2019
* Patch for OpenJDK 100% CPU usage bug

Signed-off-by: Bart Hanssens <bart.hanssens@bosa.fgov.be>

* Make it selectable by system property

Signed-off-by: Bart Hanssens <bart.hanssens@bosa.fgov.be>

* Made variable final static + added link to description of bug

* Changed property name

Signed-off-by: Bart Hanssens <bart.hanssens@bosa.fgov.be>
@barthanssens
Copy link
Contributor

OK, I'll start the backport and release process this evening (CET). If all goes well a full 2.3.3 should be available within a day or two (depending on how smoothly the build farm runs + some manual actions)

barthanssens added a commit that referenced this issue Feb 4, 2019
* Patch for OpenJDK 100% CPU usage bug

Signed-off-by: Bart Hanssens <bart.hanssens@bosa.fgov.be>

* Make it selectable by system property

Signed-off-by: Bart Hanssens <bart.hanssens@bosa.fgov.be>

* Made variable final static + added link to description of bug

* Changed property name

Signed-off-by: Bart Hanssens <bart.hanssens@bosa.fgov.be>
@barthanssens
Copy link
Contributor

@tomas-knap 2.3.3 is available for download on the rdf4j.org website

abrokenjester pushed a commit that referenced this issue Feb 6, 2019
* Patch for OpenJDK 100% CPU usage bug

Signed-off-by: Bart Hanssens <bart.hanssens@bosa.fgov.be>

* Make it selectable by system property

Signed-off-by: Bart Hanssens <bart.hanssens@bosa.fgov.be>

* Made variable final static + added link to description of bug

* Changed property name

Signed-off-by: Bart Hanssens <bart.hanssens@bosa.fgov.be>
@hmottestad
Copy link
Contributor

Can we close this issue now? Documentation and backporting complete?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📶 enhancement issue is a new feature or improvement ⏩ performance
Projects
None yet
Development

No branches or pull requests

4 participants