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

Preload asset/app creators before evaluation #749

Merged
merged 2 commits into from
Nov 29, 2021

Conversation

tolikzinovyev
Copy link
Contributor

@tolikzinovyev tolikzinovyev commented Oct 22, 2021

Summary

Preloading asset/app creators in a batch improves performance by ~10%.

Depends on #746.

@gmalouf
Copy link
Contributor

gmalouf commented Oct 23, 2021

Suggest holding off for now - build is failing, and the snapshotting and beefier machine changes will play a much larger role in performance improvement.

@codecov-commenter
Copy link

codecov-commenter commented Oct 23, 2021

Codecov Report

Merging #749 (134e2f7) into develop (2b71eeb) will increase coverage by 0.19%.
The diff coverage is 78.94%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #749      +/-   ##
===========================================
+ Coverage    55.17%   55.37%   +0.19%     
===========================================
  Files           27       27              
  Lines         3815     3850      +35     
===========================================
+ Hits          2105     2132      +27     
- Misses        1435     1440       +5     
- Partials       275      278       +3     
Impacted Files Coverage Δ
idb/postgres/postgres.go 48.47% <78.94%> (+0.73%) ⬆️

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 2b71eeb...134e2f7. Read the comment docs.

Copy link
Contributor

@winder winder left a comment

Choose a reason for hiding this comment

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

This looks correct, but should it be part of the EvalForIndexer interface? I thought that interface's main purpose was to make it easier to preload everything.

@tolikzinovyev
Copy link
Contributor Author

This looks correct, but should it be part of the EvalForIndexer interface? I thought that interface's main purpose was to make it easier to preload everything.

I don't think I understand.

@winder
Copy link
Contributor

winder commented Nov 4, 2021

This looks correct, but should it be part of the EvalForIndexer interface? I thought that interface's main purpose was to make it easier to preload everything.

I don't think I understand.

I'm asking about the design here, not the implementation.

You're using a combination of these new methods:

	LookupWithoutRewards(map[basics.Address]struct{}) (map[basics.Address]*basics.AccountData, error)
	GetAssetCreator(map[basics.AssetIndex]struct{}) (map[basics.AssetIndex]FoundAddress, error)
	GetAppCreator(map[basics.AppIndex]struct{}) (map[basics.AppIndex]FoundAddress, error)

I thought one reason for those methods was to avoid needing this sort of preloading, so I wonder if the interface is wrong.

Should it be a single method instead of 3? Or perhaps we add a 4th method to the interface specifically designed to help with caching.

@tolikzinovyev
Copy link
Contributor Author

If your suggestion is to have the code that decides what to preload in go-algorand, then @tsachiherman was against it. We still need the interface functions in case we forget to preload something and the evaluator needs it. Let me know if this doesn't quite answer your questions.

@tsachiherman
Copy link
Contributor

@winder - there are two "faces" for the evaluator:
We try to preload all the required resources before the evaluation. However, if during evaluation we find that we need additional resources, we need to provide the functionality to retrieve them.

The reason the evaluator need to be "dynamic" is that it's also being used for the transaction pool, where we add transactions on the fly. I wouldn't oppose to open a discussion on whether the evaluator need to be resource-predictable or not ( outside the scope of this PR ).

@winder
Copy link
Contributor

winder commented Nov 4, 2021

@tolikzinovyev @tsachiherman thanks for the explanations. I guess the difference between algod and indexer is that algod's caching system exists outside of these functions and Indexer's is using them to initialize the cache.

It might be good to rename this function to something like preloadEvalResources to be more specific about what sort of preparation is happening.

Do we need to modify GetAssetCreator and GetAppCreator to check the cache? Wouldn't the evaluator call these functions a second time after preloading everything?

@tolikzinovyev
Copy link
Contributor Author

After we give the resources to the evaluator, it's not supposed to request them.

@tolikzinovyev tolikzinovyev marked this pull request as draft November 5, 2021 17:37
@tolikzinovyev tolikzinovyev marked this pull request as ready for review November 29, 2021 17:20
@tolikzinovyev tolikzinovyev merged commit 7184934 into develop Nov 29, 2021
@tolikzinovyev tolikzinovyev deleted the tolik/preload-creators branch November 29, 2021 17:20
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.

5 participants