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: Continuing InternalModel Burndown #8055

Merged
merged 16 commits into from
Jul 25, 2022
Merged

Conversation

runspired
Copy link
Contributor

@runspired runspired commented Jul 24, 2022

We're getting close to fully eliminating InternalModel. To finish the job, some of the bigger ticket items to do are:

  • references, recordData and snapshots to be cached by the InstanceCache instead of InternalModel
  • peekAll to utilize a non-internalModel based cache
  • to move the relationship state classes onto the model (PromiseManyArray|ManyArray|PromiseBelongsTo and possibly the associated promise cache)
  • a mechanism for storing/determining the state of things for a given identifier (isEmpty/isLoaded/isLoading/hasRecord/isDematerializing,hasScheduledDestroy,isHiddenFromRecordArrays etc.)
  • to deprecate value() on has-many reference or deprecate has-many references entirely (this has proved contentious in the past, mostly due to the current state of relationships being not very workable)
  • to refactor record-data-store-wrapper to not use InternalModel
  • (possibly) RecordData V2 (or a shim for what it will be)

Note: not particularly worried about asset-size increases / performance regressions in this work, its expected to get worse until it gets better. Also the shape matters, we're mostly moving code out of the store package or positioning it to be able to be moved out of that package, so with time we should be able to trim a lot more.

Notes for Ember Release:

  • a significant number of private store APIs were removed: https://github.com/emberjs/data/pull/8055/files#diff-62407c6d69a4da3accd0232158a30203bd3257639c71f7c12f108417412e5a81 (the public removal was something that was left behind accidentally after a previous deprecation cycle that has been cleaned up)

  • a number of new deprecations were introduced: https://github.com/emberjs/data/pull/8055/files#diff-1f292f06ee3b691bd58448838191ead28b548b133d96123496b0f10e65a69ad6 These deprecations all target 5.0 and seek to remove private APIs that may have some community usage.

    • DEPRECATE_SNAPSHOT_MODEL_CLASS_ACCESS removes support for snapshot.type in favor of calling store.modelFor(<modelName>) or using the schema service
    • DEPRECATE_STORE_FIND deprecates the private store.find method which has been maintained to ease the pain for folks that happen to want to use the hidden route behavior in ember of autofetch.
    • DEPRECATE_HAS_RECORD deprecates store.hasRecordForId in favor of users using peekRecord which returns null if no record is loaded
    • DEPRECATE_RECORD_WAS_INVALID deprecates the private method store.recordWasInvalid which some addons may be using to try to affect record state. The state machine has now been entirely removed and currentState on records is heuristically derived, so these addons will need to use public APIs to update state in a way that their desired state would be derived.
    • DEPRECATE_STRING_ARG_SCHEMAS deprecates an older mechanism for using attributesDefinitionFor and relationshipsDefinitionFor on the schema service, calls should now pass an object with the modelName as the type.
    • DEPRECATE_JSON_API_FALLBACK deprecates a secret fallback adapter. If no application adapter is implemented and no per-type adapter exists, we would resolve a json-api adapter. This was undocumented and we will no longer do this.

    An additional note for private-api users, significant portions of the internals now have new function signatures, and these are likely to continue to change rapidly. If you have been using these methods for any reason and don't feel there is a public API to accomplish your need, reach out.

@runspired runspired added 🎯 canary PR is targeting canary (default) 🏷️ chore This PR primarily refactors code or updates dependencies labels Jul 24, 2022
@github-actions
Copy link

github-actions bot commented Jul 24, 2022

Asset Size Report for 2b29b1c

Modern Builds

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

Warnings

⚠️ The uncompressed size of the package @ember-data/model has increased by +918.0 B.
⚠️ The uncompressed size of the package @ember-data/serializer has increased by +825.0 B.
⚠️ The uncompressed size of the package @ember-data/adapter has increased by +385.0 B.

Changeset


EmberData +178.86 KB +879.0 B (+37.56 KB +86.0 B compressed)
    @ember-data/store +68.52 KB -1.22 KB (+14.39 KB -122.0 B compressed)
        @ember-data/store/-private +67.52 KB -1.3 KB (+14.18 KB -130.42 B compressed)
        @ember-data/store/index +1022.0 B +86.0 B (+214.62 B +8.41 B compressed)
    @ember-data/model +31.0 KB +918.0 B (+6.51 KB +89.82 B compressed)
        @ember-data/model/-private +30.53 KB +918.0 B (+6.41 KB +89.82 B compressed)
    @ember-data/record-data +24.38 KB -2.0 B (+5.12 KB -0.2 B compressed)
        @ember-data/record-data/-private +24.38 KB -2.0 B (+5.12 KB -0.2 B compressed)
    @ember-data/serializer +20.57 KB +825.0 B (+4.32 KB +80.72 B compressed)
        @ember-data/serializer/json +7.34 KB +116.0 B (+1.54 KB +11.35 B compressed)
        @ember-data/serializer/-private +5.67 KB +146.0 B (+1.19 KB +14.28 B compressed)
        @ember-data/serializer/json-api +3.83 KB +120.0 B (+823.01 B +11.74 B compressed)
        @ember-data/serializer/rest +2.93 KB +90.0 B (+630.64 B +8.81 B compressed)
        @ember-data/serializer/index +611.0 B +353.0 B (+128.31 B +34.54 B compressed)
    @ember-data/adapter +16.09 KB +385.0 B (+3.38 KB +37.67 B compressed)
        @ember-data/adapter/index +1.41 KB +385.0 B (+303.66 B +37.67 B compressed)

Full Asset Analysis (Modern)

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


Library: EmberData
┌────────────┬─────────────┐
│  (index)   │   Values    │
├────────────┼─────────────┤
│   bytes    │ '178.86 KB' │
│ compressed │ '37.56 KB'  │
│  packages  │      8      │
│  modules   │     44      │
└────────────┴─────────────┘

Package: @ember-data/store
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '68.52 KB' │
│  compressed  │ '14.39 KB' │
│ % Of Library │   '38.3'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/store/-private                        | 67.52 KB  | 14.18 KB   | 98.5          | 37.8
	@ember-data/store/index                           | 1022.00 B | 214.62 B   | 1.5           | 0.6

Package: @ember-data/model
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '31.00 KB' │
│  compressed  │ '6.51 KB'  │
│ % Of Library │   '17.3'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/model/-private                        | 30.53 KB  | 6.41 KB    | 98.5          | 17.1
	@ember-data/model/index                           | 486.00 B  | 102.06 B   | 1.5           | 0.3

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

Package: @ember-data/serializer
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '20.57 KB' │
│  compressed  │ '4.32 KB'  │
│ % Of Library │   '11.5'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/serializer/json                       | 7.34 KB   | 1.54 KB    | 35.7          | 4.1
	@ember-data/serializer/-private                   | 5.67 KB   | 1.19 KB    | 27.6          | 3.2
	@ember-data/serializer/json-api                   | 3.83 KB   | 823.01 B   | 18.6          | 2.1
	@ember-data/serializer/rest                       | 2.93 KB   | 630.64 B   | 14.3          | 1.6
	@ember-data/serializer/index                      | 611.00 B  | 128.31 B   | 2.9           | 0.3
	@ember-data/serializer/transform                  | 215.00 B  | 45.15 B    | 1.0           | 0.1

Package: @ember-data/adapter
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '16.09 KB' │
│  compressed  │ '3.38 KB'  │
│ % Of Library │   '9.0'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/adapter/rest                          | 7.88 KB   | 1.66 KB    | 49.0          | 4.4
	@ember-data/adapter/-private                      | 3.77 KB   | 811.25 B   | 23.4          | 2.1
	@ember-data/adapter/error                         | 1.99 KB   | 428.20 B   | 12.4          | 1.1
	@ember-data/adapter/index                         | 1.41 KB   | 303.66 B   | 8.8           | 0.8
	@ember-data/adapter/json-api                      | 1.03 KB   | 222.39 B   | 6.4           | 0.6

Package: ember-data
┌──────────────┬───────────┐
│   (index)    │  Values   │
├──────────────┼───────────┤
│    bytes     │ '8.77 KB' │
│  compressed  │ '1.84 KB' │
│ % Of Library │   '4.9'   │
└──────────────┴───────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	ember-data/index                                  | 2.14 KB   | 460.75 B   | 24.4          | 1.2
	ember-data/-private                               | 1.83 KB   | 392.71 B   | 20.8          | 1.0
	ember-data/adapters/errors                        | 1.19 KB   | 255.57 B   | 13.5          | 0.7
	ember-data/setup-container                        | 368.00 B  | 77.28 B    | 4.1           | 0.2
	ember-data/relationships                          | 318.00 B  | 66.78 B    | 3.5           | 0.2
	ember-data/serializers/embedded-records-mixin     | 274.00 B  | 57.54 B    | 3.1           | 0.1
	ember-data/serializers/json-api                   | 251.00 B  | 52.71 B    | 2.8           | 0.1
	ember-data/adapters/json-api                      | 245.00 B  | 51.45 B    | 2.7           | 0.1
	ember-data/serializers/json                       | 243.00 B  | 51.03 B    | 2.7           | 0.1
	ember-data/serializers/rest                       | 243.00 B  | 51.03 B    | 2.7           | 0.1
	ember-data/transform                              | 241.00 B  | 50.61 B    | 2.7           | 0.1
	ember-data/adapters/rest                          | 237.00 B  | 49.77 B    | 2.6           | 0.1
	ember-data/serializer                             | 232.00 B  | 48.72 B    | 2.6           | 0.1
	ember-data/adapter                                | 226.00 B  | 47.46 B    | 2.5           | 0.1
	ember-data/model                                  | 222.00 B  | 46.62 B    | 2.5           | 0.1
	ember-data/store                                  | 222.00 B  | 46.62 B    | 2.5           | 0.1
	ember-data/attr                                   | 218.00 B  | 45.78 B    | 2.4           | 0.1
	ember-data/version                                | 161.00 B  | 33.81 B    | 1.8           | 0.1

Package: ember-inflector
┌──────────────┬───────────┐
│   (index)    │  Values   │
├──────────────┼───────────┤
│    bytes     │ '6.67 KB' │
│  compressed  │ '1.40 KB' │
│ % Of Library │   '3.7'   │
└──────────────┴───────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	ember-inflector/lib/system/inflector              | 2.96 KB   | 637.15 B   | 44.4          | 1.7
	ember-inflector/lib/system/inflections            | 1.59 KB   | 341.67 B   | 23.8          | 0.9
	ember-inflector/lib/system                        | 471.00 B  | 98.91 B    | 6.9           | 0.3
	ember-inflector/index                             | 379.00 B  | 79.59 B    | 5.6           | 0.2
	ember-inflector/lib/helpers/pluralize             | 369.00 B  | 77.49 B    | 5.4           | 0.2
	ember-inflector/lib/utils/make-helper             | 332.00 B  | 69.72 B    | 4.9           | 0.2
	ember-inflector/lib/system/string                 | 318.00 B  | 66.78 B    | 4.7           | 0.2
	ember-inflector/lib/helpers/singularize           | 296.00 B  | 62.16 B    | 4.3           | 0.2

Package: @ember-data/debug
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '2.85 KB'  │
│  compressed  │ '613.43 B' │
│ % Of Library │   '1.6'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/debug/index                           | 2.36 KB   | 507.37 B   | 82.7          | 1.3
	@ember-data/debug/setup                           | 505.00 B  | 106.05 B   | 17.3          | 0.3

Modern Builds (No Rollup)

☑️ EmberData has not changed in size

If any packages had changed sizes they would be listed here.

Changeset



Full Asset Analysis (Modern)

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


Library: EmberData
┌────────────┬──────────┐
│  (index)   │  Values  │
├────────────┼──────────┤
│   bytes    │ '0.00 B' │
│ compressed │ '1.00 B' │
│  packages  │    0     │
│  modules   │    0     │
└────────────┴──────────┘

@github-actions
Copy link

github-actions bot commented Jul 25, 2022

Performance Report for 2b29b1c

Scenario - materialization: ⚠️ Performance regressed

⚠️ duration
phase estimated regression +24ms [10ms to 37ms] OR +2.18% [0.89% to 3.38%]
☑️ Phase [navigationStart] => [start-find-all]
phase no difference [-4ms to 3ms]
⚠️ Phase [start-find-all] => [start-materialization]
phase estimated regression +12ms [8ms to 16ms] OR +2.72% [1.83% to 3.62%]
⚠️ Phase [start-materialization] => [end-materialization]
phase estimated regression +12ms [9ms to 16ms] OR +4.07% [3.01% to 5.15%]
☑️ Phase [end-materialization] => [Test End]
phase no difference [-2ms to 4ms]

Scenario - unload: ⚠️ Performance regressed

⚠️ duration
phase estimated regression +34ms [25ms to 44ms] OR +2.68% [1.92% to 3.4%]
☑️ Phase [navigationStart] => [start-push-payload]
phase no difference [-3ms to 5ms]
⚠️ Phase [start-push-payload] => [start-unload-records]
phase estimated regression +20ms [16ms to 24ms] OR +3.37% [2.74% to 4.01%]
⚠️ Phase [start-unload-records] => [end-unload-records]
phase estimated regression +13ms [10ms to 16ms] OR +5.12% [3.99% to 6.25%]
☑️ Phase [end-unload-records] => [Test End]
phase no difference [0ms to 0ms]

Scenario - destroy: ☑️ Performance is stable

☑️ duration
phase no difference [-2ms to 18ms]
☑️ Phase [navigationStart] => [start-push-payload]
phase no difference [-4ms to 4ms]
⚠️ Phase [start-push-payload] => [start-destroy-records]
phase estimated regression +21ms [17ms to 25ms] OR +3.55% [2.88% to 4.22%]
✅ Phase [start-destroy-records] => [end-destroy-records]
phase estimated improvement -14ms [-17ms to -11ms] OR -3.57% [-4.34% to -2.86%]
☑️ Phase [end-destroy-records] => [Test End]
phase no difference [0ms to 0ms]

Scenario - add-children: ⚠️ Performance regressed

⚠️ duration
phase estimated regression +42ms [34ms to 52ms] OR +5.08% [4.02% to 6.16%]
☑️ Phase [navigationStart] => [start-push-initial-payload]
phase no difference [-5ms to 10ms]
⚠️ Phase [start-push-initial-payload] => [start-push-update-payload]
phase estimated regression +18ms [15ms to 19ms] OR +7.67% [6.77% to 8.38%]
⚠️ Phase [start-push-update-payload] => [end-push-update-payload]
phase estimated regression +16ms [14ms to 17ms] OR +19.15% [16.9% to 20.86%]
⚠️ Phase [end-push-update-payload] => [Test End]
phase estimated regression +8ms [7ms to 8ms] OR +19.07% [17.44% to 20.4%]

Scenario - unused-relationships: ⚠️ Performance regressed

⚠️ duration
phase estimated regression +20ms [12ms to 28ms] OR +1.9% [1.11% to 2.66%]
☑️ Phase [navigationStart] => [start-push-payload]
phase no difference [-6ms to 1ms]
⚠️ Phase [start-push-payload] => [end-push-payload]
phase estimated regression +15ms [11ms to 18ms] OR +2.45% [1.84% to 3.08%]
⚠️ Phase [end-push-payload] => [Test End]
phase estimated regression +9ms [8ms to 10ms] OR +15.99% [13.37% to 18.5%]

@runspired runspired merged commit 52c396a into master Jul 25, 2022
@delete-merged-branch delete-merged-branch bot deleted the runspired/more-trimming branch July 25, 2022 23:50
@runspired runspired added 🏷️ doc This PR adds/improves/or fixes documentation 🏷️ deprecation labels Jul 25, 2022
@runspired runspired mentioned this pull request Jul 26, 2022
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎯 canary PR is targeting canary (default) 🏷️ chore This PR primarily refactors code or updates dependencies 🏷️ deprecation 🏷️ doc This PR adds/improves/or fixes documentation
Projects
Status: In Development
Development

Successfully merging this pull request may close these issues.

1 participant