GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||
GeezerVison is showing github.com — Report event dispatches to the dependency graph as emitEvent by Domiii · Pull Request #242 · replayio/node Conversation
|
| run | emit ×1e6 | dispatchEvent ×1e5 |
|---|---|---|
| recorded | 78 | 89 |
recorded, RECORD_REPLAY_DISABLE_FEATURES=["dependency-graph"] |
59 | 82 |
unrecorded (RECORD_REPLAY_DONT_RECORD=1), main nodejs#596, median of 5 |
23 | 17 |
| unrecorded, nodejs#603, median of 5 | 24 | 15 |
emit and about 70 ns more per dispatchEvent.dependency-graph/await-fetch in test-node-recording, ms:| build | case time |
|---|---|
| main nodejs#596, node#240 only | 2718 |
| nodejs#602, this PR | 2697 |
| nodejs#603, top of the stack | 2607 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The listener calls of EventEmitter#emit and of EventTarget dispatches run
in a dependency execution of a dispatchEvent{type} node, the kind Chromium
reports synchronous event dispatch with. So the work a listener schedules
depends on the dispatch, and the chain continues to the callback that
emitted it.
- Sites: EventEmitter.prototype.emit once a handler exists, and
EventTarget's kHybridDispatch once listeners exist, which dispatchEvent,
NodeEventTarget#emit and MessagePort messages share. The calls end in a
finally.
- The depths before each dispatch begins stay on a C++ stack. An end drops
the dispatches an outer unwind already ended and unwinds to the innermost
remaining one. Nothing is returned to JS.
- type: a string, or a Symbol's description. Other values are not
converted, which could run JS.
Prod behavior. Unrecorded runs: two checks of a false boolean per dispatch
with listeners, no binding calls. Recordings: two binding calls per
dispatch, which return after checking a cached flag; nodes and depths only
exist when replaying. No JS-visible change.
…tion primitive
- Kind emitEvent{type} instead of dispatchEvent{type}. The backend reads
dispatchEvent of input types (click, change, keypress, ...) as a DOM
input origin and ends chains there; node emits those names outside of
input (fs.watch 'change', readline 'keypress', user emitters).
- DependencyExecution: save the depth, begin iff there is a node, end by
unwinding to the depth. Windows and dispatches use it.
- A window pop also drops the dispatches its unwind ended, so a dispatch
whose finally a termination skipped does not outlive its window.
- Dispatches without a node keep a nullopt entry, so an end pops exactly
its own entry.
- EventEmitter#emit: no re-indent of the multi-listener body; the dispatch
ends in its existing finally.
…nd#13927) and B1b (backend#13925)
There was an error while loading. Please reload this page.
… [kHybridDispatch] [kHybridDispatch] is the pre-#242 code again. When instrumented, pre-execution installs hybridDispatchInDependencyGraph(), which runs the original in the emitEvent node's Begin/End if it has listeners.
…and [kHybridDispatch] EventEmitter#emit and EventTarget[kHybridDispatch] are the pre-#242 code again. When instrumented, pre-execution installs wrappers from internal/events/dependency_graph that run the original in the emitEvent node's Begin/End iff it calls listeners. emit('error') with kErrorMonitor listeners now emits kErrorMonitor inside the 'error' dispatch.
… in uninstrumented processes (#250) * Dependency graph: fold the instrumented checks of uninstrumented processes The checks read a let of internal/async_hooks, which optimized code loads and converts to a boolean at every check: in EventEmitter#emit, twice per call. A field of a constant object, written only when it changes, is folded to its value instead. emit() of a single listener moves its try/finally to a function called only when instrumented. * EventTarget: end the dispatch in a catch, not a finally A finally costs on the normal path also when not instrumented. Listener errors are caught in the loop, so only internal errors reach the catch. * EventTarget: keep the finally; emit(): explain the duplicated listener call The catch ending an EventTarget dispatch rethrew with a new message location. With the gates folded, the finally remains the only cost. * EventTarget: dispatch outside of the try/finally when not instrumented The listener loop moves to dispatchListeners(). Instrumented, it runs in dispatchInDependencyGraph()'s try/finally; else kHybridDispatch calls it directly. * EventTarget: keep the dispatch loop in kHybridDispatch dispatchListeners() was inlined into dispatchEvent(), which slowed dispatches down. * EventTarget: install the dependency graph dispatch over an unmodified [kHybridDispatch] [kHybridDispatch] is the pre-#242 code again. When instrumented, pre-execution installs hybridDispatchInDependencyGraph(), which runs the original in the emitEvent node's Begin/End if it has listeners. * Events: install the dependency graph dispatches over unmodified emit and [kHybridDispatch] EventEmitter#emit and EventTarget[kHybridDispatch] are the pre-#242 code again. When instrumented, pre-execution installs wrappers from internal/events/dependency_graph that run the original in the emitEvent node's Begin/End iff it calls listeners. emit('error') with kErrorMonitor listeners now emits kErrorMonitor inside the 'error' dispatch. * Events: define the dependency graph dispatch rule in the wrapper A call dispatches iff type is a string or symbol and the emitter or target has a listener for type at call time. Deciding it runs no user code. * Events: state the dependency graph dispatch decision's reads exactly
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.