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

Short-circuit evaluation of stale actions on reorg #970

Merged
merged 3 commits into from
Aug 29, 2020

Conversation

dahlia
Copy link
Contributor

@dahlia dahlia commented Aug 27, 2020

This addresses #967.

The previous patch #963 unified two types of events into one: one is for rendering/unrendering actions, and other one is for watching new tips & reorgs. At the same time, it also threw away the BlockChain<T>() constructor's Boolean option render because I thought it's redundant as render: false seemed equivalent to renderers: null.

However, those two changes regressed the performance of reorg, because the optimization made by the patch #883 was thrown away together. The disappeared optimization was a short-circuit evaluation option for stale actions to be unrendered. As the option render: false was removed, stale actions became evaluated even if there is no renderers, or all renderers do nothing for UnrenderAction()/UnrenderActionError() events…

In order to fix this performance regression, I reverted (with some adjusts and new name) ShortCircuitActionEvaluationForUnrenderWithNoActionRenderers (was Render) test, I removed in the previous patch #963, and refactored the renderer interface(s) according to the conclusion made in the issue #967. Now we have a new interface named IActionRenderer<T>, is basically equivalent to the previous IRenderer<T>, and IRenderer<T> became to have only block-related events. BlockChain<T>.Swap() now omits evaluation of stale actions if there is no IActionRenderer<T> at all.

@dahlia dahlia self-assigned this Aug 27, 2020
@dahlia dahlia linked an issue Aug 27, 2020 that may be closed by this pull request
@dahlia dahlia changed the title WIP: Separate IActionRenderer<T> from IRenderer<T> WIP: Short-circit evaluation of stale actions on reorg Aug 27, 2020
@codecov
Copy link

codecov bot commented Aug 27, 2020

Codecov Report

Merging #970 into main will decrease coverage by 1.06%.
The diff coverage is 89.51%.

@@            Coverage Diff             @@
##             main     #970      +/-   ##
==========================================
- Coverage   88.81%   87.74%   -1.07%     
==========================================
  Files         288      288              
  Lines       26766    26588     -178     
==========================================
- Hits        23771    23329     -442     
- Misses       1466     1730     +264     
  Partials     1529     1529              
Impacted Files Coverage Δ
...ests/Blockchain/Renderers/AnonymousRendererTest.cs 83.87% <ø> (-3.72%) ⬇️
...t.Tests/Blockchain/Renderers/LoggedRendererTest.cs 99.11% <ø> (-0.14%) ⬇️
Libplanet.Tests/Common/Action/ExecuteRecord.cs 60.00% <0.00%> (-40.00%) ⬇️
Libplanet.Tests/Common/DumbRenderer.cs 93.33% <ø> (ø)
Libplanet.Tests/Store/StateStoreTracker.cs 60.00% <0.00%> (ø)
Libplanet/Action/PolymorphicAction.cs 100.00% <ø> (ø)
...ibplanet/Blockchain/Renderers/AnonymousRenderer.cs 100.00% <ø> (ø)
Libplanet/Store/Trie/Nodes/FullNode.cs 31.25% <31.25%> (ø)
Libplanet/Store/Trie/InvalidTrieNodeException.cs 33.33% <33.33%> (ø)
Libplanet/Store/Trie/Nodes/ShortNode.cs 50.00% <50.00%> (ø)
... and 110 more

@dahlia dahlia changed the title WIP: Short-circit evaluation of stale actions on reorg Short-circit evaluation of stale actions on reorg Aug 27, 2020
@dahlia dahlia marked this pull request as ready for review August 27, 2020 10:51
longfin
longfin previously approved these changes Aug 27, 2020
@longfin
Copy link
Member

longfin commented Aug 28, 2020

/rebase

@dahlia
Copy link
Contributor Author

dahlia commented Aug 28, 2020

@planetarium/libplanet Applied suggestions and rebased on the up-to-date main. Please review this again!

@dahlia dahlia requested review from earlbread and longfin August 28, 2020 03:40
earlbread
earlbread previously approved these changes Aug 28, 2020
@dahlia
Copy link
Contributor Author

dahlia commented Aug 28, 2020

@earlbread @moreal Fixed a typo. Please review this again.

earlbread
earlbread previously approved these changes Aug 28, 2020
moreal
moreal previously approved these changes Aug 28, 2020
limebell
limebell previously approved these changes Aug 28, 2020
riemannulus
riemannulus previously approved these changes Aug 28, 2020
@dahlia
Copy link
Contributor Author

dahlia commented Aug 28, 2020

@planetarium/libplanet Rebased again!

@longfin longfin changed the title Short-circit evaluation of stale actions on reorg Short-circuit evaluation of stale actions on reorg Aug 28, 2020
@dahlia dahlia merged commit 635d3a4 into planetarium:main Aug 29, 2020
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.

Let IRenderer<T> turn on and off evaluating actions
6 participants