-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
perf: lazily load plugins [APE-1422] #1681
Conversation
seeing about a 12% performance improvement with this on my machine 🚀 |
* feat(query): add timestamp to ContractLog fixes: ApeWorX#1612 * docs: add docstring to timestamp property of ContractLog * test: add test for ContractLog.timestamp
My goal right now is to not load plugins for any of the help-commands e.g.
but disclaimer here: if you run any cmd that loads plugins, there shouldnt be any performance gains by this PR alone. in the future, we want to load only plugins needed but thatll likely require a bigger refactor |
You will see a bigger one on commands like Main: |
_T = TypeVar("_T") # _LazySequence generic. | ||
|
||
|
||
class _LazySequence(Sequence[_T]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at this time, this is only really used in internal stuff in the framework for performance reasons; i tried using collections.deque()
but it wasnt lazily enough and so i went with this but if there is way to make deque not iterate at all upon init, that would be nice, or an alternative data structure
What I did
This shaves almost a second off of
time ape
. None of the plugins are loaded if they are not needed (but they are loaded if they are needed).How I did it
Use iterators mostly.
How to verify it
Checklist