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

Nested GC callback #44046

Closed
theanarkh opened this issue Jul 29, 2022 · 4 comments
Closed

Nested GC callback #44046

theanarkh opened this issue Jul 29, 2022 · 4 comments

Comments

@theanarkh
Copy link
Contributor

theanarkh commented Jul 29, 2022

Version

v19.0.0-pre

Platform

Darwin Kernel Version 20.3.0

Subsystem

perf_hooks

What steps will reproduce the bug?

The example code that triggers this bug has not been found. I found this bug in my project. I add some logs into node_perf.cc.

image

and found the log as follows.

image

This will make the value of gc duration inaccurate (node_perf.cc). The 4 and 16 is defined in GCType.

enum GCType {
  kGCTypeScavenge = 1 << 0,
  kGCTypeMinorMarkCompact = 1 << 1,
  kGCTypeMarkSweepCompact = 1 << 2,
  kGCTypeIncrementalMarking = 1 << 3,
  kGCTypeProcessWeakCallbacks = 1 << 4,
};

How often does it reproduce? Is there a required condition?

it is difficult to reproduce currently.

What is the expected behavior?

it should be 4 4 16 16.

What do you see instead?

4 16 16 4.

Additional information

cc @bnoordhuis

@bnoordhuis
Copy link
Member

Weak phantom callbacks run during the prologue or epilogue of major GCs1 so the output you're seeing is not unexpected, just an artifact of how V8 implements them.

1 The relevant method is Heap::CollectGarbage() in deps/v8/src/heap/heap.cc.

@theanarkh
Copy link
Contributor Author

Thanks. So is it wrong to calculate the elapsed time for each GC type through prologue and epilogue callbacks ?

@bnoordhuis
Copy link
Member

Yes. No. Depends on whether you count kGCTypeProcessWeakCallbacks as a separate type. :-)

@theanarkh
Copy link
Contributor Author

Get it ! Thank you very much !

nodejs-github-bot pushed a commit that referenced this issue Aug 10, 2022
PR-URL: #44058
Refs: #44046
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
danielleadams pushed a commit that referenced this issue Aug 16, 2022
PR-URL: #44058
Refs: #44046
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
ruyadorno pushed a commit that referenced this issue Aug 23, 2022
PR-URL: #44058
Refs: #44046
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
targos pushed a commit that referenced this issue Sep 5, 2022
PR-URL: #44058
Refs: #44046
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Fyko pushed a commit to Fyko/node that referenced this issue Sep 15, 2022
PR-URL: nodejs#44058
Refs: nodejs#44046
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
juanarbol pushed a commit that referenced this issue Oct 10, 2022
PR-URL: #44058
Refs: #44046
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
juanarbol pushed a commit that referenced this issue Oct 11, 2022
PR-URL: #44058
Refs: #44046
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
guangwong pushed a commit to noslate-project/node that referenced this issue Jan 3, 2023
PR-URL: nodejs/node#44058
Refs: nodejs/node#44046
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
guangwong pushed a commit to noslate-project/node that referenced this issue Jan 3, 2023
PR-URL: nodejs/node#44058
Refs: nodejs/node#44046
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
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

No branches or pull requests

2 participants