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

Wait a major task after triggering GC to measure memory #3962

Merged
merged 1 commit into from
Apr 6, 2023

Conversation

andrewiggins
Copy link
Member

window.gc synchronously triggers one Major GC. However that MajorGC asynchronously triggers additional MajorGCs until the usedJSHeapSizeBefore and usedJSHeapSizeAfter are the same. Here, we'll wait a moment (i.e. a major task using postMessage) for some (hopefully all) additional GCs to finish before measuring the memory.

Locally, i'm getting very different memory results than what is reported in this PR so attempting this benchmarking fix to hopefully normalize and reduce noise seen in differences across different machines and environments.
@coveralls
Copy link

Coverage Status

Coverage: 99.699%. Remained the same when pulling 1345125 on improve-bench-memory-measuring into e97da39 on master.

@github-actions
Copy link

github-actions bot commented Apr 6, 2023

Size Change: 0 B

Total Size: 54.3 kB

ℹ️ View Unchanged
Filename Size Change
compat/dist/compat.js 3.91 kB 0 B
compat/dist/compat.module.js 3.84 kB 0 B
compat/dist/compat.umd.js 3.98 kB 0 B
debug/dist/debug.js 3 kB 0 B
debug/dist/debug.module.js 3.01 kB 0 B
debug/dist/debug.umd.js 3.08 kB 0 B
devtools/dist/devtools.js 232 B 0 B
devtools/dist/devtools.module.js 240 B 0 B
devtools/dist/devtools.umd.js 315 B 0 B
dist/preact.js 4.21 kB 0 B
dist/preact.min.js 4.24 kB 0 B
dist/preact.min.module.js 4.24 kB 0 B
dist/preact.min.umd.js 4.26 kB 0 B
dist/preact.module.js 4.23 kB 0 B
dist/preact.umd.js 4.27 kB 0 B
hooks/dist/hooks.js 1.53 kB 0 B
hooks/dist/hooks.module.js 1.56 kB 0 B
hooks/dist/hooks.umd.js 1.61 kB 0 B
jsx-runtime/dist/jsxRuntime.js 360 B 0 B
jsx-runtime/dist/jsxRuntime.module.js 326 B 0 B
jsx-runtime/dist/jsxRuntime.umd.js 441 B 0 B
test-utils/dist/testUtils.js 442 B 0 B
test-utils/dist/testUtils.module.js 444 B 0 B
test-utils/dist/testUtils.umd.js 526 B 0 B

compressed-size-action

@andrewiggins
Copy link
Member Author

FYI, microtask is too quick and setTimeout can add extra wait time so I went with post message as it seems to immediately fire after GC has stabilized, judging from the browser traces I looked at.

@andrewiggins andrewiggins merged commit a9d9c64 into master Apr 6, 2023
@andrewiggins andrewiggins deleted the improve-bench-memory-measuring branch April 6, 2023 06:46
@JoviDeCroock JoviDeCroock mentioned this pull request May 13, 2023
JoviDeCroock added a commit that referenced this pull request Jan 22, 2024
JoviDeCroock added a commit that referenced this pull request Jan 23, 2024
* backport #3968

* backport #3964

* backport #3997

* backport #3995

* backport #3970

* backport #3971

* backport #3990

* backport #3963

* backport #3962

* backport #3960

* backport #3956

* Revert "backport #3963"

This reverts commit 86a372a.

* define public type

* fix newline issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants