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

feat: Lazy Relationships & Relationship Diffing #8131

Closed
wants to merge 12 commits into from

Conversation

runspired
Copy link
Contributor

@runspired runspired commented Aug 17, 2022

This is a refactor of the internals of the graph into a data structure previously proved out in several older versions of ember-data. Due to various complications these optimizations were never landed; however, the internals (and especially relationships) are now simple enough they may.

The underlying concepts here are around optimizing allocation, instantiation, lookups, iteration and timing.

  • make relationship storage simple objects

By moving away from classes to object for storage we both reduce the total number of allocations and the instantiation cost. For 10k records with a single relationship each this is 20k fewer calls to new Klass() as well as several fewer objects allocated in the process.

  • make update propagation more efficient

Currently GC accounts for about 15% of the time spent populating the graph. This is due partly to the high temporary allocation overhead operations have and mostly to the temporary arrays and Sets created during the population process. Instead of decomposing operations into more operations we should find a simpler way of executing the instruction set. The allocation of temporary object should be reduced by the diff mechanism itself.

  • lazy local state updates

We do not need to sync remote updates to local updates until the app has requested the current state. To achieve this we notify the change but do not actually do the work until pull.

  • lazy remote state updates

We do not need to flush remote state updates unless the app has requested the current state. To achieve this we notify the change but do not actually do the work until pull.

  • persistent diff

The most common operations on the graph are membership checks (which we already optimize by use of a Set) and updates (which require performing a diff). Updates carry through the system: the changes applied to remote state will also need to be applied to local state, the changes applied to local state will need to be applied to the ManyArray, the changes applied to the ManyArray will need to be diffed by glimmer when updating the contents of #each. Our goal is to reduce how often we diff and store information such that the diff never needs to be recalculated.

End Goals

Our long term intent with the graph is to make it entirely public API. This would mean that relationship rollback, relationship diff, and local/remote state information would all be available to consuming applications as needed.

After this PR lands, but before we can make the graph public, we have two primary problems to resolve: (1). how to handle relationship pointers in nested attribute keys. (2) how to embed the proposed pagination structure for collections within the graph.

@github-actions
Copy link

github-actions bot commented Aug 17, 2022

Asset Size Report for 0979baf

Modern Builds

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

Warnings

⚠️ The uncompressed size of the package @ember-data/record-data has increased by +1.08 KB.

Changeset


EmberData 166.24 KB +1.07 KB (35.76 KB +497.0 B compressed)
    @ember-data/store 42.95 KB -12.0 B (9.24 KB -5.47 B compressed)
        @ember-data/store/-private 41.95 KB -12.0 B (9.03 KB -5.47 B compressed)
    @ember-data/record-data 24.43 KB +1.08 KB (5.26 KB +502.47 B compressed)
        @ember-data/record-data/-private 24.43 KB +1.08 KB (5.26 KB +502.47 B compressed)

Full Asset Analysis (Modern)

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


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

Package: @ember-data/model
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '44.75 KB' │
│  compressed  │ '9.63 KB'  │
│ % Of Library │   '26.9'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/model/-private                        | 44.27 KB  | 9.53 KB    | 98.9          | 26.6
	@ember-data/model/index                           | 486.00 B  | 104.55 B   | 1.1           | 0.3

Package: @ember-data/store
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '42.95 KB' │
│  compressed  │ '9.24 KB'  │
│ % Of Library │   '25.8'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/store/-private                        | 41.95 KB  | 9.03 KB    | 97.7          | 25.2
	@ember-data/store/index                           | 1022.00 B | 219.87 B   | 2.3           | 0.6

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

Package: @ember-data/serializer
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '20.42 KB' │
│  compressed  │ '4.39 KB'  │
│ % Of Library │   '12.3'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/serializer/json                       | 7.36 KB   | 1.58 KB    | 36.0          | 4.4
	@ember-data/serializer/-private                   | 5.60 KB   | 1.20 KB    | 27.4          | 3.4
	@ember-data/serializer/json-api                   | 3.79 KB   | 834.97 B   | 18.6          | 2.3
	@ember-data/serializer/rest                       | 2.87 KB   | 631.23 B   | 14.0          | 1.7
	@ember-data/serializer/index                      | 611.00 B  | 131.45 B   | 2.9           | 0.4
	@ember-data/serializer/transform                  | 215.00 B  | 46.25 B    | 1.0           | 0.1

Package: @ember-data/adapter
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '15.93 KB' │
│  compressed  │ '3.43 KB'  │
│ % Of Library │   '9.6'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/adapter/rest                          | 7.88 KB   | 1.70 KB    | 49.5          | 4.7
	@ember-data/adapter/-private                      | 3.79 KB   | 833.89 B   | 23.8          | 2.3
	@ember-data/adapter/error                         | 1.82 KB   | 401.45 B   | 11.4          | 1.1
	@ember-data/adapter/index                         | 1.41 KB   | 311.09 B   | 8.9           | 0.8
	@ember-data/adapter/json-api                      | 1.03 KB   | 227.83 B   | 6.5           | 0.6

Package: ember-data
┌──────────────┬───────────┐
│   (index)    │  Values   │
├──────────────┼───────────┤
│    bytes     │ '8.32 KB' │
│  compressed  │ '1.79 KB' │
│ % Of Library │   '5.0'   │
└──────────────┴───────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	ember-data/index                                  | 1.98 KB   | 437.16 B   | 23.8          | 1.2
	ember-data/-private                               | 1.53 KB   | 337.98 B   | 18.4          | 0.9
	ember-data/adapters/errors                        | 1.19 KB   | 261.82 B   | 14.3          | 0.7
	ember-data/setup-container                        | 368.00 B  | 79.17 B    | 4.3           | 0.2
	ember-data/relationships                          | 318.00 B  | 68.41 B    | 3.7           | 0.2
	ember-data/serializers/embedded-records-mixin     | 274.00 B  | 58.94 B    | 3.2           | 0.2
	ember-data/serializers/json-api                   | 251.00 B  | 54.00 B    | 2.9           | 0.1
	ember-data/adapters/json-api                      | 245.00 B  | 52.70 B    | 2.9           | 0.1
	ember-data/serializers/json                       | 243.00 B  | 52.27 B    | 2.9           | 0.1
	ember-data/serializers/rest                       | 243.00 B  | 52.27 B    | 2.9           | 0.1
	ember-data/transform                              | 241.00 B  | 51.84 B    | 2.8           | 0.1
	ember-data/adapters/rest                          | 237.00 B  | 50.98 B    | 2.8           | 0.1
	ember-data/serializer                             | 232.00 B  | 49.91 B    | 2.7           | 0.1
	ember-data/adapter                                | 226.00 B  | 48.62 B    | 2.7           | 0.1
	ember-data/model                                  | 222.00 B  | 47.76 B    | 2.6           | 0.1
	ember-data/store                                  | 222.00 B  | 47.76 B    | 2.6           | 0.1
	ember-data/attr                                   | 218.00 B  | 46.90 B    | 2.6           | 0.1
	ember-data/version                                | 161.00 B  | 34.63 B    | 1.9           | 0.1

Package: ember-inflector
┌──────────────┬───────────┐
│   (index)    │  Values   │
├──────────────┼───────────┤
│    bytes     │ '6.67 KB' │
│  compressed  │ '1.43 KB' │
│ % Of Library │   '4.0'   │
└──────────────┴───────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	ember-inflector/lib/system/inflector              | 2.96 KB   | 652.74 B   | 44.4          | 1.8
	ember-inflector/lib/system/inflections            | 1.59 KB   | 350.03 B   | 23.8          | 1.0
	ember-inflector/lib/system                        | 471.00 B  | 101.33 B   | 6.9           | 0.3
	ember-inflector/index                             | 379.00 B  | 81.53 B    | 5.6           | 0.2
	ember-inflector/lib/helpers/pluralize             | 369.00 B  | 79.38 B    | 5.4           | 0.2
	ember-inflector/lib/utils/make-helper             | 332.00 B  | 71.42 B    | 4.9           | 0.2
	ember-inflector/lib/system/string                 | 318.00 B  | 68.41 B    | 4.7           | 0.2
	ember-inflector/lib/helpers/singularize           | 296.00 B  | 63.68 B    | 4.3           | 0.2

Package: @ember-data/debug
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '2.77 KB'  │
│  compressed  │ '609.50 B' │
│ % Of Library │   '1.7'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/debug/index                           | 2.27 KB   | 500.85 B   | 82.2          | 1.4
	@ember-data/debug/setup                           | 505.00 B  | 108.64 B   | 17.8          | 0.3

Modern Builds (No Rollup)

🛑 The size of the library EmberData has increased by +5.63 KB (+1.47 KB compressed) which exceeds the failure threshold of 75 bytes.

Warnings

⚠️ The uncompressed size of the package @ember-data/record-data has increased by +5.64 KB.

Changeset


EmberData 210.04 KB +5.63 KB (40.44 KB +1.47 KB compressed)
    @ember-data/store 64.02 KB -12.0 B (12.32 KB -3.13 B compressed)
        @ember-data/store/-private/network/snapshot 3.3 KB -12.0 B (650.32 B -3.13 B compressed)
    @ember-data/record-data 36.39 KB +5.64 KB (7.01 KB +1.47 KB compressed)
        @ember-data/record-data/-private/record-data 7.32 KB +159.0 B (1.41 KB +41.53 B compressed)
        @ember-data/record-data/-private/graph/graph 5.93 KB +45.0 B (1.14 KB +11.75 B compressed)
        @ember-data/record-data/-private/graph/operations/replace-related-records 3.21 KB -439.0 B (631.84 B -114.66 B compressed)
        @ember-data/record-data/-private/graph/-utils 3.64 KB +1.53 KB (717.32 B +410.32 B compressed)
        @ember-data/record-data/-private/graph/operations/update-relationship 1.58 KB +75.0 B (312.26 B +19.59 B compressed)
        @ember-data/record-data/-private/graph/operations/merge-identifier 1.33 KB +72.0 B (262.01 B +18.81 B compressed)
        @ember-data/record-data/-private/graph/operations/replace-related-record 1.23 KB +23.0 B (242.95 B +6.01 B compressed)
        @ember-data/record-data/-private/graph/operations/add-to-related-records 660.0 B -169.0 B (127.06 B -44.14 B compressed)
        @ember-data/record-data/-private/graph/operations/remove-from-related-records 626.0 B -82.0 B (120.51 B -21.42 B compressed)
        @ember-data/record-data/-private/relationships/state/belongs-to 0.0 B -707.0 B (0.0 B -184.66 B compressed)
        @ember-data/record-data/-private/relationships/state/has-many 0.0 B -692.0 B (0.0 B -180.74 B compressed)
        @ember-data/record-data/-private/graph/membership 3.83 KB +3.83 KB (754.09 B +1023.07 B compressed)
        @ember-data/record-data/-private/graph/-diff 726.0 B +726.0 B (139.76 B +189.62 B compressed)
        @ember-data/record-data/-private/graph/edges/collection 672.0 B +672.0 B (129.37 B +175.52 B compressed)
        @ember-data/record-data/-private/graph/edges/resource 607.0 B +607.0 B (116.85 B +158.54 B compressed)

Full Asset Analysis (Modern)

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


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

Package: @ember-data/store
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '64.02 KB' │
│  compressed  │ '12.32 KB' │
│ % Of Library │   '30.5'   │
└──────────────┴────────────┘
	Module                                                                        | Bytes     | Compressed | % of Package  | % Of Library
	---------------------------------------------------------------------------------------------------------------------------------
	@ember-data/store/-private/store-service                                      | 10.59 KB  | 2.04 KB    | 16.5          | 5.0
	@ember-data/store/-private/managers/record-data-manager                       | 7.90 KB   | 1.52 KB    | 12.3          | 3.8
	@ember-data/store/-private/caches/instance-cache                              | 5.90 KB   | 1.14 KB    | 9.2           | 2.8
	@ember-data/store/-private/network/fetch-manager                              | 4.89 KB   | 963.16 B   | 7.6           | 2.3
	@ember-data/store/-private/record-arrays/identifier-array                     | 4.27 KB   | 841.49 B   | 6.7           | 2.0
	@ember-data/store/-private/caches/identifier-cache                            | 3.66 KB   | 721.94 B   | 5.7           | 1.7
	@ember-data/store/-private/network/snapshot                                   | 3.30 KB   | 650.32 B   | 5.2           | 1.6
	@ember-data/store/-private/managers/record-array-manager                      | 3.07 KB   | 605.85 B   | 4.8           | 1.5
	@ember-data/store/-private/index                                              | 2.74 KB   | 539.24 B   | 4.3           | 1.3
	@ember-data/store/-private/proxies/promise-proxies                            | 1.68 KB   | 330.74 B   | 2.6           | 0.8
	@ember-data/store/-private/managers/record-data-store-wrapper                 | 1.62 KB   | 319.96 B   | 2.5           | 0.8
	@ember-data/store/-private/network/request-cache                              | 1.61 KB   | 316.49 B   | 2.5           | 0.8
	@ember-data/store/-private/legacy-model-support/shim-model-class              | 1.55 KB   | 304.75 B   | 2.4           | 0.7
	@ember-data/store/-private/network/finders                                    | 1.51 KB   | 298.40 B   | 2.4           | 0.7
	@ember-data/store/-private/legacy-model-support/schema-definition-service     | 1.37 KB   | 270.87 B   | 2.1           | 0.7
	@ember-data/store/-private/legacy-model-support/record-reference              | 1.34 KB   | 263.94 B   | 2.1           | 0.6
	@ember-data/store/index                                                       | 1022.00 B | 196.75 B   | 1.6           | 0.5
	@ember-data/store/-private/utils/uuid-polyfill                                | 786.00 B  | 151.31 B   | 1.2           | 0.4
	@ember-data/store/-private/managers/record-notification-manager               | 753.00 B  | 144.96 B   | 1.1           | 0.4
	@ember-data/store/-private/network/snapshot-record-array                      | 691.00 B  | 133.03 B   | 1.1           | 0.3
	@ember-data/store/-private/utils/construct-resource                           | 688.00 B  | 132.45 B   | 1.0           | 0.3
	@ember-data/store/-private/utils/common                                       | 572.00 B  | 110.12 B   | 0.9           | 0.3
	@ember-data/store/-private/utils/coerce-id                                    | 473.00 B  | 91.06 B    | 0.7           | 0.2
	@ember-data/store/-private/proxies/promise-proxy-base                         | 403.00 B  | 77.58 B    | 0.6           | 0.2
	@ember-data/store/-private/caches/record-data-for                             | 325.00 B  | 62.56 B    | 0.5           | 0.2
	@ember-data/store/-private/utils/identifer-debug-consts                       | 304.00 B  | 58.52 B    | 0.5           | 0.1
	@ember-data/store/-private/utils/promise-record                               | 291.00 B  | 56.02 B    | 0.4           | 0.1
	@ember-data/store/-private/utils/serializer-response                          | 258.00 B  | 49.66 B    | 0.4           | 0.1
	@ember-data/store/-private/utils/normalize-model-name                         | 219.00 B  | 42.16 B    | 0.3           | 0.1
	@ember-data/store/-debug/index                                                | 207.00 B  | 39.85 B    | 0.3           | 0.1
	@ember-data/store/-private/utils/is-non-empty-string                          | 204.00 B  | 39.27 B    | 0.3           | 0.1

Package: @ember-data/model
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '51.10 KB' │
│  compressed  │ '9.84 KB'  │
│ % Of Library │   '24.3'   │
└──────────────┴────────────┘
	Module                                                      | Bytes     | Compressed | % of Package  | % Of Library
	---------------------------------------------------------------------------------------------------------------
	@ember-data/model/-private/model                            | 11.25 KB  | 2.16 KB    | 22.0          | 5.4
	@ember-data/model/-private/legacy-relationships-support     | 7.94 KB   | 1.53 KB    | 15.5          | 3.8
	@ember-data/model/-private/record-state                     | 6.52 KB   | 1.26 KB    | 12.8          | 3.1
	@ember-data/model/-private/references/has-many              | 3.20 KB   | 631.07 B   | 6.3           | 1.5
	@ember-data/model/-private/references/belongs-to            | 2.81 KB   | 554.64 B   | 5.5           | 1.3
	@ember-data/model/-private/promise-many-array               | 2.70 KB   | 532.69 B   | 5.3           | 1.3
	@ember-data/model/-private/legacy-data-fetch                | 2.59 KB   | 509.78 B   | 5.1           | 1.2
	@ember-data/model/-private/many-array                       | 2.35 KB   | 462.81 B   | 4.6           | 1.1
	@ember-data/model/-private/errors                           | 2.31 KB   | 455.30 B   | 4.5           | 1.1
	@ember-data/model/-private/index                            | 1.48 KB   | 292.43 B   | 2.9           | 0.7
	@ember-data/model/-private/relationship-meta                | 991.00 B  | 190.78 B   | 1.9           | 0.5
	@ember-data/model/-private/notify-changes                   | 913.00 B  | 175.76 B   | 1.7           | 0.4
	@ember-data/model/-private/attr                             | 839.00 B  | 161.52 B   | 1.6           | 0.4
	@ember-data/model/-private/has-many                         | 817.00 B  | 157.28 B   | 1.6           | 0.4
	@ember-data/model/-private/belongs-to                       | 736.00 B  | 141.69 B   | 1.4           | 0.3
	@ember-data/model/-private/deprecated-promise-proxy         | 681.00 B  | 131.10 B   | 1.3           | 0.3
	@ember-data/model/-private/promise-belongs-to               | 615.00 B  | 118.39 B   | 1.2           | 0.3
	@ember-data/model/-private/util                             | 522.00 B  | 100.49 B   | 1.0           | 0.2
	@ember-data/model/index                                     | 486.00 B  | 93.56 B    | 0.9           | 0.2
	@ember-data/model/-private/diff-array                       | 445.00 B  | 85.67 B    | 0.9           | 0.2
	@ember-data/model/-private/model-for-mixin                  | 407.00 B  | 78.35 B    | 0.8           | 0.2
	@ember-data/model/-private/legacy-data-utils                | 395.00 B  | 76.04 B    | 0.8           | 0.2
	@ember-data/model/-private/promise-proxy-base               | 284.00 B  | 54.67 B    | 0.5           | 0.1

Package: @ember-data/record-data
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '36.39 KB' │
│  compressed  │ '7.01 KB'  │
│ % Of Library │   '17.3'   │
└──────────────┴────────────┘
	Module                                                                            | Bytes     | Compressed | % of Package  | % Of Library
	-------------------------------------------------------------------------------------------------------------------------------------
	@ember-data/record-data/-private/record-data                                      | 7.32 KB   | 1.41 KB    | 20.1          | 3.5
	@ember-data/record-data/-private/graph/graph                                      | 5.93 KB   | 1.14 KB    | 16.3          | 2.8
	@ember-data/record-data/-private/graph/membership                                 | 3.83 KB   | 754.09 B   | 10.5          | 1.8
	@ember-data/record-data/-private/graph/-utils                                     | 3.64 KB   | 717.32 B   | 10.0          | 1.7
	@ember-data/record-data/-private/graph/operations/replace-related-records         | 3.21 KB   | 631.84 B   | 8.8           | 1.5
	@ember-data/record-data/-private/graph/-edge-definition                           | 3.12 KB   | 614.32 B   | 8.6           | 1.5
	@ember-data/record-data/-private/graph/operations/update-relationship             | 1.58 KB   | 312.26 B   | 4.4           | 0.8
	@ember-data/record-data/-private/graph/operations/merge-identifier                | 1.33 KB   | 262.01 B   | 3.7           | 0.6
	@ember-data/record-data/-private/graph/operations/replace-related-record          | 1.23 KB   | 242.95 B   | 3.4           | 0.6
	@ember-data/record-data/-private/graph/-diff                                      | 726.00 B  | 139.76 B   | 1.9           | 0.3
	@ember-data/record-data/-private/graph/edges/collection                           | 672.00 B  | 129.37 B   | 1.8           | 0.3
	@ember-data/record-data/-private/graph/operations/add-to-related-records          | 660.00 B  | 127.06 B   | 1.8           | 0.3
	@ember-data/record-data/-private/graph/operations/remove-from-related-records     | 626.00 B  | 120.51 B   | 1.7           | 0.3
	@ember-data/record-data/-private/graph/edges/resource                             | 607.00 B  | 116.85 B   | 1.6           | 0.3
	@ember-data/record-data/-private/index                                            | 497.00 B  | 95.68 B    | 1.3           | 0.2
	@ember-data/record-data/-private/graph/index                                      | 482.00 B  | 92.79 B    | 1.3           | 0.2
	@ember-data/record-data/-private/coerce-id                                        | 379.00 B  | 72.96 B    | 1.0           | 0.2
	@ember-data/record-data/-private/graph/-state                                     | 293.00 B  | 56.40 B    | 0.8           | 0.1
	@ember-data/record-data/-private/normalize-link                                   | 238.00 B  | 45.81 B    | 0.6           | 0.1
	@ember-data/record-data/-private/graph/-operations                                | 150.00 B  | 28.87 B    | 0.4           | 0.1

Package: @ember-data/serializer
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '22.43 KB' │
│  compressed  │ '4.32 KB'  │
│ % Of Library │   '10.7'   │
└──────────────┴────────────┘
	Module                                                     | Bytes     | Compressed | % of Package  | % Of Library
	--------------------------------------------------------------------------------------------------------------
	@ember-data/serializer/json                                | 7.36 KB   | 1.42 KB    | 32.8          | 3.5
	@ember-data/serializer/-private/embedded-records-mixin     | 4.59 KB   | 905.60 B   | 20.5          | 2.2
	@ember-data/serializer/json-api                            | 3.79 KB   | 747.16 B   | 16.9          | 1.8
	@ember-data/serializer/rest                                | 2.87 KB   | 564.84 B   | 12.8          | 1.4
	@ember-data/serializer/-private/index                      | 1018.00 B | 195.98 B   | 4.4           | 0.5
	@ember-data/serializer/index                               | 611.00 B  | 117.62 B   | 2.7           | 0.3
	@ember-data/serializer/-private/transforms/date            | 530.00 B  | 102.03 B   | 2.3           | 0.2
	@ember-data/serializer/-private/transforms/boolean         | 504.00 B  | 97.02 B    | 2.2           | 0.2
	@ember-data/serializer/-private/transforms/number          | 439.00 B  | 84.51 B    | 1.9           | 0.2
	@ember-data/serializer/-private/transforms/string          | 371.00 B  | 71.42 B    | 1.6           | 0.2
	@ember-data/serializer/-private/transforms/transform       | 226.00 B  | 43.50 B    | 1.0           | 0.1
	@ember-data/serializer/transform                           | 215.00 B  | 41.39 B    | 0.9           | 0.1

Package: @ember-data/adapter
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '18.04 KB' │
│  compressed  │ '3.47 KB'  │
│ % Of Library │   '8.6'    │
└──────────────┴────────────┘
	Module                                                        | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------------------
	@ember-data/adapter/rest                                      | 7.88 KB   | 1.52 KB    | 43.7          | 3.8
	@ember-data/adapter/-private/build-url-mixin                  | 1.92 KB   | 378.10 B   | 10.6          | 0.9
	@ember-data/adapter/error                                     | 1.82 KB   | 359.23 B   | 10.1          | 0.9
	@ember-data/adapter/index                                     | 1.41 KB   | 278.38 B   | 7.8           | 0.7
	@ember-data/adapter/json-api                                  | 1.03 KB   | 203.87 B   | 5.7           | 0.5
	@ember-data/adapter/-private/index                            | 1.03 KB   | 203.29 B   | 5.7           | 0.5
	@ember-data/adapter/-private/utils/serialize-query-params     | 769.00 B  | 148.04 B   | 4.2           | 0.4
	@ember-data/adapter/-private/utils/determine-body-promise     | 556.00 B  | 107.04 B   | 3.0           | 0.3
	@ember-data/adapter/-private/utils/parse-response-headers     | 488.00 B  | 93.94 B    | 2.6           | 0.2
	@ember-data/adapter/-private/utils/fetch                      | 450.00 B  | 86.63 B    | 2.4           | 0.2
	@ember-data/adapter/-private/utils/serialize-into-hash        | 382.00 B  | 73.54 B    | 2.1           | 0.2
	@ember-data/adapter/-private/utils/continue-on-reject         | 222.00 B  | 42.73 B    | 1.2           | 0.1
	@ember-data/adapter/-private/fastboot-interface               | 147.00 B  | 28.30 B    | 0.8           | 0.1

Package: ember-data
┌──────────────┬───────────┐
│   (index)    │  Values   │
├──────────────┼───────────┤
│    bytes     │ '8.64 KB' │
│  compressed  │ '1.66 KB' │
│ % Of Library │   '4.1'   │
└──────────────┴───────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	ember-data/index                                  | 1.98 KB   | 391.19 B   | 23.0          | 0.9
	ember-data/-private/index                         | 1.49 KB   | 293.97 B   | 17.3          | 0.7
	ember-data/adapters/errors                        | 1.19 KB   | 234.29 B   | 13.8          | 0.6
	ember-data/-private/core                          | 368.00 B  | 70.84 B    | 4.2           | 0.2
	ember-data/setup-container                        | 368.00 B  | 70.84 B    | 4.2           | 0.2
	ember-data/relationships                          | 318.00 B  | 61.22 B    | 3.6           | 0.1
	ember-data/serializers/embedded-records-mixin     | 274.00 B  | 52.74 B    | 3.1           | 0.1
	ember-data/serializers/json-api                   | 251.00 B  | 48.32 B    | 2.8           | 0.1
	ember-data/adapters/json-api                      | 245.00 B  | 47.16 B    | 2.8           | 0.1
	ember-data/serializers/json                       | 243.00 B  | 46.78 B    | 2.7           | 0.1
	ember-data/serializers/rest                       | 243.00 B  | 46.78 B    | 2.7           | 0.1
	ember-data/transform                              | 241.00 B  | 46.39 B    | 2.7           | 0.1
	ember-data/adapters/rest                          | 237.00 B  | 45.62 B    | 2.7           | 0.1
	ember-data/serializer                             | 232.00 B  | 44.66 B    | 2.6           | 0.1
	ember-data/adapter                                | 226.00 B  | 43.50 B    | 2.6           | 0.1
	ember-data/model                                  | 222.00 B  | 42.73 B    | 2.5           | 0.1
	ember-data/store                                  | 222.00 B  | 42.73 B    | 2.5           | 0.1
	ember-data/attr                                   | 218.00 B  | 41.96 B    | 2.5           | 0.1
	ember-data/version                                | 161.00 B  | 30.99 B    | 1.8           | 0.1

Package: ember-inflector
┌──────────────┬───────────┐
│   (index)    │  Values   │
├──────────────┼───────────┤
│    bytes     │ '6.67 KB' │
│  compressed  │ '1.28 KB' │
│ % Of Library │   '3.2'   │
└──────────────┴───────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	ember-inflector/lib/system/inflector              | 2.96 KB   | 584.10 B   | 44.4          | 1.4
	ember-inflector/lib/system/inflections            | 1.59 KB   | 313.22 B   | 23.8          | 0.8
	ember-inflector/lib/system                        | 471.00 B  | 90.67 B    | 6.9           | 0.2
	ember-inflector/index                             | 379.00 B  | 72.96 B    | 5.6           | 0.2
	ember-inflector/lib/helpers/pluralize             | 369.00 B  | 71.03 B    | 5.4           | 0.2
	ember-inflector/lib/utils/make-helper             | 332.00 B  | 63.91 B    | 4.9           | 0.2
	ember-inflector/lib/system/string                 | 318.00 B  | 61.22 B    | 4.7           | 0.1
	ember-inflector/lib/helpers/singularize           | 296.00 B  | 56.98 B    | 4.3           | 0.1

Package: @ember-data/debug
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '2.77 KB'  │
│  compressed  │ '545.40 B' │
│ % Of Library │   '1.3'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/debug/index                           | 2.27 KB   | 448.17 B   | 82.2          | 1.1
	@ember-data/debug/setup                           | 505.00 B  | 97.22 B    | 17.8          | 0.2

@runspired runspired force-pushed the runspired/fast-relationships branch from 8e3a171 to d70831c Compare August 18, 2022 06:59
@runspired runspired added 🎯 canary PR is targeting canary (default) 🏷️ feat This PR introduces a new feature Relationship Refactor 🏷️ perf PRs that improve performance in a notable way 5.0 Roadmap labels Aug 18, 2022
@runspired runspired force-pushed the runspired/fast-relationships branch from 62118a8 to 27619cb Compare August 18, 2022 07:16
@github-actions
Copy link

github-actions bot commented Aug 18, 2022

Performance Report for 0979baf

Scenario - basic-record-materialization: ✅ Performance improved

✅ duration
phase estimated improvement -1362ms [-1395ms to -1147ms] OR -44.74% [-45.84% to -37.67%]
☑️ Phase [navigationStart] => [start-data-generation]
phase no difference [-2ms to 2ms]
⚠️ Phase [start-data-generation] => [start-push-payload]
phase estimated regression +2ms [1ms to 4ms] OR +0.61% [0.18% to 1.08%]
✅ Phase [start-push-payload] => [start-peek-records]
phase estimated improvement -1089ms [-1095ms to -1084ms] OR -72.32% [-72.68% to -71.96%]
☑️ Phase [start-peek-records] => [start-record-materialization]
phase no difference [0ms to 0ms]
✅ Phase [start-record-materialization] => [end-record-materialization]
phase estimated improvement -247ms [-268ms to -15ms] OR -31.29% [-33.91% to -1.89%]
✅ Phase [end-record-materialization] => [Test End]
phase estimated improvement -31ms [-44ms to -1ms] OR -41.16% [-58.34% to -0.92%]

Scenario - relationship-materialization-simple: ✅ Performance improved

✅ duration
phase estimated improvement -19ms [-27ms to -12ms] OR -2.72% [-3.72% to -1.65%]
☑️ Phase [navigationStart] => [start-find-all]
phase no difference [-2ms to 3ms]
✅ Phase [start-find-all] => [start-materialization]
phase estimated improvement -179ms [-182ms to -176ms] OR -49.95% [-50.69% to -49.21%]
⚠️ Phase [start-materialization] => [end-materialization]
phase estimated regression +156ms [152ms to 159ms] OR +212.13% [207.73% to 216.52%]
☑️ Phase [end-materialization] => [Test End]
phase no difference [0ms to 2ms]

Scenario - relationship-materialization-complex: ✅ Performance improved

✅ duration
phase estimated improvement -105ms [-130ms to -79ms] OR -2.4% [-2.99% to -1.8%]
☑️ Phase [navigationStart] => [start-data-generation]
phase no difference [-3ms to 1ms]
☑️ Phase [start-data-generation] => [start-push-payload]
phase no difference [0ms to 1ms]
✅ Phase [start-push-payload] => [start-peek-records]
phase estimated improvement -589ms [-592ms to -586ms] OR -77.72% [-78.11% to -77.37%]
☑️ Phase [start-peek-records] => [start-record-materialization]
phase no difference [0ms to 0ms]
⚠️ Phase [start-record-materialization] => [start-relationship-materialization]
phase estimated regression +69ms [65ms to 72ms] OR +28.83% [27.35% to 30.27%]
⚠️ Phase [start-relationship-materialization] => [end-relationship-materialization]
phase estimated regression +405ms [385ms to 425ms] OR +15.88% [15.1% to 16.67%]
⚠️ Phase [end-relationship-materialization] => [Test End]
phase estimated regression +7ms [1ms to 14ms] OR +1.89% [0.33% to 3.89%]

Scenario - unload: ✅ Performance improved

✅ duration
phase estimated improvement -412ms [-419ms to -405ms] OR -38.16% [-38.83% to -37.54%]
☑️ Phase [navigationStart] => [start-push-payload]
phase no difference [-6ms to 2ms]
✅ Phase [start-push-payload] => [start-unload-records]
phase estimated improvement -377ms [-379ms to -374ms] OR -76.38% [-76.87% to -75.92%]
✅ Phase [start-unload-records] => [end-unload-records]
phase estimated improvement -33ms [-35ms to -31ms] OR -18.14% [-19.09% to -17.07%]
✅ Phase [end-unload-records] => [Test End]
phase estimated improvement -1ms [-1ms to -1ms] OR -3.13% [-3.42% to -2.82%]

Scenario - unload-all: ✅ Performance improved

✅ duration
phase estimated improvement -680ms [-690ms to -670ms] OR -31.85% [-32.29% to -31.37%]
⚠️ Phase [navigationStart] => [start-push-payload]
phase estimated regression +4ms [1ms to 8ms] OR +0.82% [0.15% to 1.58%]
✅ Phase [start-push-payload] => [start-materialization]
phase estimated improvement -737ms [-740ms to -735ms] OR -77.51% [-77.79% to -77.24%]
⚠️ Phase [start-materialization] => [start-unload-all]
phase estimated regression +62ms [59ms to 66ms] OR +19.89% [18.82% to 20.94%]
✅ Phase [start-unload-all] => [end-unload-all]
phase estimated improvement -12ms [-14ms to -9ms] OR -3.47% [-4.33% to -2.63%]
☑️ Phase [end-unload-all] => [Test End]
phase no difference [0ms to 0ms]

Scenario - destroy: ⚠️ Performance regressed

⚠️ duration
phase estimated regression +433ms [424ms to 442ms] OR +40.87% [40.07% to 41.76%]
☑️ Phase [navigationStart] => [start-push-payload]
phase no difference [-2ms to 4ms]
✅ Phase [start-push-payload] => [start-destroy-records]
phase estimated improvement -372ms [-375ms to -370ms] OR -76.16% [-76.64% to -75.74%]
⚠️ Phase [start-destroy-records] => [end-destroy-records]
phase estimated regression +806ms [803ms to 811ms] OR +484.64% [482.48% to 487.33%]
✅ Phase [end-destroy-records] => [Test End]
phase estimated improvement -1ms [-1ms to -1ms] OR -2.75% [-3.23% to -2.31%]

Scenario - add-children: ✅ Performance improved

✅ duration
phase estimated improvement -137ms [-142ms to -130ms] OR -18.35% [-19.12% to -17.5%]
☑️ Phase [navigationStart] => [start-push-initial-payload]
phase no difference [-2ms to 7ms]
✅ Phase [start-push-initial-payload] => [start-push-update-payload]
phase estimated improvement -85ms [-86ms to -83ms] OR -49.68% [-50.73% to -48.66%]
✅ Phase [start-push-update-payload] => [end-push-update-payload]
phase estimated improvement -53ms [-55ms to -52ms] OR -43.13% [-44.59% to -41.95%]
☑️ Phase [end-push-update-payload] => [Test End]
phase no difference [0ms to 0ms]

Scenario - unused-relationships: ✅ Performance improved

✅ duration
phase estimated improvement -374ms [-380ms to -367ms] OR -41.57% [-42.31% to -40.86%]
☑️ Phase [navigationStart] => [start-push-payload]
phase no difference [-3ms to 4ms]
✅ Phase [start-push-payload] => [end-push-payload]
phase estimated improvement -373ms [-375ms to -371ms] OR -76.26% [-76.68% to -75.81%]
✅ Phase [end-push-payload] => [Test End]
phase estimated improvement -1ms [-1ms to -1ms] OR -2.67% [-3.02% to -2.39%]

@runspired runspired force-pushed the runspired/fast-relationships branch from 06b78e2 to ce348ed Compare September 2, 2022 09:57
@github-actions
Copy link

github-actions bot commented Sep 2, 2022

Commit v Release Performance Report for 0979baf

Scenario - basic-record-materialization: ✅ Performance improved

✅ duration
phase estimated improvement -3142ms [-3203ms to -2877ms] OR -64.09% [-65.33% to -58.69%]
☑️ Phase [navigationStart] => [start-data-generation]
phase no difference [-5ms to 2ms]
✅ Phase [start-data-generation] => [start-push-payload]
phase estimated improvement -3ms [-5ms to -1ms] OR -0.72% [-1.23% to -0.17%]
✅ Phase [start-push-payload] => [start-peek-records]
phase estimated improvement -1950ms [-1959ms to -1942ms] OR -81.41% [-81.77% to -81.07%]
✅ Phase [start-peek-records] => [start-record-materialization]
phase estimated improvement -126ms [-128ms to -125ms] OR -96.85% [-98.35% to -95.88%]
✅ Phase [start-record-materialization] => [end-record-materialization]
phase estimated improvement -572ms [-583ms to -563ms] OR -49.48% [-50.39% to -48.67%]
✅ Phase [end-record-materialization] => [Test End]
phase estimated improvement -198ms [-217ms to -186ms] OR -83.87% [-92.24% to -78.88%]

Scenario - relationship-materialization-simple: ✅ Performance improved

✅ duration
phase estimated improvement -477ms [-485ms to -468ms] OR -39.93% [-40.64% to -39.18%]
☑️ Phase [navigationStart] => [start-find-all]
phase no difference [-4ms to 1ms]
✅ Phase [start-find-all] => [start-materialization]
phase estimated improvement -276ms [-279ms to -273ms] OR -60.19% [-60.83% to -59.57%]
✅ Phase [start-materialization] => [end-materialization]
phase estimated improvement -119ms [-123ms to -116ms] OR -33.34% [-34.31% to -32.45%]
✅ Phase [end-materialization] => [Test End]
phase estimated improvement -81ms [-83ms to -80ms] OR -68.61% [-70.35% to -67.09%]

Scenario - relationship-materialization-complex: ✅ Performance improved

✅ duration
phase estimated improvement -1281ms [-1311ms to -1252ms] OR -22.11% [-22.63% to -21.6%]
☑️ Phase [navigationStart] => [start-data-generation]
phase no difference [-5ms to 1ms]
☑️ Phase [start-data-generation] => [start-push-payload]
phase no difference [-1ms to 1ms]
✅ Phase [start-push-payload] => [start-peek-records]
phase estimated improvement -954ms [-960ms to -949ms] OR -84.33% [-84.84% to -83.86%]
✅ Phase [start-peek-records] => [start-record-materialization]
phase estimated improvement -62ms [-63ms to -61ms] OR -96.68% [-98.3% to -94.85%]
✅ Phase [start-record-materialization] => [start-relationship-materialization]
phase estimated improvement -173ms [-177ms to -169ms] OR -34.64% [-35.39% to -33.89%]
⚠️ Phase [start-relationship-materialization] => [end-relationship-materialization]
phase estimated regression +76ms [53ms to 99ms] OR +2.46% [1.72% to 3.18%]
✅ Phase [end-relationship-materialization] => [Test End]
phase estimated improvement -165ms [-172ms to -158ms] OR -29.77% [-30.96% to -28.55%]

Scenario - unload: ✅ Performance improved

✅ duration
phase estimated improvement -732ms [-743ms to -721ms] OR -51.38% [-52.13% to -50.59%]
☑️ Phase [navigationStart] => [start-push-payload]
phase no difference [-5ms to 3ms]
✅ Phase [start-push-payload] => [start-unload-records]
phase estimated improvement -578ms [-582ms to -573ms] OR -82.74% [-83.33% to -82.06%]
✅ Phase [start-unload-records] => [end-unload-records]
phase estimated improvement -150ms [-152ms to -147ms] OR -48.89% [-49.76% to -48.05%]
✅ Phase [end-unload-records] => [Test End]
phase estimated improvement -2ms [-2ms to -2ms] OR -5.01% [-5.41% to -4.62%]

Scenario - unload-all: ✅ Performance improved

✅ duration
phase estimated improvement -17494ms [-17546ms to -17420ms] OR -91.75% [-92.03% to -91.37%]
☑️ Phase [navigationStart] => [start-push-payload]
phase no difference [-8ms to 5ms]
✅ Phase [start-push-payload] => [start-materialization]
phase estimated improvement -1316ms [-1324ms to -1310ms] OR -85.17% [-85.67% to -84.78%]
✅ Phase [start-materialization] => [start-unload-all]
phase estimated improvement -358ms [-364ms to -351ms] OR -46.6% [-47.39% to -45.75%]
✅ Phase [start-unload-all] => [end-unload-all]
phase estimated improvement -15792ms [-15855ms to -15752ms] OR -97.8% [-98.19% to -97.55%]
✅ Phase [end-unload-all] => [Test End]
phase estimated improvement -1ms [-1ms to 0ms] OR -1.62% [-2.19% to -0.89%]

Scenario - destroy: ✅ Performance improved

✅ duration
phase estimated improvement -19ms [-31ms to -8ms] OR -1.23% [-1.96% to -0.49%]
☑️ Phase [navigationStart] => [start-push-payload]
phase no difference [-4ms to 3ms]
✅ Phase [start-push-payload] => [start-destroy-records]
phase estimated improvement -566ms [-570ms to -564ms] OR -82.42% [-82.89% to -82.02%]
⚠️ Phase [start-destroy-records] => [end-destroy-records]
phase estimated regression +548ms [544ms to 553ms] OR +120.12% [119.14% to 121.23%]
✅ Phase [end-destroy-records] => [Test End]
phase estimated improvement -1ms [-1ms to -1ms] OR -2.45% [-2.95% to -1.92%]

Scenario - add-children: ✅ Performance improved

✅ duration
phase estimated improvement -381ms [-387ms to -375ms] OR -38.12% [-38.77% to -37.55%]
✅ Phase [navigationStart] => [start-push-initial-payload]
phase estimated improvement -5ms [-9ms to -1ms] OR -1.15% [-2.1% to -0.15%]
✅ Phase [start-push-initial-payload] => [start-push-update-payload]
phase estimated improvement -183ms [-185ms to -181ms] OR -67.34% [-68.03% to -66.62%]
✅ Phase [start-push-update-payload] => [end-push-update-payload]
phase estimated improvement -154ms [-156ms to -152ms] OR -67.05% [-67.92% to -66.18%]
✅ Phase [end-push-update-payload] => [Test End]
phase estimated improvement -41ms [-42ms to -41ms] OR -54.36% [-54.89% to -53.91%]

Scenario - unused-relationships: ✅ Performance improved

✅ duration
phase estimated improvement -619ms [-626ms to -612ms] OR -53.79% [-54.41% to -53.18%]
☑️ Phase [navigationStart] => [start-push-payload]
phase no difference [-4ms to 3ms]
✅ Phase [start-push-payload] => [end-push-payload]
phase estimated improvement -584ms [-587ms to -581ms] OR -82.92% [-83.35% to -82.46%]
✅ Phase [end-push-payload] => [Test End]
phase estimated improvement -32ms [-33ms to -32ms] OR -48.62% [-50.21% to -47.58%]

@runspired
Copy link
Contributor Author

this branch is no longer needed as the diffing work was completed in #8807 and the lazy work is being done in #8806

all other ideas here have now been ported to #6573 for tracking

@runspired runspired closed this Sep 3, 2023
@runspired runspired deleted the runspired/fast-relationships branch September 3, 2023 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.0 Roadmap 🎯 canary PR is targeting canary (default) 🏷️ feat This PR introduces a new feature 🏷️ perf PRs that improve performance in a notable way
Projects
Status: Discarded
Development

Successfully merging this pull request may close these issues.

1 participant