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

Cache creators in cow base #2939

Merged
merged 1 commit into from
Sep 23, 2021

Conversation

tolikzinovyev
Copy link
Contributor

Summary

The evaluator shouldn't ask the ledger who is the creator of an asset multiple times. This PR adds a cache for ledger's responses in cow base.

Test Plan

Added a test. Is there a better way to write a mock test?

@codecov-commenter
Copy link

codecov-commenter commented Sep 22, 2021

Codecov Report

Merging #2939 (4420f23) into master (01d853f) will increase coverage by 0.03%.
The diff coverage is 63.63%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2939      +/-   ##
==========================================
+ Coverage   47.27%   47.31%   +0.03%     
==========================================
  Files         356      356              
  Lines       57239    57249      +10     
==========================================
+ Hits        27062    27089      +27     
+ Misses      27108    27099       -9     
+ Partials     3069     3061       -8     
Impacted Files Coverage Δ
ledger/appcow.go 81.95% <0.00%> (-0.25%) ⬇️
ledger/evalIndexer.go 38.55% <ø> (ø)
ledger/eval.go 78.03% <70.00%> (-0.15%) ⬇️
ledger/roundlru.go 90.56% <0.00%> (-5.67%) ⬇️
network/wsPeer.go 72.14% <0.00%> (-2.23%) ⬇️
network/wsNetwork.go 60.90% <0.00%> (ø)
ledger/acctupdates.go 63.01% <0.00%> (+0.51%) ⬆️
network/requestTracker.go 71.12% <0.00%> (+0.86%) ⬆️
catchup/peerSelector.go 100.00% <0.00%> (+1.04%) ⬆️
ledger/msgp_gen.go 35.32% <0.00%> (+1.12%) ⬆️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 01d853f...4420f23. Read the comment docs.

Copy link
Contributor

@tsachiherman tsachiherman left a comment

Choose a reason for hiding this comment

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

looks good to me.

Copy link
Contributor

@algorandskiy algorandskiy left a comment

Choose a reason for hiding this comment

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

Looks good, only concerning on FoundAddress type name

}

// FoundAddress is a wrapper for an address and a boolean.
type FoundAddress struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

why is it exported? The struct name sound a bit weird. Maybe cachedCreator or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FoundAddress is also used in evalIndexer.go where this type needs to be exposed to Indexer. I think this name is ok for caching as well. FoundAddress encodes an address that is found (or not found). That is exactly what we want to cache.

Copy link
Contributor

@tsachiherman tsachiherman left a comment

Choose a reason for hiding this comment

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

When do we need to cache non-existent addresses ? It looks like the Exists it's a mutually exclusive with the Address.

@tolikzinovyev
Copy link
Contributor Author

Maybe caching responses for non-existent assets is silly, but it lets indexer preload such responses in a batch.

Copy link
Contributor

@tsachiherman tsachiherman left a comment

Choose a reason for hiding this comment

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

I think we can do better here on both the struct naming as well on the cached content, but I can't see a (good) reason to block this one right away. We could iterate on the above in the future.

@tsachiherman tsachiherman merged commit a196929 into algorand:master Sep 23, 2021
@tolikzinovyev tolikzinovyev deleted the creators-cow-base branch September 23, 2021 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants