-
Notifications
You must be signed in to change notification settings - Fork 14
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 a fuse to speed up the case where no resource is present #59
Conversation
It doesn't make sense to test just the resource injection part on a program that doesn't use the runtime API by calling any of the functions inside postject-api.h. Refs: #59 (comment) Signed-off-by: Darshan Sen <raisinten@gmail.com>
It doesn't make sense to test just the resource injection part on a program that doesn't use the runtime API by calling any of the functions inside postject-api.h. Refs: #59 (comment) Signed-off-by: Darshan Sen <raisinten@gmail.com> Signed-off-by: Darshan Sen <raisinten@gmail.com>
a61f9a9
to
f8bb078
Compare
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.
since we're trying to enable others to implement either side of the process usign tools that are not postject, we should document this.
using rfc lanuage, is this going to be a MAY
? so extract implementation have to work without it, but have to consider it when it is present?
I think the other way around - if the run-time implementation ( |
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.
Could the commit message be tweaked? This doesn't speed up resource access, it speeds up the case where there is no resource present. If anything it slows down resource access with an extra check. 😄
Also, I think it would be nice if the name of the sentinel was an option (with default value) for the injection side. I tried to make all references to the name Postject configurable so any user could customize it for various reasons.
@RaisinTen any update here? 👀 |
Fixes: #58 Signed-off-by: Darshan Sen <raisinten@gmail.com>
Fixes the following error: ``` In file included from /root/project/test/test.c:5: /root/project/test/../dist/postject-api.h:38:15: error: unknown type name 'bool' 38 | static inline bool postject_has_resource() { | ^~~~ ``` Refs: https://app.circleci.com/pipelines/github/postmanlabs/postject/195/workflows/ba6a05d2-1359-4876-a165-68dea6536c2b/jobs/1551?invite=true#step-110-676 Signed-off-by: Darshan Sen <raisinten@gmail.com>
Maybe that will fix this error: ``` Error: Could not find the sentinel POSTJECT_SENTINEL_fce680ab2cc467b6e072b8b5df1996b2: in the binary at inject (dist/api.js:5147:11) at async Context.<anonymous> (file:///home/circleci/project/test/cli.mjs:138:7) ``` Refs: https://app.circleci.com/pipelines/github/postmanlabs/postject/197/workflows/741145b6-e19e-4d09-b995-49eebc237962/jobs/1580 Signed-off-by: Darshan Sen <raisinten@gmail.com>
Signed-off-by: Darshan Sen <raisinten@gmail.com>
Signed-off-by: Darshan Sen <raisinten@gmail.com>
f8bb078
to
a8c52d6
Compare
Signed-off-by: Darshan Sen <raisinten@gmail.com>
Refs: nodejs/postject#59 Signed-off-by: Darshan Sen <raisinten@gmail.com>
I've imported this patch in nodejs/node#45038 and there are no related errors. PTAL everyone! |
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.
Overall LGTM, although I think it would be more ergonomic if the :0
suffix was internalized as an implementation detail and only POSTJECT_SENTINEL_fce680ab2cc467b6e072b8b5df1996b2
was exposed to users. Then there wouldn't need to be a validation check for the CLI option value - any string value would be valid. Would also help prevent issues since there is no validation on the macro side.
I believe this could be accomplished in postject-api.h
with something like:
static inline bool postject_has_resource() {
static const volatile char* sentinel = POSTJECT_SENTINEL_FUSE ":0";
return sentinel[sizeof(POSTJECT_SENTINEL_FUSE)] == '1';
}
src/cli.js
Outdated
@@ -52,6 +53,11 @@ if (require.main === module) { | |||
"Name for the Mach-O segment", | |||
"__POSTJECT" | |||
) | |||
.option( | |||
"--sentinel-fuse <sentinel_fuse>", | |||
"Sentinel fuse", |
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.
Could this be expanded to state the intended usage is for resource presence detection? I also wonder if the option name should be less generic, in case a different sentinel value is added in the future.
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.
Done! I'm open to better names if you have a suggestion
Refs: #59 (review) Refs: #59 (comment) Signed-off-by: Darshan Sen <raisinten@gmail.com>
Refs: #59 (review) Refs: #59 (comment) Signed-off-by: Darshan Sen <raisinten@gmail.com>
1adb4cd
to
6da6e04
Compare
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.
@RaisinTen, changes look good (thanks!), but the tests still have :0
in their usages. Once that's cleaned up I'm good to merge.
Refs: #59 (review) Signed-off-by: Darshan Sen <raisinten@gmail.com>
@dsanders11 Good catch, done! Been a while since we released stuff. I'm probably gonna release |
@RaisinTen, sounds good to me. Merging this PR is blocked by the old CircleCI status check being required, and I don't have perms to remove (or override) that check so I'll defer to you on merging, but LGTM. 👍 |
Fixes: #58
Signed-off-by: Darshan Sen raisinten@gmail.com