Skip to content

Commit d7a9de9

Browse files
authored
Heap snapshot diffs for accurate memtest leak detection (#1372)
1 parent e9c2cd1 commit d7a9de9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+13642
-296
lines changed

.github/workflows/memtest.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ jobs:
5757
with:
5858
key: docker-images-${{ runner.os }}-${{ steps.hash-docker-images.outputs.result }}
5959
- name: Test
60-
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
6160
env:
6261
E2E_GATEWAY_RUNNER: ${{matrix.e2e_runner}}
62+
run: yarn test:mem ${{matrix.test_name}}
63+
- name: Upload heap snapshots
64+
if: failure()
65+
uses: actions/upload-artifact@v4
6366
with:
64-
timeout_minutes: 30
65-
max_attempts: 5
66-
command: yarn test:mem ${{matrix.test_name}}
67-
# TODO: publish heap allocation sampling profile to artifact
67+
name: ${{matrix.test_name}}-heap-snapshots
68+
path: e2e/${{matrix.test_name}}/*.heapsnapshot

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
node_modules/
22
.DS_Store
33
dist/
4+
!/internal/heapsnapshot/dist/
45
bundle/
56
.yarn/*
67
!.yarn/patches

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ __generated__
1313
/e2e/config-syntax-error/gateway.config.ts
1414
/e2e/config-syntax-error/custom-resolvers.ts
1515
CHANGELOG.md
16+
/internal/heapsnapshot/dist/

DEPS_RESOLUTIONS_NOTES.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,3 @@ Here we collect reasons and write explanations about why some resolutions or pat
1414
### vitest-tsconfig-paths
1515

1616
1. Resolve tsconfig paths in modules that have been [inlined](https://vitest.dev/config/#server-deps-inline).
17-
18-
### @memlab/core
19-
20-
1. Define package.json#export for `@memlab/core/Types`
21-
1. Define package.json#export for `@memlab/core/Utils`

e2e/auto-type-merging/auto-type-merging.memtest.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ memtest(
2828
}
2929
}
3030
`,
31-
expectedHeavyFrame: (frame) =>
32-
// allocates a lot but all is freed confirmed through heap snapshot
33-
frame.name === 'set' &&
34-
frame.callstack.some((frame) => frame.name === 'subschemaExecutor'),
3531
},
3632
async () =>
3733
gateway({

e2e/federation-subscriptions-passthrough/federation-subscriptions-passthrough.memtest.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ describe('upstream subscriptions via websockets', () => {
2323
}
2424
}
2525
`,
26-
expectedHeavyFrame: (frame) =>
27-
// allocates a lot but all is freed confirmed through heap snapshot
28-
frame.name === 'set' &&
29-
frame.callstack.some(
30-
(frame) =>
31-
frame.name.includes('stitchingInfo') ||
32-
frame.name.includes('batch'),
33-
),
3426
},
3527
async () =>
3628
gateway({

e2e/interface-additional-resolvers/interface-additional-resolvers.memtest.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ memtest(
2424
}
2525
}
2626
`,
27-
expectedHeavyFrame: (frame) =>
28-
// allocates a lot but all is freed confirmed through heap snapshot
29-
frame.name === 'set' &&
30-
frame.callstack.some((frame) => frame.name === 'createBatchingExecutor'),
3127
},
3228
async () =>
3329
await gateway({

internal/heapsnapshot/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Fork of [ChromeDevTools/devtools-frontend/[...]/heap_snapshot_worker](https://github.com/ChromeDevTools/devtools-frontend/blob/dd60dc9c8add93357dcffcfc3e2a9e5a31864413/front_end/entrypoints/heap_snapshot_worker) without the browser requirements, adapted for Node, with utilities for quick setup, parsing and analysis.
2+
3+
Please make sure to build and commit any changes done inside this package to allow for "buildless" testing.
4+
5+
This is the only package in the project that is used built (it's not listed in `tsconfig.json#paths`) because it uses worker threads and they need Node-ready JavaScript.

0 commit comments

Comments
 (0)