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

test/integration: Add NodeJS Integration tests #2512 #2598

Closed

Conversation

joeyleeeeeee97
Copy link

for #2512

@joeyleeeeeee97 joeyleeeeeee97 requested a review from a team as a code owner March 6, 2024 05:04
@joeyleeeeeee97
Copy link
Author

@kakkoyun Only "17": "17-alpine" image for now, please tell me what to add here

Copy link
Member

@kakkoyun kakkoyun left a comment

Choose a reason for hiding this comment

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

Awesome work 🎉 Thanks a lot for taking care of this!

It's very close but it's not there yet. I have commented inline what we need probably.

test/integration/nodejs/nodejs_test.go Outdated Show resolved Hide resolved
test/integration/nodejs/testdata/cpu_hog.js Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
test/integration/nodejs/nodejs_test.go Outdated Show resolved Hide resolved
FileMode: 0o700,
},
},
Cmd: []string{"node", "/cpu_hug.js"},
Copy link
Member

Choose a reason for hiding this comment

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

And we need special flags until we implement a dedicated unwinder.

This should help you https://www.polarsignals.com/docs/nodejs

Copy link
Author

@joeyleeeeeee97 joeyleeeeeee97 Mar 7, 2024

Choose a reason for hiding this comment

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

The aggregatedStack I got now was [[JS:~ JS:~executeUserEntryPoint JS:~Module._load JS:~Module.load JS:~Module._extensions..js JS:~Module._compile JS:*]]. Not complete.

    nodejs_test.go:170: The stack [LazyCompile:*fib] is not contained in any of [[JS:~ JS:~executeUserEntryPoint JS:~Module._load JS:~Module.load JS:~Module._extensions..js JS:~Module._compile JS:*]]

@kakkoyun should I assert on this?

Copy link
Member

Choose a reason for hiding this comment

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

Do you see this stack after you added those flags?

Copy link
Author

@joeyleeeeeee97 joeyleeeeeee97 Mar 8, 2024

Choose a reason for hiding this comment

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

no. this is the output after I added --perf-basic-prof-only-functions --interpreted-frames-native-stack

Let me add this test in our github check so we can see this

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Author

@joeyleeeeeee97 joeyleeeeeee97 Mar 11, 2024

Choose a reason for hiding this comment

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

This is because node js lazyCompiling and make the loop anonymous, I modified the test and tried assert on runLoop instead

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I suspect nodejs is inlining things. Could we disable inlining?

Copy link
Author

Choose a reason for hiding this comment

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

OK. let me test this without inlining

@joeyleeeeeee97 joeyleeeeeee97 force-pushed the nodejs_integration branch 7 times, most recently from 7521280 to a1077f4 Compare March 8, 2024 03:15
@joeyleeeeeee97 joeyleeeeeee97 force-pushed the nodejs_integration branch 4 times, most recently from e63f431 to 4b48da9 Compare March 11, 2024 20:11

- name: Integration Tests (Nodejs)
if: ${{ always() }}
continue-on-error: true
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be the case for NodeJS. We did this for Java because it hasn't been implemented fully yet.

Copy link
Author

Choose a reason for hiding this comment

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

ok

"JS:~Module._extensions..js",
"JS:~Module._compile",
"JS:~",
"JS:*runLoop",
Copy link
Member

Choose a reason for hiding this comment

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

Maybe NodeJS is inlining these functions. Could we somehow disable inlining for the tests? Or a specific function?

Copy link
Author

Choose a reason for hiding this comment

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

OK

Copy link
Author

Choose a reason for hiding this comment

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

There is not a single option to disable inlining optimizations, I am using --no-opt to disable all optimizations.
Now I can see the expected whole stack.

Copy link
Author

Choose a reason for hiding this comment

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

@kakkoyun , please take another look

@kakkoyun
Copy link
Member

@joeyleeeeee97 Thanks again for taking care of this and bearing with me. But we need to make sure that unwinding works as expected, so hang tight for a little longer.

We need to make sure we see the expected stack in the tests.

@joeyleeeeeee97
Copy link
Author

joeyleeeeeee97 commented Mar 15, 2024

@kakkoyun You are right on this.

node --trace-opt cpu_hog.js
[marking 0x1c745a9658a1 <JSFunction cpu (sfi = 0x933e0017551)> for optimization to TURBOFAN, ConcurrencyMode::kConcurrent, reason: hot and stable]
[compiling method 0x1c745a9658a1 <JSFunction cpu (sfi = 0x933e0017551)> (target TURBOFAN), mode: ConcurrencyMode::kConcurrent]
[completed compiling 0x1c745a9658a1 <JSFunction cpu (sfi = 0x933e0017551)> (target TURBOFAN) - took 0.041, 0.375, 0.000 ms]
[completed optimizing 0x1c745a9658a1 <JSFunction cpu (sfi = 0x933e0017551)> (target TURBOFAN)]
[marking 0x1c745a9658e1 <JSFunction c1 (sfi = 0x933e00175a9)> for optimization to TURBOFAN, ConcurrencyMode::kConcurrent, reason: hot and stable]
[marking 0x1c745a965921 <JSFunction b1 (sfi = 0x933e0017601)> for optimization to TURBOFAN, ConcurrencyMode::kConcurrent, reason: hot and stable]
[marking 0x1c745a965961 <JSFunction a1 (sfi = 0x933e0017659)> for optimization to TURBOFAN, ConcurrencyMode::kConcurrent, reason: hot and stable]
[marking 0x1c745a9659a1 <JSFunction runLoop (sfi = 0x933e00176b1)> for optimization to TURBOFAN, ConcurrencyMode::kConcurrent, reason: hot and stable]
[compiling method 0x1c745a965961 <JSFunction a1 (sfi = 0x933e0017659)> (target TURBOFAN), mode: ConcurrencyMode::kConcurrent]
[compiling method 0x1c745a965921 <JSFunction b1 (sfi = 0x933e0017601)> (target TURBOFAN), mode: ConcurrencyMode::kConcurrent]
[compiling method 0x1c745a9658e1 <JSFunction c1 (sfi = 0x933e00175a9)> (target TURBOFAN), mode: ConcurrencyMode::kConcurrent]
[completed compiling 0x1c745a965921 <JSFunction b1 (sfi = 0x933e0017601)> (target TURBOFAN) - took 0.000, 0.250, 0.000 ms]
[completed optimizing 0x1c745a965921 <JSFunction b1 (sfi = 0x933e0017601)> (target TURBOFAN)]
[completed compiling 0x1c745a9658e1 <JSFunction c1 (sfi = 0x933e00175a9)> (target TURBOFAN) - took 0.000, 0.250, 0.000 ms]
[completed optimizing 0x1c745a9658e1 <JSFunction c1 (sfi = 0x933e00175a9)> (target TURBOFAN)]
[completed compiling 0x1c745a965961 <JSFunction a1 (sfi = 0x933e0017659)> (target TURBOFAN) - took 0.000, 0.334, 0.000 ms]
[completed optimizing 0x1c745a965961 <JSFunction a1 (sfi = 0x933e0017659)> (target TURBOFAN)]
[compiling method 0x1c745a9659a1 <JSFunction runLoop (sfi = 0x933e00176b1)> (target TURBOFAN) OSR, mode: ConcurrencyMode::kConcurrent]
[completed compiling 0x1c745a9659a1 <JSFunction runLoop (sfi = 0x933e00176b1)> (target TURBOFAN) OSR - took 0.000, 0.292, 0.041 ms]
[completed optimizing 0x1c745a9659a1 <JSFunction runLoop (sfi = 0x933e00176b1)> (target TURBOFAN) OSR]

Now I added --no-opt on this test.

Also

In the context of V8 engine, JS:*runLoop and JS:^runLoop both represent identifiers for JavaScript functions, but they have different meanings:

JS:*runLoop: This identifier typically denotes a JavaScript function that has been optimized. The * symbol indicates that the function has been optimized and may have been compiled to machine code. When you see an identifier like JS:*functionName, it means that the function has been optimized by the V8 engine.

JS:^runLoop: This identifier typically denotes a JavaScript function that has not been optimized. The ^ symbol indicates that the function has not been optimized. When you see an identifier like JS:^functionName, it means that the function has not been optimized by the V8 engine.

@joeyleeeeeee97
Copy link
Author

@brancz Could you help check this?

Copy link
Member

@kakkoyun kakkoyun left a comment

Choose a reason for hiding this comment

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

LGTM. Happy to merge it when the CI is green.

@kakkoyun
Copy link
Member

AMD64 tests are passing for 19, 20. 18 has a different stack trace. Maybe we should have a different assertion for that.

ARM64 failures are somewhat known, so I'd be happy to merge if we can fix the issue with 18 on amd64.

@brancz
Copy link
Member

brancz commented Aug 8, 2024

Outdated since #2958

@brancz brancz closed this Aug 8, 2024
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