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

Add a caching system for the stateTries … #2261

Merged
merged 3 commits into from May 8, 2020
Merged

Add a caching system for the stateTries … #2261

merged 3 commits into from May 8, 2020

Conversation

ineiti
Copy link
Member

@ineiti ineiti commented May 4, 2020

The current stateTries have two bottlenecks:

  • LoadConfigFromTrie - which is called everytime a LoadDarcFromTrie is called and
    decodes the config protobuf structure every time anew
  • LoadDarcFromTrie - which is called when evaluating signatures or authorizations

This PR adds a cache for both of these methods, so that calls within the
same block are cached. The test, which is a bit artificial, gives the
following improvements:

  • LoadConfigFromTrie - 3x faster authorization check
  • LoadDarcFromTrie - 4x faster authorization check

The latter is a bit artificial, because it measures looking up the same darcs
repeatedly, which in practice happens rarely.

The first test, however, is very relevant. In the 9cc3-chain, it is even worse,
as the config contains more nodes, which will make protobuf.Decode even
slower.

Closes #2258

The current stateTries have two bottlenecks:
- LoadConfigFromTrie - which is called everytime a LoadDarcFromTrie is called and
decodes the config protobuf structure every time anew
- LoadDarcFromTrie - which is called when evaluating signatures or authorizations

This PR adds a cache for both of these methods, so that calls within the
same block are cached. The test, which is a bit artificial, gives the
following improvements:
- LoadConfigFromTrie - 3x faster authorization check
- LoadDarcFromTrie - 4x faster authorization check

The latter is a bit artificial, because it measures looking up the same darcs
repeatedly, which in practice happens rarely.

The first test, however, is very relevant. In the 9cc3-chain, it is even worse,
as the config contains more nodes, which will make protobuf.Decode even
slower.
@ineiti ineiti requested a review from Gilthoniel May 4, 2020 06:27
@ineiti ineiti added this to WIP in Cothority via automation May 4, 2020
@ineiti ineiti moved this from WIP to Ready4Merge in Cothority May 4, 2020
@ineiti ineiti self-assigned this May 7, 2020
@ineiti ineiti requested a review from tharvik May 8, 2020 15:10
@tharvik tharvik merged commit 38ff4b7 into master May 8, 2020
Cothority automation moved this from Ready4Merge to Closed May 8, 2020
@tharvik tharvik deleted the speed_up_darcs branch May 8, 2020 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Cothority
  
Closed
Development

Successfully merging this pull request may close these issues.

None yet

2 participants