Skip to content

Conversation

@kwisniewski98
Copy link
Contributor

@kwisniewski98 kwisniewski98 commented Aug 29, 2022

Description

Adds --nodejs-mode=attachable, which injects DSO into already running NodeJS processes.

Related Issue

#418

Motivation and Context

At current state, resolving function addresses in NodeJS requires restarting each process, which might be very hard if not impossible in production. This features allows generating perf maps at runtime.

How Has This Been Tested?

Tested manually in container and as executable. NodeJS targets were tested in both same namespace as gprofiler and in separate namespace (docker container)

Checklist:

  • I have read the CONTRIBUTING document.
  • I have updated the relevant documentation.
  • I have added tests for new logic.

Copy link
Contributor

@Jongy Jongy left a comment

Choose a reason for hiding this comment

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

Looks very good @kwisniewski98 !

I left some comments (did not complete reviewing, will continue this week).

Please add a test like test_nodejs that uses the new attach mode. Also, the target nodejs app should not be started with the jitdump flags like we do now - we can add another Dockerfile, or just control the extra flags passed to node via a parameter when starting the container (so the existing test_nodejs can pass the flags; and your new test won't pass them)

@Jongy
Copy link
Contributor

Jongy commented Sep 1, 2022

I ran the CI

@Jongy
Copy link
Contributor

Jongy commented Sep 1, 2022

The attach causes this to be printed:

Debugger attached.
Debugger listening on ws://127.0.0.1:9229/9e541850-fa6d-4e4c-b566-97bf6c786205
For help, see: https://nodejs.org/en/docs/inspector

Not too bad but if it can be avoided somehow, that's best.

@kwisniewski98 kwisniewski98 force-pushed the node-attachable-profiler branch from 805a816 to 4f8382f Compare September 8, 2022 15:20
@kwisniewski98
Copy link
Contributor Author

The attach causes this to be printed:

Debugger attached.
Debugger listening on ws://127.0.0.1:9229/9e541850-fa6d-4e4c-b566-97bf6c786205
For help, see: https://nodejs.org/en/docs/inspector

Not too bad but if it can be avoided somehow, that's best.

I didn't find any way inside nodeJS to hide that message, Seems like it is printed unconditionally ref

@kwisniewski98 kwisniewski98 force-pushed the node-attachable-profiler branch from 4f8382f to 39993a2 Compare September 13, 2022 11:04
@kwisniewski98 kwisniewski98 requested a review from Jongy September 13, 2022 11:05
Copy link
Contributor

@Jongy Jongy left a comment

Choose a reason for hiding this comment

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

Finished 4th round

@Jongy
Copy link
Contributor

Jongy commented Sep 30, 2022

Reviewed again. Left 3 final comments. Please fix the lint errors as well, and the one comment from earlier that wasn't fixed yet as far as I can tell, and we're good to merge this :)

@kwisniewski98 kwisniewski98 requested a review from Jongy October 3, 2022 11:03
Jongy
Jongy previously approved these changes Oct 6, 2022
Copy link
Contributor

@Jongy Jongy left a comment

Choose a reason for hiding this comment

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

LGTM.

Lint errors are what I described in #517 (comment), so I ignore them. I will merge after tests pass.

@Jongy
Copy link
Contributor

Jongy commented Oct 6, 2022

@kwisniewski98 only the Dockerifle lint error seems relevant -

/home/runner/work/gprofiler/gprofiler/pyi.Dockerfile:319 SC2086 info: Double quote to prevent globbing and word splitting.

@Jongy
Copy link
Contributor

Jongy commented Oct 6, 2022

Also, you can merge from master, I fixed the flake8 issue

@kwisniewski98
Copy link
Contributor Author

@kwisniewski98 only the Dockerifle lint error seems relevant -

/home/runner/work/gprofiler/gprofiler/pyi.Dockerfile:319 SC2086 info: Double quote to prevent globbing and word splitting.

I've added ignore for that, double quote seems to be not working.

@Jongy Jongy merged commit 3426d2f into intel:master Oct 8, 2022
@Jongy
Copy link
Contributor

Jongy commented Oct 8, 2022

At last :) Congrats @kwisniewski98 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants