Avoid using caller unless it will be used #62
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
caller
is pretty well known to be slow, since it has to navigate the stack among other things.notify
usesnotify?
as a guard clause inside it, but by the time it exits early,caller
has already gotten the stack trace. This PR checksnotify?
at the callsites ofnotify
instead, so thatcaller
won't run unless notifications are going to go out.I found this while using memory_profiler on some of my slow system specs. Here's some choice lines from the report:
With this proposed change, isolator doesn't even show up in the memory_profiler report. To get a sense of the scope, for this one system spec, here's the before summary:
and after:
That's 410,461,332 less allocated memory (7.6% reduction), 1,256,965 less allocated objects (2.7% reduction), 11,320,668 less retained memory (6.2% reduction), and 128,146 less retained logics (10% reduction).
What is the purpose of this pull request?
What changes did you make? (overview)
Is there anything you'd like reviewers to focus on?
Checklist