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: add support for v8 version 10+ #83

Merged
merged 2 commits into from
Dec 7, 2022

Conversation

dios-david
Copy link
Contributor

After upgrading from Node 16 to Node 18 I noticed that I get some undefineds in the gctype label in my prometheus metrics:

koa_nodejs_gc_runs_total{gctype="Scavenge"} 3618
koa_nodejs_gc_runs_total{gctype="WeakPhantom"} 482
koa_nodejs_gc_runs_total{gctype="IncrementalMarking"} 241
koa_nodejs_gc_runs_total{gctype="undefined"} 2877

After digging into this a bit, I found out that the GCType enum was changed in v8 in version 10 in this PR (check deps/v8/include/v8-callbacks.h):

Before:
https://github.com/nodejs/node/blob/554fa24916c5c6d052b51c5cee9556b76489b3f7/deps/v8/include/v8.h#L6137-L6144

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

After:
https://github.com/nodejs/node/blob/main/deps/v8/include/v8-callbacks.h#L150-L159

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

I made some changes to be able to support both 10+ and <10 versions of v8 with proper GC type mappings.

Let me know what you think.

@dios-david
Copy link
Contributor Author

@SimenB fyi

Copy link
Owner

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@SimenB SimenB changed the title Adding support for v8 version 10+ feat: add support for v8 version 10+ Dec 7, 2022
@SimenB SimenB merged commit 9977181 into SimenB:master Dec 7, 2022
@SimenB
Copy link
Owner

SimenB commented Dec 7, 2022

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.

2 participants