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

About Thread Long Runs #123

Open
MrLi2018 opened this issue Jan 26, 2022 · 5 comments
Open

About Thread Long Runs #123

MrLi2018 opened this issue Jan 26, 2022 · 5 comments
Labels

Comments

@MrLi2018
Copy link

If a thread continuously executes different scripts for a long time, the memory usage will be exceeded. This is because the CPU execution time is the total time of the thread.

@mxro
Copy link
Collaborator

mxro commented Jan 27, 2022

Thank you for raising this issue! What do you think could be a good solution to this?

I guess a workaround would be to spawn new threads? And otherwise probably calculate execution time delta?

@MrLi2018
Copy link
Author

Thanks for your answer, I'm not sure if the problem exists or if I'm using it incorrectly, I've tried to use new threads, but this will increase my thread context switching.

@mxro
Copy link
Collaborator

mxro commented Feb 1, 2022

Looking at this line in the code: https://github.com/javadelight/delight-nashorn-sandbox/blob/master/src/main/java/delight/nashornsandbox/internal/ThreadMonitor.java#L123 It seems as if the starttime is taken into consideration when calculating if the runtime for a particular thread is exceeded.

So it shouldn't be required to create a new thread solely for the purpose to have the cpu limit work. That being said, I think getThreadCpuTime may not be very accurate: https://github.com/javadelight/delight-nashorn-sandbox/blob/master/src/main/java/delight/nashornsandbox/internal/ThreadMonitor.java#L216

@mxro mxro added the question label Feb 1, 2022
@tellmewhattodo
Copy link

tellmewhattodo commented Feb 2, 2022 via email

@MrLi2018
Copy link
Author

MrLi2018 commented Feb 8, 2022

I have a question about whether the rhino scripting engine can set thresholds for instruction counts and whether nashorn can do the same without relying on thread monitoring.

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

3 participants