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

Defer creation of current-time-in-seconds thread until runtime #3385

Merged
merged 12 commits into from
Sep 10, 2021
Merged

Defer creation of current-time-in-seconds thread until runtime #3385

merged 12 commits into from
Sep 10, 2021

Conversation

tjquinno
Copy link
Member

@tjquinno tjquinno commented Sep 7, 2021

Replaces #3374
Resolves #3389

This PR picks up Tomas's earlier one (#3374) and incorporates Daniel's comments.

The separate commits divide up the changes clearly, I hope.

Aside from adopting Daniel's suggestion for a three-state model for the executor, the other main change is to maintain a list of ExponentiallyDecayingReservoirs for which their current-time-in-seconds should be updated periodically, rather than keep a list of Runnable; we don't need to be that general and it's clearer and probably faster this way.

Also, the earlier shutdown processing (awaitTermination to wait for the scheduled tasks to finish) seemed to time out rather than complete, so I've changed it to use shutdownNow instead.

@tjquinno tjquinno added this to the 2.4.0 milestone Sep 7, 2021
@tjquinno tjquinno self-assigned this Sep 7, 2021
@tjquinno
Copy link
Member Author

tjquinno commented Sep 7, 2021

Comment copied from the other PR:

danielkec yesterday Member
Seems to me we need one more atomic state here to safeguard against init() being invoked just after onServerShutdown() gate eg. 'INIT, STARTED, STOPPED'.

…; for updating each EDR's current time, keep list of EDRs rather than of Runnables
…stion; convert updates of current times from .forEach to for-each
@tjquinno tjquinno changed the title WIP: Defer creation of current-time-in-seconds thread until runtime Defer creation of current-time-in-seconds thread until runtime Sep 8, 2021
@tjquinno tjquinno mentioned this pull request Sep 8, 2021
@tjquinno
Copy link
Member Author

tjquinno commented Sep 9, 2021

The refactoring in the previous push takes the single-thread executor handling out of ExponentiallyDecayingReservoir because in a future PR the ConcurrentGauge will also use this mechanism. State checking and management occurs entirely within synchronized methods; none of the critical regions should execute very often so performance should not really be an issue.

@tjquinno tjquinno requested a review from danielkec September 9, 2021 16:31
Copy link
Member

@tomas-langer tomas-langer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tjquinno tjquinno merged commit 786244b into helidon-io:master Sep 10, 2021
@tjquinno tjquinno deleted the native-image-edr-fix branch September 10, 2021 14:47
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

Successfully merging this pull request may close these issues.

native-image build fails due to metrics performance optimization
3 participants