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

Tracing: Add lttng support for tracing on Linux. #702

Closed
wants to merge 5 commits into from

Conversation

GlenTiki
Copy link
Contributor

@GlenTiki GlenTiki commented Feb 3, 2015

This commit adds the ability to enable userspace tracing with lttng
in io.js. It adds tracepoints for all the equivalent dtrace and ETW
tracepoints. To use these tracepoints enable --with-lttng on linux.

@GlenTiki
Copy link
Contributor Author

GlenTiki commented Feb 3, 2015

So, this PR goes off without a hike, except there was a failing test - test/sequential/test-util-debug.js
To make it work nicely with Lttng I had to pass it the HOME env variable, because Lttng is weird about it. How do you guys want to approach the test? Thanks.

@GlenTiki
Copy link
Contributor Author

GlenTiki commented Feb 3, 2015

To build with lttng probes on, you need to have installed lttng as described here: Lttng docs

I would like to document this feature, but documentation is lacking on the tracing side of things, so I cannot work from example. How would you guys like for us to document this?

parser.add_option('--with-lttng',
action='store_true',
dest='with_lttng',
help='build with Lttng (Only available to Linux)')
Copy link
Contributor

Choose a reason for hiding this comment

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

Can it default to 'on' on Linux, or will that break Linuxen that don't have LTTNG?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It cannot default to 'on' on Linux as the library won't be accessible to the compiler if its not installed.

@bnoordhuis
Copy link
Member

The PR more or less LGTM. However:

  • Some of the new files have a lot of style errors that I would like to see fixed. If unsure what style to use, let me know and I'll call it out.
  • There is a lot of duplication with the dtrace code. I urge you to try and reduce that.

@GlenTiki
Copy link
Contributor Author

GlenTiki commented Feb 3, 2015

@bnoordhuis How would I just test the style without running make test, before I finish my commit?

Also, some of the TRACEPOINT_EVENT macros will throw style errors as that is the way the macro is supposed to be, without the commas.

The duplication I can try to reduce, but I wouldn't be very comfortable with it.

@GlenTiki
Copy link
Contributor Author

GlenTiki commented Feb 4, 2015

The issues with style was fixed, I had to add two of the files to the cpplint exclude list in the makefile. Both dtrace and ETW have similar solutions for their files. Trace related code seems to break linters in general. I fixed all the style errors in the files however, the only errors are relating to defined headers and not having a header guard at the top of the file, which I didn't do as that is not the lttng way of doing the tracepoint files.

@GlenTiki
Copy link
Contributor Author

GlenTiki commented Feb 4, 2015

On the code duplication, how would you recommend I approach it, so to make it more generic?

@GlenTiki GlenTiki mentioned this pull request Feb 5, 2015
macro LTTNG_HTTP_SERVER_REQUEST(x) = ;
macro LTTNG_HTTP_SERVER_RESPONSE(x) = ;
macro LTTNG_NET_SERVER_CONNECTION(x) = ;
macro LTTNG_NET_STREAM_END(x) = ;
Copy link
Contributor

Choose a reason for hiding this comment

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

Missed a file ending in the cleanup commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixing now... the python files weren't linted. Cheers (Y)

@mikeal
Copy link
Contributor

mikeal commented Feb 5, 2015

@groundwater you might be interested in this: getting this to a place where the trace endpoint is abstracted rather than duplicated between lttng and dtrace.

@rmg
Copy link
Contributor

rmg commented Feb 5, 2015

👍 to merge after one last newline nit is fixed. The deduplication seems like it could easily turn into a refactoring into generic tracing points, which makes sense as a separate PR.

@Qard
Copy link
Member

Qard commented Feb 5, 2015

I agree with @rmg, LGTM.

@sam-github
Copy link
Contributor

@trevnorris you mentioned being concerned the trace stubs were getting compiled into a no-op function, but they aren't, they are completely remove by js2c: node -p "process.binding('natives')._http_server" | grep DTRACE

This commit adds the ability to enable userspace tracing with lttng
in io.js. It adds tracepoints for all the equivalent dtrace and ETW
tracepoints. To use these tracepoints enable --with-lttng on linux.
@GlenTiki
Copy link
Contributor Author

GlenTiki commented Feb 5, 2015

Okay, I've squashed all the commits.

What next? Are we making the generic tracepoints into another PR, as it may break existing Dtrace probes/api? Or should we proceed as @thlorenz said, and make the configure simply remove the noop/tracepoints for compilation? This could be a bigish project/refactor.

@Qard
Copy link
Member

Qard commented Feb 5, 2015

Leave the big-ish ideas for later. We still need to decide what a generic tracepoint API would look like. :)


Environment* env = Environment::GetCurrent(args);
HandleScope scope(env->isolate());
Local<Object> arg0 = Local<Object>::Cast(args[0]);
Copy link
Member

Choose a reason for hiding this comment

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

Caveat emptor: Cast() does the wrong thing when someone does this.connection = null. There should be a if (!args[0]->IsObject()) return guard a few lines up. You probably want to do it after the NODE_HTTP_SERVER_REQUEST_ENABLED check because that check is presumably cheaper than calling args[0]->IsObject().

Side note: you don't need the HandleScope. JS -> C++ callbacks have an implicit HandleScope.

return;

Environment* env = Environment::GetCurrent(args);
HandleScope scope(env->isolate());
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is being called from JS then it doesn't need the HandleScope.

@trevnorris
Copy link
Contributor

@thekemkid nice work here.

@GlenTiki
Copy link
Contributor Author

GlenTiki commented Feb 6, 2015

@trevnorris @bnoordhuis I did some more work, I'll commit it so you can review. Its unfinished, I haven't fixed the c style casting, and the forwarded_for const char* needs work, I think.

@mikeal mikeal mentioned this pull request Feb 7, 2015
bnoordhuis pushed a commit that referenced this pull request Feb 9, 2015
This commit adds the ability to enable userspace tracing with lttng
in io.js. It adds tracepoints for all the equivalent dtrace and ETW
tracepoints. To use these tracepoints enable --with-lttng on linux.

PR-URL: #702
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Ryan Graham <[email protected]>
Reviewed-By: Stephen Belanger <[email protected]>
@bnoordhuis
Copy link
Member

Landed in 5e825d1, thanks Glen. We can tie up the loose ends later.

@bnoordhuis bnoordhuis closed this Feb 9, 2015
@rvagg rvagg mentioned this pull request Feb 11, 2015
rvagg added a commit that referenced this pull request Feb 11, 2015
Notable changes:

* stream:
  - Simpler stream construction, see
    nodejs/readable-stream#102 for details.
    This extends the streams base objects to make their constructors
    accept default implementation methods, reducing the boilerplate
    required to implement custom streams. An updated version of
    readable-stream will eventually be released to match this change
    in core. (@sonewman)
* dns:
  - `lookup()` now supports an `'all'` boolean option, default to
    `false` but when turned on will cause the method to return an
    array of *all* resolved names for an address, see,
    #744 (@silverwind)
* assert:
  - Remove `prototype` property comparison in `deepEqual()`,
    considered a bugfix, see #636
    (@vkurchatkin)
  - Introduce a `deepStrictEqual()` method to mirror `deepEqual()`
    but performs strict equality checks on primitives, see
    #639 (@vkurchatkin)
* **tracing**:
  - Add LTTng (Linux Trace Toolkit Next Generation) when compiled
    with the  `--with-lttng` option. Trace points match those
    available for DTrace and ETW.
    #702 (@thekemkid)
* npm upgrade to 2.5.1
* **libuv** upgrade to 1.4.0
* Add new collaborators:
  - Aleksey Smolenchuk (@lxe)
  - Shigeki Ohtsu (@shigeki)
@ChALkeR ChALkeR mentioned this pull request Feb 24, 2018
2 tasks
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.

8 participants