Skip to content
Source
Sign inSign up
TanStack/db

perf(db): explore incremental update hot paths #1648

Closedsamwilliswants to merge 32 commits intomain fromcodex/fix-incremental-snapshot-hot-pathopened

Showing 43 changed files with 93 additions and 0 deletions (loading 41).

x
0 of 43 viewed, 43 left
64 additions and 0 deletionspackages/db/src/collection/changes.tsModified
View file
@@ -3,6 +3,11 @@
createSingleRowRefProxy,
toExpression,
} from '../query/builder/ref-proxy.js'
+import {
+ isPerfEnabled,
+ recordPerfCount,
+ startPerfSpan,
+} from '../query/live/perf.js'
import { CollectionSubscription } from './subscription.js'
import type { StandardSchemaV1 } from '@standard-schema/spec'
import type { ChangeMessage, SubscribeChangesOptions } from '../types'
@@ -77,10 +82,23 @@
changes: Array<ChangeMessage<TOutput, TKey>>,
forceEmit = false,
): void {
+ const shouldTrace = isPerfEnabled()
+ const span = shouldTrace
+ ? startPerfSpan(`collection.changes.emitEvents`, {
+ collectionId: this.collection.id,
+ forceEmit,
+ })
+ : undefined
// Skip batching for user actions (forceEmit=true) to keep UI responsive
if (this.shouldBatchEvents && !forceEmit) {