-
Notifications
You must be signed in to change notification settings - Fork 8
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
Reduce treatment service memory usage #59
Merged
deadlycoconuts
merged 8 commits into
caraml-dev:main
from
deadlycoconuts:reduce_treatment_service_mem_usage
Jan 19, 2023
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b1741ee
Refactor array iteration when converting interface types into basic d…
deadlycoconuts 4826f53
Remove segments from treatments after they are parsed into sets
deadlycoconuts b83afc2
Fix unit tests
deadlycoconuts 01e2d4d
Add additional comments and reorder helper method
deadlycoconuts d753a9d
Refactor boolean map into set map for boolean segment values
deadlycoconuts d076413
Fix incorrect logic in checkSegmentHasWeakMatch
deadlycoconuts 3c68735
Add todo message for future refactoring
deadlycoconuts fb285f8
Refactor control statements for readability
deadlycoconuts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -560,6 +560,7 @@ func TestExperimentIndexMatchSegment(t *testing.T) { | |
stringSetsVal := []interface{}{"test1"} | ||
intSetsVal := []interface{}{int64(1)} | ||
realSetsVal := []interface{}{1.0} | ||
boolSetsVal := []interface{}{true} | ||
experimentIndex := ExperimentIndex{ | ||
stringSets: map[string]*set.Set{ | ||
"stringType": set.New(stringSetsVal...), | ||
|
@@ -570,6 +571,9 @@ func TestExperimentIndexMatchSegment(t *testing.T) { | |
realSets: map[string]*set.Set{ | ||
"realType": set.New(realSetsVal...), | ||
}, | ||
boolSets: map[string]*set.Set{ | ||
"flagType": set.New(boolSetsVal...), | ||
}, | ||
Experiment: &_pubsub.Experiment{ | ||
Segments: map[string]*_segmenters.ListSegmenterValue{ | ||
"stringType": { | ||
|
@@ -672,7 +676,7 @@ func TestExperimentIndexMatchSegment(t *testing.T) { | |
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got := experimentIndex.matchSegment(tt.args.segmentName, tt.args.value) | ||
assert.Equal(t, got, tt.want) | ||
assert.Equal(t, tt.want, got) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Flipped this around because |
||
}) | ||
} | ||
} | ||
|
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.
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.
This is a series of minor changes to initialise a fixed-length slice instead of a dynamic length slice to store the segmenter values so as to prevent repeated allocation of memory to copy-paste the slice values when
append
-ing.