Skip to content

Commit 6c952b0

Browse files
committed
chore: update perf suite
1 parent bb38113 commit 6c952b0

File tree

7 files changed

+85
-22
lines changed

7 files changed

+85
-22
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"prepare": "export TURBO_FORCE=true; turbo run build:pkg; pnpm run prepare:types;",
1313
"prepare:types": "export TURBO_FORCE=true; tsc --build --force; turbo run build:glint;",
1414
"release": "./release/index.ts",
15-
"build": "turbo _build --log-order=stream --filter=./packages/* --concurrency=10;",
15+
"build": "turbo run build:pkg --log-order=stream --concurrency=10;",
1616
"sync": "pnpm --filter './packages/*' run --parallel --if-present sync",
1717
"build:docs": "mkdir -p packages/-ember-data/dist && cd ./docs-generator && node ./compile-docs.js",
1818
"lint:tests": "turbo --log-order=stream lint --filter=./tests/* --continue --concurrency=10",

packages/build-config/src/debugging.ts

+8
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,11 @@ export const LOG_INSTANCE_CACHE: boolean = false;
111111
* @public
112112
*/
113113
export const LOG_METRIC_COUNTS: boolean = false;
114+
/**
115+
* Helps when debugging causes of a change notification
116+
* when processing an update to a hasMany relationship.
117+
*
118+
* @property {boolean} DEBUG_RELATIONSHIP_NOTIFICATIONS
119+
* @public
120+
*/
121+
export const DEBUG_RELATIONSHIP_NOTIFICATIONS: boolean = false;

tests/docs/fixtures/expected.js

+1
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,7 @@ module.exports = {
606606
'(public) @warp-drive/build-config/debugging DebugLogging#LOG_PAYLOADS',
607607
'(public) @warp-drive/build-config/debugging DebugLogging#LOG_REQUEST_STATUS',
608608
'(public) @warp-drive/build-config/debugging DebugLogging#LOG_REQUESTS',
609+
'(public) @warp-drive/build-config/debugging DebugLogging#DEBUG_RELATIONSHIP_NOTIFICATIONS',
609610
'(public) @warp-drive/build-config/deprecations CurrentDeprecations#DEPRECATE_COMPUTED_CHAINS',
610611
'(public) @warp-drive/build-config/deprecations CurrentDeprecations#DEPRECATE_EMBER_INFLECTOR',
611612
'(public) @warp-drive/build-config/deprecations CurrentDeprecations#DEPRECATE_LEGACY_IMPORTS',

tests/performance/app/routes/update-with-same-state-m2m.js

+56-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1+
/* eslint-disable no-console */
2+
/* eslint-disable no-undef */
13
import Route from '@ember/routing/route';
24
import { inject as service } from '@ember/service';
35

4-
const REMOVAL_COUNT = 10;
6+
const DEBUG = false;
57

68
export default Route.extend({
79
store: service(),
810

911
async model() {
12+
DEBUG && console.groupCollapsed('test-setup');
1013
performance.mark('start-data-generation');
1114

1215
const initialPayload = await fetch('./fixtures/big-many-to-many.json').then((r) => r.json());
1316
const initialPayload2 = structuredClone(initialPayload);
1417
const payloadWithRemoval = await fetch('./fixtures/big-many-to-many-with-removal.json').then((r) => r.json());
18+
// our relationship has 10 * number of colors generated members,
19+
// so this keeps us in-sync with the fixture generation
20+
const REMOVAL_COUNT =
21+
initialPayload.data[0].relationships.colors.data.length -
22+
payloadWithRemoval.data[0].relationships.colors.data.length;
1523

1624
performance.mark('start-push-initial-payload');
1725
this.store.push(initialPayload);
@@ -27,24 +35,68 @@ export default Route.extend({
2735
performance.mark('start-relationship-materialization');
2836
const seen = new Set();
2937
peekedCars.forEach((car) => iterateCar(car, seen));
38+
seen.clear();
3039
const removedColors = [];
3140

41+
DEBUG && console.groupEnd();
42+
DEBUG && console.log(structuredClone(getWarpDriveMetricCounts()));
43+
3244
performance.mark('start-local-removal');
45+
console.groupCollapsed('start-local-removal');
3346
for (const car of peekedCars) {
3447
const colors = car.colors;
3548
removedColors.push(colors.splice(0, REMOVAL_COUNT));
3649
}
50+
peekedCars.forEach((car) => iterateCar(car, seen));
51+
seen.clear();
52+
53+
DEBUG && console.groupEnd();
54+
DEBUG && console.log(structuredClone(getWarpDriveMetricCounts()));
3755

3856
performance.mark('start-push-minus-one-payload');
57+
DEBUG && console.groupCollapsed('start-push-minus-one-payload');
58+
3959
this.store.push(payloadWithRemoval);
60+
DEBUG && console.groupEnd();
61+
DEBUG && console.log(structuredClone(getWarpDriveMetricCounts()));
4062

4163
performance.mark('start-local-addition');
42-
peekedCars.forEach((car, index) => {
43-
car.colors = removedColors[index].concat(car.colors);
44-
});
64+
DEBUG && console.groupCollapsed('start-local-addition');
65+
// note, due to their position, the cars relationship on 50% of
66+
// colors will end up reversed, causing us to generate a notification.
67+
// this is because when we initially remove the colors from cars,
68+
// we remove the car from wherever it occurs. When we re-add, that
69+
// counts as re-adding "to the end" of the relationship since the
70+
// removal was previously committed.
71+
// To not generate a notification in this benchmark, the API response
72+
// would need to account for the natural re-ordering of cars in the colors
73+
// relationship.
74+
//
75+
// colors.cars = [1, 2, 3]
76+
// cars.colors = [1, 2, 3]
77+
// remove color 1 from cars.colors
78+
// colors.cars = [2, 3]
79+
// cars.colors = [2, 3]
80+
// now add color-1 back to cars.colors at the front
81+
// cars.colors = [1, 2, 3]
82+
// colors.cars = [2, 3, 1] // notice order change
83+
// but our payload will be [1, 2, 3] so we will generate a notification
84+
// for colors.cars (we should not generate one for cars.colors)
85+
for (let i = 0; i < peekedCars.length; i++) {
86+
const car = peekedCars[i];
87+
car.colors = removedColors[i].concat(car.colors);
88+
}
89+
peekedCars.forEach((car) => iterateCar(car, seen));
90+
seen.clear();
91+
92+
DEBUG && console.groupEnd();
93+
DEBUG && console.log(structuredClone(getWarpDriveMetricCounts()));
4594

4695
performance.mark('start-push-plus-one-payload');
96+
DEBUG && console.groupCollapsed('start-push-plus-one-payload');
4797
this.store.push(initialPayload2);
98+
DEBUG && console.groupEnd();
99+
DEBUG && console.log(structuredClone(getWarpDriveMetricCounts()));
48100

49101
performance.mark('end-push-plus-one-payload');
50102
},

tests/performance/ember-cli-build.js

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = async function (defaults) {
1414
// LOG_NOTIFICATIONS: true,
1515
// LOG_INSTANCE_CACHE: true,
1616
// LOG_METRIC_COUNTS: true,
17+
// DEBUG_RELATIONSHIP_NOTIFICATIONS: true,
1718
},
1819
});
1920

tests/performance/fixtures/index.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,24 @@ const createParentRecords = require('./create-parent-records');
2828
const { createComplexPayload: createComplexRecordsPayload } = require('./create-complex-payload.ts');
2929

3030
async function main() {
31-
const initialChildrenPayload = createParentPayload(19600);
32-
write('add-children-initial', initialChildrenPayload);
33-
write('add-children-final', createParentPayload(20000));
34-
const payloadWithRemoval = structuredClone(initialChildrenPayload);
35-
payloadWithRemoval.data.relationships.children.data.splice(0, 19000);
36-
payloadWithRemoval.included.splice(0, 19000);
37-
write('add-children-with-removal', payloadWithRemoval);
31+
// const initialChildrenPayload = createParentPayload(19600);
32+
// write('add-children-initial', initialChildrenPayload);
33+
// write('add-children-final', createParentPayload(20000));
34+
// const payloadWithRemoval = structuredClone(initialChildrenPayload);
35+
// payloadWithRemoval.data.relationships.children.data.splice(0, 19000);
36+
// payloadWithRemoval.included.splice(0, 19000);
37+
// write('add-children-with-removal', payloadWithRemoval);
3838

39-
write('destroy', createParentPayload(500, 50));
40-
write('relationship-materialization-simple', createCarsPayload(10000));
41-
write('relationship-materialization-complex', createParentRecords(200, 10, 20));
42-
write('unload', createParentPayload(500, 50));
43-
write('unload-all', createParentRecords(1000, 5, 10));
44-
write('unused-relationships', createParentPayload(500, 50));
45-
write('example-car', createCarsPayload(1));
46-
write('example-parent', createParentPayload(2, 2));
47-
write('basic-record-materialization', createParentRecords(10000, 2, 3));
48-
write('complex-record-materialization', await createComplexRecordsPayload(400));
39+
// write('destroy', createParentPayload(500, 50));
40+
// write('relationship-materialization-simple', createCarsPayload(10000));
41+
// write('relationship-materialization-complex', createParentRecords(200, 10, 20));
42+
// write('unload', createParentPayload(500, 50));
43+
// write('unload-all', createParentRecords(1000, 5, 10));
44+
// write('unused-relationships', createParentPayload(500, 50));
45+
// write('example-car', createCarsPayload(1));
46+
// write('example-parent', createParentPayload(2, 2));
47+
// write('basic-record-materialization', createParentRecords(10000, 2, 3));
48+
// write('complex-record-materialization', await createComplexRecordsPayload(400));
4949

5050
const initialBigM2M = createCarsPayload(100, 100);
5151
write('big-many-to-many', initialBigM2M);

tests/performance/vite.config.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export default defineConfig({
5959
negate_iife: false,
6060
sequences: 30,
6161
defaults: true,
62+
drop_debugger: false,
6263
arguments: false,
6364
keep_fargs: false,
6465
toplevel: false,

0 commit comments

Comments
 (0)