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

Bug in ThreadMonitor that can cause it to wait unnecessarily #55

Closed
cmorriss opened this issue Apr 18, 2018 · 6 comments
Closed

Bug in ThreadMonitor that can cause it to wait unnecessarily #55

cmorriss opened this issue Apr 18, 2018 · 6 comments
Labels

Comments

@cmorriss
Copy link

I had noticed in some stress testing that sometimes the call to execute a function would take the maximum CPU limit time. I tracked it down to an issue in ThreadMonitor in the call to wait on the monitor object. It's possible that the threadToMonitor was already set and the monitor notification sent. In that case, the monitor wait goes to the maximum value for the cpu time limit.

The fix is pretty simple. You simply need to check if the threadToMonitor is not null in the synchronized block, but before the wait, and if it's not null, skip the wait. I can submit a pull request with the fix if that will help.

@cmorriss
Copy link
Author

// wait, for threadToMonitor to be set in JS evaluator thread
synchronized (monitor) {
    if (threadToMonitor == null) {
        monitor.wait(maxCPUTime / MILI_TO_NANO);
    }
}

@mxro
Copy link
Collaborator

mxro commented Apr 18, 2018

Hi Chris,

thanks for finding this! A pull request would be fantastic!

@cmorriss
Copy link
Author

Updates to the pull request were to get in line with the existing formatting conventions.

@cmorriss
Copy link
Author

cmorriss commented May 1, 2018

Any issues with merging this request? Happy to answer any comments or update the PR if needed.

mxro added a commit that referenced this issue May 4, 2018
Fix for issue #55: ThreadMonitor waits unnecessarily
@mxro mxro added the solved label May 10, 2018
@mxro
Copy link
Collaborator

mxro commented May 10, 2018

Fix included in release 0.1.14. Please close the issue if the fix is okay. Thank you for reporting and fixing it!!

@cmorriss
Copy link
Author

Thanks for including and sorry for the delay in closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants