Skip to content

VM intrinsic trace event... #153

Closed
Closed
@jasnell

Description

@jasnell

To parallel the trace event support at the native layer, it would be helpful to have an intrinsic trace event facility accessible on the JS layer that we can use to efficiently instrument core js code. This does not need to be as expressive as the current set of macros (the ability to mark instants and span start/end should be sufficient).

The motivation for a vm intrinsic is the ability for the vm to optimize these as much as possible. We could implement these via a process binding but doing so certainly adds a runtime cost that an intrinsic should be able to avoid.

In most cases in core, the existing async_hooks/trace_events coverage actually covers the most interesting cases. It does not cover things like EventEmitter, however. Emitting an event, for instance, should cause a trace event to be emitted if trace events are enabled and should be a non-op with no runtime cost if not (e.g. have the compiler optimize the trace call out if v8 is not tracing).

ee.prototype.emit(event, ...args) {
  %trace_event_begin('node', 'eventemitter.emit', event, ...)
  // synchronously emit events
  %trace_event_end('node', 'eventemitter.emit', event, ...)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions