-
Notifications
You must be signed in to change notification settings - Fork 13
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
Optimize IdentifierIssuer existing Map. #65
base: main
Are you sure you want to change the base?
Conversation
- Change clones from always-copy to copy-on-write. - Depending on shape of data, this can reduce `Map` copies by ~90%. However, in some data patterns, these will have very few entries, so overall performance may not be noticeably effected.
80e1b96
to
3d15697
Compare
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #65 +/- ##
==========================================
+ Coverage 88.44% 88.52% +0.07%
==========================================
Files 10 10
Lines 580 584 +4
==========================================
+ Hits 513 517 +4
Misses 67 67
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
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.
Seems ok ... the TODO should be moved to an issue. By removing the prefix _
from _existing
it will move it into public space which seems like a bad idea. Let's keep it. It's ok that it's used in "protected" space by the same class.
this.prefix = prefix; | ||
this._existing = existing; |
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.
Let's keep the prefixed _
so only protected / internal usage of this is expected.
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.
Ok. But it's not consistent. counter
is only used internally, but has no leading _
.
Map
copies by ~90%. However, in some data patterns, these will have very few entries, so overall performance may not be noticeably effected.This patch may need more work. It doesn't seem to hurt anything. Benchmarking was difficult, and it may even be slightly slower for small tests? Unclear why that would be other than faulty benchmarking.
I had expected this to show up better in benchmarks. But it seems the timing effect may be minimal. Perhaps the memory usage of fewer maps is more measurable, but I'm unsure how best to do so. For example, running the test suite with just the async code, the
clone
calls will do 25602 Map copies. With this patch it will only do 2307 copies.As noted in the code, there is a case of clones being done, but they won't unref the shared map, so another user of that map might copy it needlessly. This is a bit more involved to fix, and it's unclear how often that may happen.