Skip to content
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

perf(store): improve compliant prop getter #2106

Merged
merged 1 commit into from
Mar 13, 2024
Merged

Conversation

arturovt
Copy link
Member

@arturovt arturovt commented Mar 12, 2024

This commit enhances the compliantPropGetter function's implementation. The prop getter is heavily utilized in NGXS. I noticed that the function unnecessarily copies paths. It now returns a function that accepts an object as a parameter and attempts to select a property deeply. We've replaced the use of reduce with a single for-loop, making it simpler. Though it doesn't significantly impact size, there's only a minor difference in production bundle size.

Regarding performance, I checked the perf.link service and got the following results:

  • Old compliant prop getter: 120,410 ops/s
  • New compliant prop getter: 220,480 ops/s

I generated a deeply nested object and set my CPU slowdown to 6x. The new implementation is only 30% faster, but it's reasonable to have a slightly faster implementation if possible. At least it's not causing any negative impact.

Copy link

nx-cloud bot commented Mar 12, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit d129f9b. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 4 targets

Sent with 💌 from NxCloud.

Copy link

bundlemon bot commented Mar 12, 2024

BundleMon (Integration Projects)

Files updated (1)
Status Path Size Limits
Main bundles(Gzip)
hello-world-ng17/dist-integration/main.(hash)
.js
68.29KB (+17B +0.02%) +1%
Unchanged files (1)
Status Path Size Limits
Main bundles(Gzip)
hello-world-ng16/dist-integration/main.(hash)
.js
66.76KB +1%

Total files change +25B +0.02%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

This commit enhances the `compliantPropGetter` function's implementation. The prop getter
is heavily utilized in NGXS. I noticed that the function unnecessarily copies `paths`. It
now returns a function that accepts an object as a parameter and attempts to select a property
deeply. We've replaced the use of `reduce` with a single for-loop, making it simpler. Though
it doesn't significantly impact size, there's only a minor difference in production bundle size.

Regarding performance, I checked the `perf.link` service and got the following results:
- Old compliant prop getter: 120,410 ops/s
- New compliant prop getter: 220,480 ops/s

I generated a deeply nested object and set my CPU slowdown to 6x. The new implementation is only
30% faster, but it's reasonable to have a slightly faster implementation if possible. At least it's
not causing any negative impact.
Copy link

codeclimate bot commented Mar 12, 2024

Code Climate has analyzed commit d129f9b and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 95.4% (0.0% change).

View more on Code Climate.

@arturovt arturovt marked this pull request as ready for review March 13, 2024 00:33
@arturovt arturovt merged commit 42a8ed3 into master Mar 13, 2024
12 checks passed
@arturovt arturovt deleted the perf/prop-getter branch March 13, 2024 00:33
@markwhitfeld markwhitfeld added this to the v.18.0.0 milestone Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants