-
Notifications
You must be signed in to change notification settings - Fork 296
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
DelegatingScheduler singletons in modern style #349
Comments
Plus it creates (if needed) ForkJoinPool with asyncMode=true (which is recommended for normal Runnables and Callables) and it uses Math.max(Runtime.getRuntime().availableProcessors(), 2) for parallelism. Second commit contains:
|
The associated PR is a lot to take on faith, and it's very hard to test. Is anyone reporting problems due to the current implementation? |
There are only 225 lines of code. I work with large sets, so every byte in RAM counts. With last commit, there is no more "fat" in code. |
I report problem so to say :-) |
Last possible optimization: |
Simply having tests to cover lines of code doesn't give me confidence in the correctness of the code. The risk involved in replacing this machinery without feedback from experts could be substantial, but getting that feedback takes time and attention. I could understand undertaking it if people were reporting actual problems, e.g., "I ran out of memory because the tasks were too big." "I'm seeing significant performance degradation due to the extra checks." Has anyone experienced problems that might stem from a need to optimize DelegatingScheduler? If not, this could be premature optimization. Side note: |
JDK's ScheduledThreadPoolExecutor accepts them (treats negative values as 0 = run immediately). This is what I mean, when I say: "too many moving parts" Maybe you could show the code to the devs?
Greta Thunberg won't love you: All this extra work adds to global warming :-) |
I am not a maintainer of this project, so I can't "show the code to the devs" beyond making comments here that interested parties might pick up on. How about making the Greta Thunberg would probably be in favor of thinking about whether the extra work isn't dominated by other concerns. |
I did a good job. And I hope the maintainer will find my changes interesting. It is easy to see the difference: simply generate 1 billion scheduled "events" and see. |
DelegatingScheduler uses an old singleton idiom with double volatile check and synchronized.
Bill Pugh Singleton Implementation is better, shorter and uses (in some cases) less memory.
Plus fields become "static final" so JVM can do some other optimizations.
The text was updated successfully, but these errors were encountered: