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

FYI: Very compact "lean" version of DelegatingScheduler #353

Open
magicprinc opened this issue Nov 29, 2022 · 1 comment
Open

FYI: Very compact "lean" version of DelegatingScheduler #353

magicprinc opened this issue Nov 29, 2022 · 1 comment

Comments

@magicprinc
Copy link

magicprinc commented Nov 29, 2022

This is the continuation of #349

Here:
https://github.com/magicprinc/failsafe/commits/leap_of_faith

Final memory balance:
-1 fat object CompletableFuture
-1 lambda Callable in DelegatingScheduler.schedule
-1 Callable-Runnable wrapper in delayer().schedule (Runnables are wrapped as Callables in FutureTask ctor)

+1 very lean object ScheduledCompletableFuture implements ScheduledFuture, Callable
(not a CompletableFuture anymore)

I am sure this is the final step and one can't optimize this class further.
Not a single unused byte in memory!

@magicprinc
Copy link
Author

magicprinc commented Nov 29, 2022

I did a (not scientific) memory test:

Old scheduled task in memory: 193 bytes
New scheduled task in memory: 136 bytes
70% of original

https://github.com/magicprinc/failsafe/blob/9f23989e3bf77e9b525d0863ba89b89075240355/core/src/test/java/dev/failsafe/internal/util/DelegatingSchedulerTest.java#L404

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

No branches or pull requests

1 participant