Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

raju-opti
Copy link
Contributor

@raju-opti raju-opti commented Aug 29, 2025

Summary

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 PR makes this more efficient.

Test plan

  • all existing tests should pass

Issues

Copy link

@prisma-cloud-devsecops prisma-cloud-devsecops bot left a 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 ⬇️

@coveralls
Copy link

coveralls commented Aug 29, 2025

Coverage Status

coverage: 79.143% (+0.005%) from 79.138%
when pulling 07bb567 on raju/createInstance-perf
into 017e10b on master.

Copy link

@Copilot Copilot AI left a 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.

Copy link
Contributor

@junaed-optimizely junaed-optimizely left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@raju-opti raju-opti merged commit fb5e012 into master Sep 1, 2025
19 checks passed
@raju-opti raju-opti deleted the raju/createInstance-perf branch September 1, 2025 09:41
raju-opti added a commit that referenced this pull request Sep 2, 2025
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants