Repository navigation
Set Insertion Rework - #4999
Merged
philipaconrad merged 4 commits intoAug 15, 2022
Merged
Set Insertion Rework#4999
Conversation
philipaconrad
force-pushed
the
set-insert-rework
branch
2 times, most recently
from
August 12, 2022 17:29
d0410d4 to
9a28e3b
Compare
philipaconrad
force-pushed
the
set-insert-rework
branch
from
August 15, 2022 13:56
9a28e3b to
a59aafd
Compare
Member
Author
|
Will update + squash-merge when green. 👍 |
Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
philipaconrad
force-pushed
the
set-insert-rework
branch
from
August 15, 2022 14:13
a59aafd to
ba1c4a5
Compare
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 introduces lazy key slice sorting for the Set datatype, similar to what was done in #4830 (Object Insertion Rework). After this change,
Set.Add()will be an O(1) operation, and sorting of the Set type's key slice will be delayed until just-before-use, identically to how lazy key slice sorting is done for the Object type.This will move the sorting overhead from construction-time for Sets over to eval-time, allowing much more efficient construction and use of enormous (500k+ item) Sets. In small-scale tests, this appears to be a performance-neutral change overall, while dramatically improving performance for the "large set" edge case.
This PR also introduces a 2x new benchmarks for Sets, to keep parity with what we introduced for Objects:
BenchmarkSetCreationAndLookup(Identical toBenchmarkObjectCreationAndLookup)BenchmarkSetMarshalJSON(We already benchmarkString()operations separately for Sets)Note: This change is independent of the PR for improving the set
unionbuiltin (#4980), but very slightly improves performance there as well (around 5% or smaller improvement), likely from improved efficiency in Set construction.