-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add option to disable/limit threads #1607
Comments
To my knowledge the compiler is essentially single-threaded. Can you provide more details about the thrashing you've seen? How much memory was the compiler using? Which versions did you update from and to? |
It's true - like any workhorse compiler, closure-compiler makes my macbook pro sounds like it is getting ready for a takeoff. But that's any compiler ... |
@struys Compiler.java has a diableThreads() option but I doubt it will help. |
@struys You can pass the flag Closing this issue since there is no actionable information here. If you find some slowdown for some specific pass, and you can give us instructions to reproduce, then we can look into it. |
(I work with @struys)
We're using plovr.
The processes are using ~150MB resident memory, each.
From: v20150729 To: v20151216 The TIMING_ONLY run didn't show anything notable. |
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=100425540
The cause is the new |
We plan to submit a patch for this and would like some guidance; how would you like to see this configured. The current thinking is to make the number of threads default to the number of CPU cores, and make this ratio tunable (something like --threads-per-cpu 2). |
Interesting, 44 threads per process sounds a a bit ridiculous. I thought that particular commit shouldn't cause more threads to be created. We were using |
Sounds like this is a plovr issue. As stated the compiler should only need using ones thread per compilation job. Embedders are free to start as many parallel jobs are they wish / think they can handle. |
I ran into a similar issue. In your case, Plovr must be starting and killing multiple compilation jobs (different Compiler instances), possibly sequentially. Perhaps Plovr is interrupting the thread. That's what I'm trying. But Closure Compiler doesn't have a mechanism to cancel an ongoing compilation - it merely forgets the thread is running when interrupted. See CompilerExecutor. I'm experimenting with Compiler.disableThreads() to work around this, but may consider a PR to properly interrupt compilation, some volatile boolean in Compiler which causes a commonly access method such as NodeTraversal.traverse to fail propagate some runtime exception, perhaps. |
I think to interrupt, you may just be able to report an error to the compiler, then the compiler will stop before the next pass starts unless you are running in "ide mode":
|
Thanks. I need something more prompt, so I extended Compiler, overrode a bunch of public/protected methods, threw a RuntimeException and caught it higher up. Works well, but there'll be some fallout when I next update the compiler version probably. I think a PR for an API to interrupt compilation is probably to specific to my own uses, so unless you say otherwise I'll leave it at that. Also see #1822 |
Coming back to this as I'm investigating something similar internally at Google. So between v20150729 and v20151216 something did change: 73eb61b In an upcoming change I'm changing |
Because projects might reuse the Compiler instance for multiple compilations, set a new ExecutorService at the beginning of runInCompilerThread(). Should fix #1607 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=160981960
We updated to a more recent version of the closure compiler and we're seeing it thrash our development machines. I believe this is happening because closure is using a ton of CPU, I'd like a way to limit the CPU usage by either disabling or limiting the number of threads used.
The text was updated successfully, but these errors were encountered: