-
Notifications
You must be signed in to change notification settings - Fork 83
[FSSDK-11787] fix config parsing performance #1080
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
Conversation
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.
Prisma Cloud has found errors in this PR ⬇️
b56cb36
to
b168a1e
Compare
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.
Pull Request Overview
This PR optimizes the performance of config parsing by improving how the variationIdMap
is populated. Instead of creating new objects through spread operations for each experiment, it modifies the keyBy
utility function to accept an optional base object parameter and directly mutates it.
- Modified
keyBy
function to accept an optional base object parameter and mutate it directly - Removed the now-unused
keyByUtil
helper function - Updated all
variationIdMap
population calls to use the more efficient in-place approach
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
lib/utils/fns/index.ts | Enhanced keyBy function with optional base parameter and removed keyByUtil |
lib/utils/fns/index.spec.ts | Updated test to use keyBy instead of removed keyByUtil |
lib/project_config/project_config.ts | Replaced spread operations with direct mutation calls for performance |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
LGTM. Thanks!
Currently, variationIdMap is being populated as follows: ``` projectConfig.variationIdMap = { ...projectConfig.variationIdMap, ...keyBy(experiment.variations, 'id') }; ``` This creates a new objects for each experiment unnecessarily. This causes large slowdown in project config parsing for datafiles containing a large number of experiments containing a large number of variations. This commit makes this more efficient.
Summary
Currently, variationIdMap is being populated as follows:
This creates a new objects for each experiment unnecessarily. This causes large slowdown in project config parsing for datafiles containing a large number of experiments containing a large number of variations.
This PR makes this more efficient.
Test plan
Issues