Open
Conversation
Contributor
Author
|
Hi @tcrayford -- hope you get to look at this one as well -- assuming #56 is merged, this increases |
Codecov Report
@@ Coverage Diff @@
## master #57 +/- ##
==========================================
+ Coverage 96.42% 96.87% +0.44%
==========================================
Files 1 1
Lines 84 96 +12
==========================================
+ Hits 81 93 +12
Misses 3 3
Continue to review full report at Codecov.
|
Contributor
Author
|
@tcrayford have you had a chance to look at this? |
This PR is inspired by tom-pang#56, and assumes that code will be merged, so uses it in the benchmarks here: https://gist.github.com/ms-ati/fa8002ef8a0ce00716e9aa6510d3d4d9 It is common in our code, as in any idiomatic code using value objects in loops or pipelines, to call `#with` many times, returning a new immutable object each time with 1 or more fields replaced with new values. The optimizations in this PR eliminate a number of extra Hash and Array instantiations that were occurring each time, in favor of iterating only over the constant `VALUE_ATTRS` array and doing key lookups in the given Hash parameter in the hot paths. Per the gist above, this increases ips (iterations per second) 2.29x, from 335.9 to 769.6 on my machine.
15c0489 to
c3f00e3
Compare
Contributor
Author
|
@tcrayford ping again |
Contributor
Author
Contributor
Author
|
@tcrayford ping again |
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR is inspired by #56, and
assumes that code will be merged, so uses it in the benchmarks here:
https://gist.github.com/ms-ati/fa8002ef8a0ce00716e9aa6510d3d4d9
It is common in our code, as in any idiomatic code using value objects
in loops or pipelines, to call
#withmany times, returning a new immutableobject each time with 1 or more fields replaced with new values.
The optimizations in this PR eliminate a number of extra Hash and Array
instantiations that were occurring each time, in favor of iterating only over
the constant
VALUE_ATTRSarray and doing key lookups in the givenHash parameter in the hot paths.
Per the gist above, this increases ips (iterations per second) 2.29x, from
335.9 to 769.6 on my machine.
cc @michaeldiscala