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: refactor IdentifierCache to improve opaqueness #8725

Closed
wants to merge 1 commit into from

Conversation

runspired
Copy link
Contributor

Currently while resources are treated opaquely they effectively still need at least type to be present. Most things would probably work if it wasn't in production, but this constraint shouldn't be there. This refactor ensures we do not make this assumption, but allows us to continue to expose type and id for record identifiers by introducing a new config point to extract type/id information for a resource.

@runspired runspired added 🎯 canary PR is targeting canary (default) 🏷️ chore This PR primarily refactors code or updates dependencies ci-assetsize Activates Asset Size Checks in CI ci-perf Activates Performance Checks in CI labels Jul 23, 2023
@github-actions
Copy link

github-actions bot commented Jul 23, 2023

Asset Size Report for d9fc15e

Modern Builds

🛑 The size of the library EmberData has increased by +174.0 B (+128.0 B compressed) which exceeds the failure threshold of 75 bytes.

Warnings

⚠️ The uncompressed size of the package @ember-data/store has increased by +173.0 B.
⚠️ The uncompressed size of the package @ember-data/debug has increased by +1.0 B.

Changeset


EmberData 184.95 KB +174.0 B (39.55 KB +128.0 B compressed)
    @ember-data/store 35.21 KB +173.0 B (7.53 KB +127.26 B compressed)
        @ember-data/store/store-service-4284ed59 0.0 B -31.91 KB (0.0 B -23.48 KB compressed)
        @ember-data/store/store-service-67bc8346 32.08 KB +32.08 KB (6.86 KB +23.6 KB compressed)
    @ember-data/debug 2.75 KB +1.0 B (602.2 B +0.74 B compressed)
        @ember-data/debug/index 2.75 KB +1.0 B (602.2 B +0.74 B compressed)

Full Asset Analysis (Modern)

Asset Size Report
=================


Library: EmberData
┌────────────┬─────────────┐
│  (index)   │   Values    │
├────────────┼─────────────┤
│   bytes    │ '184.95 KB' │
│ compressed │ '39.55 KB'  │
│  packages  │     12      │
│  modules   │     62      │
└────────────┴─────────────┘

Package: @ember-data/model
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '42.27 KB' │
│  compressed  │ '9.04 KB'  │
│ % Of Library │   '22.9'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/model/model-d401e249                  | 36.68 KB  | 7.84 KB    | 86.8          | 19.8
	@ember-data/model/hooks-c118f005                  | 1.81 KB   | 396.05 B   | 4.3           | 1.0
	@ember-data/model/has-many-aa0b9b51               | 1.53 KB   | 334.25 B   | 3.6           | 0.8
	@ember-data/model/-private                        | 928.00 B  | 198.45 B   | 2.1           | 0.5
	@ember-data/model/index                           | 890.00 B  | 190.32 B   | 2.1           | 0.5
	@ember-data/model/hooks                           | 494.00 B  | 105.64 B   | 1.1           | 0.3

Package: @ember-data/store
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '35.21 KB' │
│  compressed  │ '7.53 KB'  │
│ % Of Library │   '19.0'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/store/store-service-67bc8346          | 32.08 KB  | 6.86 KB    | 91.1          | 17.3
	@ember-data/store/-private                        | 2.26 KB   | 495.92 B   | 6.4           | 1.2
	@ember-data/store/index                           | 885.00 B  | 189.25 B   | 2.5           | 0.5

Package: @ember-data/serializer
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '21.30 KB' │
│  compressed  │ '4.56 KB'  │
│ % Of Library │   '11.5'   │
└──────────────┴────────────┘
	Module                                                     | Bytes     | Compressed | % of Package  | % Of Library
	--------------------------------------------------------------------------------------------------------------
	@ember-data/serializer/json                                | 7.36 KB   | 1.57 KB    | 34.6          | 4.0
	@ember-data/serializer/embedded-records-mixin-d75385ff     | 4.47 KB   | 978.37 B   | 21.0          | 2.4
	@ember-data/serializer/json-api                            | 3.77 KB   | 825.68 B   | 17.7          | 2.0
	@ember-data/serializer/rest                                | 2.86 KB   | 625.51 B   | 13.4          | 1.5
	@ember-data/serializer/-private                            | 1.52 KB   | 333.61 B   | 7.2           | 0.8
	@ember-data/serializer/index                               | 879.00 B  | 187.97 B   | 4.0           | 0.5
	@ember-data/serializer/utils-075c5b79                      | 240.00 B  | 51.32 B    | 1.1           | 0.1
	@ember-data/serializer/transform                           | 234.00 B  | 50.04 B    | 1.1           | 0.1

Package: @ember-data/adapter
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '17.51 KB' │
│  compressed  │ '3.74 KB'  │
│ % Of Library │   '9.5'    │
└──────────────┴────────────┘
	Module                                               | Bytes     | Compressed | % of Package  | % Of Library
	--------------------------------------------------------------------------------------------------------
	@ember-data/adapter/rest                             | 7.67 KB   | 1.64 KB    | 43.8          | 4.1
	@ember-data/adapter/serialize-into-hash-b9092b25     | 2.40 KB   | 526.50 B   | 13.7          | 1.3
	@ember-data/adapter/build-url-mixin-18db8c8b         | 1.91 KB   | 419.15 B   | 10.9          | 1.0
	@ember-data/adapter/error                            | 1.80 KB   | 393.27 B   | 10.3          | 1.0
	@ember-data/adapter/index-f54121ea                   | 1.48 KB   | 323.77 B   | 8.4           | 0.8
	@ember-data/adapter/json-api                         | 1.07 KB   | 233.95 B   | 6.1           | 0.6
	@ember-data/adapter/-private                         | 835.00 B  | 178.56 B   | 4.7           | 0.4
	@ember-data/adapter/index                            | 375.00 B  | 80.19 B    | 2.1           | 0.2

Package: @ember-data/graph
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '16.71 KB' │
│  compressed  │ '3.57 KB'  │
│ % Of Library │   '9.0'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/graph/-private                        | 16.71 KB  | 3.57 KB    | 100.0         | 9.0

Package: @ember-data/legacy-compat
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '15.21 KB' │
│  compressed  │ '3.25 KB'  │
│ % Of Library │   '8.2'    │
└──────────────┴────────────┘
	Module                                               | Bytes     | Compressed | % of Package  | % Of Library
	--------------------------------------------------------------------------------------------------------
	@ember-data/legacy-compat/fetch-manager-5d3205f7     | 8.20 KB   | 1.75 KB    | 53.9          | 4.4
	@ember-data/legacy-compat/index                      | 6.50 KB   | 1.39 KB    | 42.8          | 3.5
	@ember-data/legacy-compat/-private                   | 516.00 B  | 110.34 B   | 3.3           | 0.3

Package: @ember-data/json-api
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '11.93 KB' │
│  compressed  │ '2.55 KB'  │
│ % Of Library │   '6.5'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/json-api/index                        | 10.52 KB  | 2.25 KB    | 88.2          | 5.7
	@ember-data/json-api/request                      | 1.41 KB   | 308.58 B   | 11.8          | 0.8

Package: ember-data
┌──────────────┬───────────┐
│   (index)    │  Values   │
├──────────────┼───────────┤
│    bytes     │ '8.36 KB' │
│  compressed  │ '1.79 KB' │
│ % Of Library │   '4.5'   │
└──────────────┴───────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	ember-data/-private                               | 2.12 KB   | 463.63 B   | 25.3          | 1.1
	ember-data/index                                  | 1.74 KB   | 381.08 B   | 20.8          | 0.9
	ember-data/adapters/errors                        | 1009.00 B | 215.77 B   | 11.8          | 0.5
	ember-data/relationships                          | 318.00 B  | 68.00 B    | 3.7           | 0.2
	ember-data/serializers/embedded-records-mixin     | 274.00 B  | 58.59 B    | 3.2           | 0.1
	ember-data/setup-container                        | 272.00 B  | 58.16 B    | 3.2           | 0.1
	ember-data/serializers/json-api                   | 251.00 B  | 53.67 B    | 2.9           | 0.1
	ember-data/adapters/json-api                      | 245.00 B  | 52.39 B    | 2.9           | 0.1
	ember-data/serializers/json                       | 243.00 B  | 51.96 B    | 2.8           | 0.1
	ember-data/serializers/rest                       | 243.00 B  | 51.96 B    | 2.8           | 0.1
	ember-data/transform                              | 241.00 B  | 51.53 B    | 2.8           | 0.1
	ember-data/adapters/rest                          | 237.00 B  | 50.68 B    | 2.8           | 0.1
	ember-data/serializer                             | 232.00 B  | 49.61 B    | 2.7           | 0.1
	ember-data/adapter                                | 226.00 B  | 48.33 B    | 2.6           | 0.1
	ember-data/model                                  | 222.00 B  | 47.47 B    | 2.6           | 0.1
	ember-data/store                                  | 222.00 B  | 47.47 B    | 2.6           | 0.1
	ember-data/attr                                   | 218.00 B  | 46.61 B    | 2.5           | 0.1
	ember-data/version                                | 161.00 B  | 34.43 B    | 1.9           | 0.1

Package: ember-inflector
┌──────────────┬───────────┐
│   (index)    │  Values   │
├──────────────┼───────────┤
│    bytes     │ '6.69 KB' │
│  compressed  │ '1.43 KB' │
│ % Of Library │   '3.6'   │
└──────────────┴───────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	ember-inflector/lib/system/inflector              | 2.99 KB   | 654.17 B   | 44.7          | 1.6
	ember-inflector/lib/system/inflections            | 1.59 KB   | 347.93 B   | 23.7          | 0.9
	ember-inflector/lib/system                        | 471.00 B  | 100.72 B   | 6.9           | 0.2
	ember-inflector/index                             | 379.00 B  | 81.04 B    | 5.5           | 0.2
	ember-inflector/lib/helpers/pluralize             | 369.00 B  | 78.91 B    | 5.4           | 0.2
	ember-inflector/lib/utils/make-helper             | 332.00 B  | 70.99 B    | 4.8           | 0.2
	ember-inflector/lib/system/string                 | 318.00 B  | 68.00 B    | 4.6           | 0.2
	ember-inflector/lib/helpers/singularize           | 296.00 B  | 63.30 B    | 4.3           | 0.2

Package: @ember-data/request
┌──────────────┬───────────┐
│   (index)    │  Values   │
├──────────────┼───────────┤
│    bytes     │ '5.76 KB' │
│  compressed  │ '1.23 KB' │
│ % Of Library │   '3.1'   │
└──────────────┴───────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/request/index                         | 5.22 KB   | 1.12 KB    | 90.5          | 2.8
	@ember-data/request/fetch                         | 559.00 B  | 119.54 B   | 9.5           | 0.3

Package: @ember-data/debug
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '2.75 KB'  │
│  compressed  │ '602.20 B' │
│ % Of Library │   '1.5'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/debug/index                           | 2.75 KB   | 602.20 B   | 100.0         | 1.5

Package: @ember-data/tracking
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '1.24 KB'  │
│  compressed  │ '272.44 B' │
│ % Of Library │   '0.7'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/tracking/-private                     | 846.00 B  | 180.91 B   | 66.4          | 0.4
	@ember-data/tracking/index                        | 428.00 B  | 91.52 B    | 33.6          | 0.2

@runspired runspired force-pushed the chore/refactor-default-identity2 branch from 8af9b89 to 48748b9 Compare July 23, 2023 21:39
@github-actions
Copy link

github-actions bot commented Jul 24, 2023

Performance Report for d9fc15e

Scenario - basic-record-materialization: ⚠️ Performance regressed

⚠️ duration
phase estimated regression +172ms [126ms to 213ms] OR +5.5% [4.01% to 6.81%]
☑️ Phase [navigationStart] => [start-data-generation]
phase no difference [-1ms to 2ms]
☑️ Phase [start-data-generation] => [start-push-payload]
phase no difference [-2ms to 2ms]
⚠️ Phase [start-push-payload] => [start-peek-records]
phase estimated regression +189ms [173ms to 204ms] OR +10.61% [9.73% to 11.51%]
☑️ Phase [start-peek-records] => [start-record-materialization]
phase no difference [0ms to 0ms]
☑️ Phase [start-record-materialization] => [end-record-materialization]
phase no difference [-27ms to 12ms]
☑️ Phase [end-record-materialization] => [Test End]
phase no difference [-13ms to 2ms]

Scenario - relationship-materialization-simple: ⚠️ Performance regressed

⚠️ duration
phase estimated regression +38ms [30ms to 44ms] OR +4.03% [3.19% to 4.66%]
☑️ Phase [navigationStart] => [start-find-all]
phase no difference [-2ms to 1ms]
⚠️ Phase [start-find-all] => [start-materialization]
phase estimated regression +37ms [32ms to 41ms] OR +9.78% [8.6% to 11.02%]
☑️ Phase [start-materialization] => [end-materialization]
phase no difference [-4ms to 5ms]
☑️ Phase [end-materialization] => [Test End]
phase no difference [-1ms to 0ms]

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

☑️ duration
phase no difference [-1ms to 69ms]
☑️ Phase [navigationStart] => [start-data-generation]
phase no difference [-2ms to 1ms]
☑️ Phase [start-data-generation] => [start-push-payload]
phase no difference [-1ms to 1ms]
⚠️ Phase [start-push-payload] => [start-peek-records]
phase estimated regression +51ms [42ms to 59ms] OR +5.73% [4.75% to 6.69%]
☑️ Phase [start-peek-records] => [start-record-materialization]
phase no difference [0ms to 0ms]
☑️ Phase [start-record-materialization] => [start-relationship-materialization]
phase no difference [-5ms to 2ms]
☑️ Phase [start-relationship-materialization] => [end-relationship-materialization]
phase no difference [-34ms to 18ms]
✅ Phase [end-relationship-materialization] => [Test End]
phase estimated improvement -8ms [-13ms to -3ms] OR -2.9% [-4.54% to -1.19%]

Scenario - unload: ⚠️ Performance regressed

⚠️ duration
phase estimated regression +38ms [32ms to 45ms] OR +3.73% [3.14% to 4.37%]
☑️ Phase [navigationStart] => [start-push-payload]
phase no difference [-1ms to 2ms]
⚠️ Phase [start-push-payload] => [start-unload-records]
phase estimated regression +39ms [35ms to 44ms] OR +6.9% [6.08% to 7.75%]
☑️ Phase [start-unload-records] => [end-unload-records]
phase no difference [-4ms to 1ms]
☑️ Phase [end-unload-records] => [Test End]
phase no difference [0ms to 0ms]

Scenario - unload-all: ⚠️ Performance regressed

⚠️ duration
phase estimated regression +99ms [84ms to 113ms] OR +4.33% [3.7% to 4.93%]
☑️ Phase [navigationStart] => [start-push-payload]
phase no difference [-2ms to 3ms]
⚠️ Phase [start-push-payload] => [start-materialization]
phase estimated regression +101ms [92ms to 110ms] OR +9.03% [8.2% to 9.83%]
☑️ Phase [start-materialization] => [start-unload-all]
phase no difference [-3ms to 6ms]
☑️ Phase [start-unload-all] => [end-unload-all]
phase no difference [-7ms to 2ms]
☑️ Phase [end-unload-all] => [Test End]
phase no difference [-1ms to 0ms]

Scenario - destroy: ⚠️ Performance regressed

⚠️ duration
phase estimated regression +39ms [30ms to 49ms] OR +3.84% [2.9% to 4.79%]
☑️ Phase [navigationStart] => [start-push-payload]
phase no difference [-2ms to 2ms]
⚠️ Phase [start-push-payload] => [start-destroy-records]
phase estimated regression +38ms [32ms to 45ms] OR +6.69% [5.51% to 7.88%]
☑️ Phase [start-destroy-records] => [end-destroy-records]
phase no difference [-5ms to 3ms]
☑️ Phase [end-destroy-records] => [Test End]
phase no difference [-1ms to 1ms]

Scenario - add-children: ⚠️ Performance regressed

⚠️ duration
phase estimated regression +45ms [40ms to 50ms] OR +6.88% [6.13% to 7.62%]
✅ Phase [navigationStart] => [start-push-initial-payload]
phase estimated improvement -2ms [-4ms to 0ms] OR -0.84% [-1.66% to -0.07%]
⚠️ Phase [start-push-initial-payload] => [start-push-update-payload]
phase estimated regression +23ms [20ms to 25ms] OR +10.84% [9.73% to 12.04%]
⚠️ Phase [start-push-update-payload] => [end-push-update-payload]
phase estimated regression +25ms [23ms to 27ms] OR +14.89% [13.79% to 16.15%]
☑️ Phase [end-push-update-payload] => [Test End]
phase no difference [0ms to 0ms]

Scenario - unused-relationships: ⚠️ Performance regressed

⚠️ duration
phase estimated regression +38ms [32ms to 44ms] OR +4.57% [3.85% to 5.24%]
☑️ Phase [navigationStart] => [start-push-payload]
phase no difference [-2ms to 1ms]
⚠️ Phase [start-push-payload] => [end-push-payload]
phase estimated regression +38ms [33ms to 44ms] OR +6.71% [5.8% to 7.65%]
☑️ Phase [end-push-payload] => [Test End]
phase no difference [-1ms to 0ms]

@runspired runspired force-pushed the chore/refactor-default-identity2 branch from acaed4f to 2bf178d Compare July 26, 2023 02:05
@runspired runspired force-pushed the chore/refactor-default-identity2 branch from 2bf178d to d9fc15e Compare July 26, 2023 03:30
@runspired runspired closed this Jul 27, 2023
@runspired runspired deleted the chore/refactor-default-identity2 branch July 27, 2023 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-assetsize Activates Asset Size Checks in CI ci-perf Activates Performance Checks in CI 🎯 canary PR is targeting canary (default) 🏷️ chore This PR primarily refactors code or updates dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant