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

chore: reduce simple Map/Set ops #9761

Merged
merged 1 commit into from
Mar 12, 2025
Merged

chore: reduce simple Map/Set ops #9761

merged 1 commit into from
Mar 12, 2025

Conversation

runspired
Copy link
Contributor

No description provided.

@runspired runspired added 🎯 canary PR is targeting canary (default) 🏷️ chore This PR primarily refactors code or updates dependencies ci-perf Activates Performance Checks in CI labels Mar 12, 2025
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this change is just variable name cleanup. This method is a mega hot-path. I previously benchmarked this multi-tier strategy working better overall than a single-tier strategy + there may later be gains made possible by it in terms of making remote operations flush lazily.

However, we should re-test this assumption at this point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for small arrays and sets, checking value directly is 30% faster (or more)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the change here is that we use the callback function itself as the token, stashing a bit of info directly on it. This eliminates the double map lookup and simplifies iteration.

We also convert CacheOperations (a simple set) into a direct value comparison.

Copy link

Performance Report for dbe4c43

Scenario - basic-record-materialization: ✅ Performance improved

✅ duration
phase estimated improvement -28ms [-38ms to -19ms] OR -1.88% [-2.53% to -1.27%]
☑️ Phase [navigationStart] => [start-data-generation]
phase no difference [0ms to 1ms]
☑️ Phase [start-data-generation] => [start-push-payload]
phase no difference [-2ms to 1ms]
✅ Phase [start-push-payload] => [start-peek-records]
phase estimated improvement -10ms [-16ms to -4ms] OR -1.22% [-1.98% to -0.51%]
☑️ Phase [start-peek-records] => [start-record-materialization]
phase no difference [0ms to 0ms]
✅ Phase [start-record-materialization] => [end-record-materialization]
phase estimated improvement -16ms [-21ms to -11ms] OR -4.48% [-5.77% to -3.01%]
☑️ Phase [end-record-materialization] => [Test End]
phase no difference [-1ms to 0ms]

Scenario - complex-record-materialization: ✅ Performance improved

✅ duration
phase estimated improvement -14ms [-19ms to -9ms] OR -1.36% [-1.84% to -0.91%]
☑️ Phase [navigationStart] => [start-data-generation]
phase no difference [0ms to 1ms]
☑️ Phase [start-data-generation] => [start-push-payload]
phase no difference [-1ms to 2ms]
✅ Phase [start-push-payload] => [start-peek-records]
phase estimated improvement -11ms [-15ms to -7ms] OR -1.97% [-2.7% to -1.23%]
☑️ Phase [start-peek-records] => [start-record-materialization]
phase no difference [0ms to 0ms]
✅ Phase [start-record-materialization] => [end-record-materialization]
phase estimated improvement -3ms [-4ms to -3ms] OR -3.96% [-4.79% to -3.16%]
☑️ Phase [end-record-materialization] => [Test End]
phase no difference [0ms to 0ms]

Scenario - complex-record-materialization-with-relationship-materialization: ✅ Performance improved

✅ duration
phase estimated improvement -15ms [-22ms to -9ms] OR -1.42% [-2.02% to -0.83%]
☑️ Phase [navigationStart] => [start-data-generation]
phase no difference [0ms to 1ms]
☑️ Phase [start-data-generation] => [start-push-payload]
phase no difference [-3ms to 1ms]
✅ Phase [start-push-payload] => [start-peek-records]
phase estimated improvement -12ms [-17ms to -8ms] OR -2.23% [-3.06% to -1.39%]
☑️ Phase [start-peek-records] => [start-record-materialization]
phase no difference [0ms to 0ms]
✅ Phase [start-record-materialization] => [start-field-access]
phase estimated improvement -3ms [-4ms to -2ms] OR -3.3% [-4.4% to -2.32%]
☑️ Phase [start-field-access] => [start-relationship-access]
phase no difference [-1ms to 0ms]
☑️ Phase [start-relationship-access] => [end-relationship-access]
phase no difference [0ms to 0ms]
☑️ Phase [end-relationship-access] => [Test End]
phase no difference [0ms to 0ms]

Scenario - relationship-materialization-simple: ☑️ Performance is stable

☑️ duration
phase no difference [-6ms to 1ms]
☑️ Phase [navigationStart] => [start-find-all]
phase no difference [-1ms to 1ms]
✅ Phase [start-find-all] => [start-materialization]
phase estimated improvement -3ms [-5ms to 0ms] OR -1.29% [-2.41% to -0.19%]
☑️ Phase [start-materialization] => [end-materialization]
phase no difference [-3ms to 1ms]
☑️ Phase [end-materialization] => [Test End]
phase no difference [0ms to 1ms]

Scenario - relationship-materialization-complex: ✅ Performance improved

✅ duration
phase estimated improvement -12ms [-22ms to -3ms] OR -0.47% [-0.84% to -0.1%]
☑️ Phase [navigationStart] => [start-data-generation]
phase no difference [-1ms to 0ms]
☑️ Phase [start-data-generation] => [start-push-payload]
phase no difference [-1ms to 1ms]
☑️ Phase [start-push-payload] => [start-peek-records]
phase no difference [-2ms to 5ms]
☑️ Phase [start-peek-records] => [start-record-materialization]
phase no difference [0ms to 0ms]
✅ Phase [start-record-materialization] => [start-relationship-materialization]
phase estimated improvement -6ms [-8ms to -5ms] OR -4.85% [-5.74% to -4.04%]
☑️ Phase [start-relationship-materialization] => [start-push-payload2]
phase no difference [-10ms to 3ms]
✅ Phase [start-push-payload2] => [start-relationship-materialization2]
phase estimated improvement -4ms [-6ms to -1ms] OR -1.53% [-2.45% to -0.55%]
☑️ Phase [start-relationship-materialization2] => [end-relationship-materialization2]
phase no difference [-2ms to 0ms]
☑️ Phase [end-relationship-materialization2] => [Test End]
phase no difference [-1ms to 1ms]

Scenario - unload: ☑️ Performance is stable

☑️ duration
phase no difference [-5ms to 1ms]
☑️ Phase [navigationStart] => [start-push-payload]
phase no difference [-1ms to 1ms]
☑️ Phase [start-push-payload] => [start-unload-records]
phase no difference [-4ms to 1ms]
☑️ Phase [start-unload-records] => [end-unload-records]
phase no difference [-1ms to 4ms]
☑️ Phase [end-unload-records] => [Test End]
phase no difference [-1ms to 0ms]

Scenario - unload-all: ✅ Performance improved

✅ duration
phase estimated improvement -23ms [-26ms to -18ms] OR -1.87% [-2.18% to -1.54%]
☑️ Phase [navigationStart] => [start-push-payload]
phase no difference [-1ms to 1ms]
☑️ Phase [start-push-payload] => [start-materialization]
phase no difference [-2ms to 2ms]
✅ Phase [start-materialization] => [start-unload-all]
phase estimated improvement -8ms [-9ms to -7ms] OR -4.16% [-4.86% to -3.53%]
✅ Phase [start-unload-all] => [end-unload-all]
phase estimated improvement -15ms [-16ms to -13ms] OR -5.1% [-5.64% to -4.52%]
☑️ Phase [end-unload-all] => [Test End]
phase no difference [0ms to 0ms]

Scenario - destroy: ☑️ Performance is stable

☑️ duration
phase no difference [-1ms to 7ms]
☑️ Phase [navigationStart] => [start-push-payload]
phase no difference [-1ms to 0ms]
☑️ Phase [start-push-payload] => [start-destroy-records]
phase no difference [-1ms to 3ms]
⚠️ Phase [start-destroy-records] => [end-destroy-records]
phase estimated regression +1ms [0ms to 3ms] OR +2.52% [0.26% to 5.97%]
☑️ Phase [end-destroy-records] => [Test End]
phase no difference [0ms to 0ms]

Scenario - add-children: ☑️ Performance is stable

☑️ duration
phase no difference [-4ms to 1ms]
☑️ Phase [navigationStart] => [start-push-initial-payload]
phase no difference [0ms to 1ms]
☑️ Phase [start-push-initial-payload] => [start-push-update-payload]
phase no difference [-1ms to 1ms]
☑️ Phase [start-push-update-payload] => [end-push-update-payload]
phase no difference [-2ms to 0ms]
☑️ Phase [end-push-update-payload] => [Test End]
phase no difference [0ms to 0ms]

Scenario - unused-relationships: ✅ Performance improved

✅ duration
phase estimated improvement -6ms [-11ms to -1ms] OR -1.5% [-2.95% to -0.17%]
✅ Phase [navigationStart] => [start-push-payload]
phase estimated improvement -3ms [-5ms to -1ms] OR -1.77% [-3.38% to -0.45%]
☑️ Phase [start-push-payload] => [end-push-payload]
phase no difference [-7ms to 0ms]
☑️ Phase [end-push-payload] => [Test End]
phase no difference [-1ms to 0ms]

Scenario - update-with-same-state: ✅ Performance improved

✅ duration
phase estimated improvement -15ms [-22ms to -8ms] OR -1.37% [-1.98% to -0.75%]
☑️ Phase [navigationStart] => [start-data-generation]
phase no difference [-1ms to 0ms]
☑️ Phase [start-data-generation] => [start-push-initial-payload]
phase no difference [0ms to 1ms]
☑️ Phase [start-push-initial-payload] => [start-peek-records]
phase no difference [-3ms to 0ms]
☑️ Phase [start-peek-records] => [start-record-materialization]
phase no difference [0ms to 0ms]
✅ Phase [start-record-materialization] => [start-relationship-materialization]
phase estimated improvement -17ms [-19ms to -10ms] OR -24.03% [-27.67% to -14.11%]
⚠️ Phase [start-relationship-materialization] => [start-local-removal]
phase estimated regression +7ms [2ms to 12ms] OR +2.16% [0.78% to 3.64%]
⚠️ Phase [start-local-removal] => [start-push-minus-one-payload]
phase estimated regression +2ms [1ms to 3ms] OR +0.7% [0.22% to 1.12%]
☑️ Phase [start-push-minus-one-payload] => [start-local-addition]
phase no difference [0ms to 0ms]
✅ Phase [start-local-addition] => [start-push-plus-one-payload]
phase estimated improvement -3ms [-4ms to -2ms] OR -7.36% [-9.27% to -5.43%]
☑️ Phase [start-push-plus-one-payload] => [end-push-plus-one-payload]
phase no difference [-2ms to 1ms]
✅ Phase [end-push-plus-one-payload] => [Test End]
phase estimated improvement -4ms [-5ms to -3ms] OR -13.05% [-15.51% to -8.79%]

Scenario - update-with-same-state-m2m: ☑️ Performance is stable

☑️ duration
phase no difference [0ms to 7ms]
☑️ Phase [navigationStart] => [start-data-generation]
phase no difference [-1ms to 0ms]
⚠️ Phase [start-data-generation] => [start-push-initial-payload]
phase estimated regression +1ms [0ms to 1ms] OR +0.31% [0.01% to 0.63%]
☑️ Phase [start-push-initial-payload] => [start-peek-records]
phase no difference [-1ms to 2ms]
☑️ Phase [start-peek-records] => [start-record-materialization]
phase no difference [0ms to 0ms]
☑️ Phase [start-record-materialization] => [start-relationship-materialization]
phase no difference [0ms to 0ms]
☑️ Phase [start-relationship-materialization] => [start-local-removal]
phase no difference [-1ms to 0ms]
⚠️ Phase [start-local-removal] => [start-push-minus-one-payload]
phase estimated regression +2ms [1ms to 3ms] OR +1.54% [0.79% to 2.3%]
☑️ Phase [start-push-minus-one-payload] => [start-local-addition]
phase no difference [-1ms to 1ms]
☑️ Phase [start-local-addition] => [start-push-plus-one-payload]
phase no difference [-1ms to 1ms]
☑️ Phase [start-push-plus-one-payload] => [end-push-plus-one-payload]
phase no difference [-1ms to 1ms]
☑️ Phase [end-push-plus-one-payload] => [Test End]
phase no difference [0ms to 0ms]

@runspired runspired merged commit f9b9fe2 into main Mar 12, 2025
28 of 30 checks passed
@runspired runspired deleted the iterable-metrics branch March 12, 2025 07:54
MehulKChaudhari pushed a commit to MehulKChaudhari/ember-data that referenced this pull request Mar 16, 2025
gitKrystan pushed a commit that referenced this pull request Mar 21, 2025
gitKrystan added a commit that referenced this pull request Mar 21, 2025
* feat: schema type utils (#9757)

* minor type improvements

* chore: fixup types

* add api docs

* nice things

* account for schema presence

* cleanup test

* chore: update contributing docs (#9758)

* chore: Improve contributing experience (#9759)

* chore: improve developing experience on local

* more

* temporarily deactivate some scenarios

* deactivate more lints

* deactivate more prod tests

* another

* chore: reduce simple Map/Set ops (#9761)

* perf: faster iteration of relationship payloads (#9762)

faster iteration of payloads

* chore: restructure SchemaRecord test file layout to make it easier to navigate (#9763)

* chore: simplify test file layout

* chore: move polaris test files to new structure

* docs: LinksMode and Polymorphic Relationship Guide, stubs out guide for LegacyMode vs PolarisMode (#9764)

* docs: stub out guides for SchemaRecord, LinksMode, PolarisMode etc.

* add linksmode guide

* fix annotation

* Update guides/relationships/features/links-mode.md

Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>

* Update guides/relationships/features/links-mode.md

Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>

* Update guides/relationships/features/links-mode.md

Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>

* Update guides/relationships/features/links-mode.md

Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>

* Update guides/relationships/features/links-mode.md

Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>

* Update guides/relationships/features/links-mode.md

Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>

* Update guides/relationships/features/links-mode.md

Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>

* Update guides/relationships/features/links-mode.md

Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>

* Update guides/relationships/features/links-mode.md

Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>

* Update guides/relationships/features/links-mode.md

Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>

* Update guides/relationships/features/links-mode.md

Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>

* Update guides/relationships/features/links-mode.md

Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>

* cleanup op

* rewrite future thoughts

* stub out more of the guide

* add docs on polymorphism

* stub out guide

* add note on interop

* add reactivity overview

---------

Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>

* feat: improve debuggability of SchemaRecord, RecordArray and Identifier (#9766)

* feat: improve debuggability of SchemaRecord, RecordArray and Identifier

* fix configurability

* fix keys

* feat: persist runtime config (#9767)

* feat: persist runtime config

* ensure fastboot works

* Don't set isDirty to true in diff callbacks (#9765)

* More overnotification fixes

* Fix DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE case

* feat: ensure objects behave amazeballs (#9768)

* feat: ensure objects behave amazeballs

* add tests for record iteration

* add more tests

* fix(deps): update dependency @babel/runtime to v7.26.10 [security] (#9760)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore: remove restriction on new field kinds being used with legacy mode

* improve types

* Revert "improve types"

This reverts commit 84daef7.

* Revert "chore: remove restriction on new field kinds being used with legacy mode"

This reverts commit 3fd81bf.

* Widen Peer Range for ember-inflector (#9770)

* chore: remove restriction on new field kinds being used with legacy mode (#9769)

* chore: remove restriction on new field kinds being used with legacy mode

* chore: cleanup types

* fix

* fix test

* fix docs

* chore: cleanup @ember/service deprecation from shipped library code (#9773)

* Add: tests verify behavior mutating a record  (#9754)

* add: tests verify behavior mutating a related record from a checked-out record

* fix: lint

* fix: test

* fix: lint

* fix: better reordering detection when remoteClearsLocal is true (#9771)

* Fix DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE reordering detection

* add failing test

* notification tests

* implement fix

* cleanup console logs

* fix spurrious type issue

---------

Co-authored-by: Chris Thoburn <runspired@users.noreply.github.com>

* Fix some lint

---------

Co-authored-by: Chris Thoburn <runspired@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jon Johnson <jon.johnson@ucsf.edu>
Co-authored-by: Mehul Kiran Chaudhari <55375534+MehulKChaudhari@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-perf Activates Performance Checks in CI 🎯 canary PR is targeting canary (default) 🏷️ chore This PR primarily refactors code or updates dependencies
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant