-
Notifications
You must be signed in to change notification settings - Fork 68
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
metadata: Add runtime labels for NodeJS #2233
Conversation
Signed-off-by: Kemal Akkoyun <[email protected]>
cache.Add(pid, nil) | ||
return nil, nil | ||
} | ||
cache.Add(pid, rt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rt
can be an error, caching errors, is this intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rt
can be nil but not an error. Why do you think so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, should have been nil
, not an error! Just wanted to make sure that caching the "unhappy path" was something we wanted to do
|
||
const semVerRegex string = `v([0-9]+)(\.[0-9]+)(\.[0-9]+)` + | ||
`(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?` + | ||
`(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Perhaps removing everything after -
, +
,
and trimming a leading v
and spaces could be easier to understand and evolve? This is a major nit though, I don't mind the approach and you added awesome tests already!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can be more precise about matching, but we can't be loose. Removing v
gives false matches (I've tested, and we get things like `127.0.0.1). We must be strict since we search the whole space of constant strings. I wish there were a more straightforward way. We could evolve the approach when we know more.
type Type string | ||
|
||
type Runtime struct { | ||
Type Type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Maybe "name" is clearer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also planning to merge or embed this to the Interpreter
type. I'll iterate on it in subsequent PRs.
var lastError error | ||
for _, sec := range ef.Sections { | ||
if sec.Name == ".data" || sec.Name == ".rodata" { | ||
data, err := sec.Data() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perf nit: This might allocate a new buffer, I don't expect it to be very large, but might be worth checking some node js executables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are spot on I have already an optimization lined up to optimize this part. Stay tuned ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!! Mostly left some nits and questions to understand things a bit better.
Another thing I wanted to ask is where can I see the values retrieved in the pprof profile, I couldn't spot anything 😢 .
One more thing I noticed is that the provided file, https://github.com/nodejs/node/blob/36ecf8ca656063060421e5b5440ac056f3a51e20/src/node_version.h will only run in the preprocessor, so the version inclusion in the binary must happen elsewhere. Could be good to know exactly where it's embedded in case this shows us some opportunity to do things differently.
On this last point:
|
Thanks for the review ❤️
This is my bad. For whatever reason, I thought we had the labels in there. I'm gonna add a screenshot of the labels. |
Shots are the descriptions. |
This is how I discovered them 😊 I don't know the exact mechanism of how compilers decide to embed these constants. |
Signed-off-by: Kemal Akkoyun [email protected]
The version information set in here https://github.com/nodejs/node/blob/36ecf8ca656063060421e5b5440ac056f3a51e20/src/node_version.h so they end up in
.data
or.rodata
sections.Tested against multiple versions https://pprof.me/75e08cdd91547a303b82065b9281bf1e