-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
sqlite: add diagnostic channel #62241
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
base: main
Are you sure you want to change the base?
Changes from all commits
12bcef0
92c852f
951d37d
4265252
189dd9d
59c371d
b488f79
6bb5356
55eedb9
5dd5a6e
be11388
fa8748b
2198e89
82c8b07
abd0792
d7d6182
f2b0e0b
47734f4
f2b660b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| 'use strict'; | ||
| const common = require('../common.js'); | ||
| const sqlite = require('node:sqlite'); | ||
| const dc = require('diagnostics_channel'); | ||
| const assert = require('assert'); | ||
|
|
||
| const bench = common.createBenchmark(main, { | ||
| n: [1e5], | ||
| mode: ['none', 'subscribed', 'unsubscribed'], | ||
| }); | ||
|
|
||
| function main(conf) { | ||
| const { n, mode } = conf; | ||
|
|
||
| const db = new sqlite.DatabaseSync(':memory:'); | ||
| db.exec('CREATE TABLE t (x INTEGER)'); | ||
| const insert = db.prepare('INSERT INTO t VALUES (?)'); | ||
|
|
||
| let subscriber; | ||
| if (mode === 'subscribed') { | ||
| subscriber = () => {}; | ||
| dc.subscribe('sqlite.db.query', subscriber); | ||
| } else if (mode === 'unsubscribed') { | ||
| subscriber = () => {}; | ||
| dc.subscribe('sqlite.db.query', subscriber); | ||
| dc.unsubscribe('sqlite.db.query', subscriber); | ||
| } | ||
| // mode === 'none': no subscription ever made | ||
|
|
||
| let result; | ||
| bench.start(); | ||
| for (let i = 0; i < n; i++) { | ||
| result = insert.run(i); | ||
| } | ||
| bench.end(n); | ||
|
|
||
| if (mode === 'subscribed') { | ||
| dc.unsubscribe('sqlite.db.query', subscriber); | ||
| } | ||
|
|
||
| assert.ok(result !== undefined); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1913,10 +1913,33 @@ added: v16.18.0 | |
|
|
||
| Emitted when a new thread is created. | ||
|
|
||
| #### SQLite | ||
|
|
||
| <!-- YAML | ||
| added: REPLACEME | ||
| --> | ||
|
|
||
| > Stability: 1 - Experimental | ||
|
|
||
| ##### Event: `'sqlite.db.query'` | ||
|
|
||
| * `sql` {string} The expanded SQL with bound parameter values substituted. | ||
| If expansion fails, the source SQL with unsubstituted placeholders is used | ||
| instead. | ||
| * `database` {DatabaseSync} The [`DatabaseSync`][] instance that executed the | ||
| statement. | ||
| * `duration` {number} The estimated statement run time in nanoseconds. | ||
|
|
||
| Emitted when a SQL statement is executed against a [`DatabaseSync`][] instance. | ||
| This allows subscribers to observe every SQL statement executed without | ||
| modifying the database code itself. Tracing is zero-cost when there are no | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We may want to be clear that this is a profiling and not for true tracing as it does not actually capture the timing of when it starts or have any way to produce a span linked to a correct parent. Either that or just use TracingChannel instead in pure JS and forget the C part entirely. The C code, for a bunch of reasons, is not a super accurate picture of what actually is going on given that will only show you the performance of the C API and none of the code exposing that data to JS. If that's all you care about, that's fine, but it won't give you a clear picture of actual application performance. |
||
| subscribers. | ||
|
|
||
| [BoundedChannel Channels]: #boundedchannel-channels | ||
| [TracingChannel Channels]: #tracingchannel-channels | ||
| [`'uncaughtException'`]: process.md#event-uncaughtexception | ||
| [`BoundedChannel`]: #class-boundedchannel | ||
| [`DatabaseSync`]: sqlite.md#class-databasesync | ||
| [`TracingChannel`]: #class-tracingchannel | ||
| [`asyncEnd` event]: #asyncendevent | ||
| [`asyncStart` event]: #asyncstartevent | ||
|
|
||
|
araujogui marked this conversation as resolved.
|
Uh oh!
There was an error while loading. Please reload this page.