@peerbit/shared-log 16.0.23 → 16.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -74,7 +74,9 @@ export type SyncOptions<R extends "u32" | "u64"> = {
74
74
  nativeWireSync?: SharedLogNativeWireSync;
75
75
  /**
76
76
  * Optional profiling callback. It is only invoked when provided, and should
77
- * avoid blocking because it runs inside sync hot paths.
77
+ * avoid blocking because it runs inline during open, provider resolution,
78
+ * and sync paths. Open-phase events describe setup progress only; they are
79
+ * not replication or durable-write readiness barriers.
78
80
  */
79
81
  profile?: SyncProfileFn;
80
82
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sync/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEpE,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,IAAI,CACrD,KAAK,EAAE,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,MAAM,EAAE,GAAG,IAAI,CAAC;IAC9C,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,kBAAkB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAAC;IAEtD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC7B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAE9B,IAAI,OAAO,IAAI,MAAM,CAAC;IAEtB,IAAI,YAAY,IAAI,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,WAAW,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;CACzE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peerbit/shared-log",
3
- "version": "16.0.23",
3
+ "version": "16.0.24",
4
4
  "description": "Shared log",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -63,26 +63,26 @@
63
63
  "pino": "^9.4.0",
64
64
  "uint8arrays": "^5.1.0",
65
65
  "@peerbit/any-store": "2.2.17",
66
- "@peerbit/blocks": "4.2.15",
67
- "@peerbit/blocks-interface": "2.1.7",
66
+ "@peerbit/blocks": "4.2.16",
67
+ "@peerbit/blocks-interface": "2.1.8",
68
68
  "@peerbit/cache": "3.1.1",
69
69
  "@peerbit/crypto": "3.1.6",
70
+ "@peerbit/diagnostics": "0.0.1",
70
71
  "@peerbit/indexer-interface": "3.0.13",
71
- "@peerbit/indexer-sqlite3": "3.0.20",
72
- "@peerbit/log": "6.2.30",
72
+ "@peerbit/log": "6.2.31",
73
73
  "@peerbit/logger": "2.0.2",
74
- "@peerbit/program": "6.0.57",
75
- "@peerbit/pubsub-interface": "5.2.2",
76
- "@peerbit/pubsub": "5.4.4",
77
- "@peerbit/diagnostics": "0.0.1",
74
+ "@peerbit/indexer-sqlite3": "3.0.20",
75
+ "@peerbit/program": "6.0.58",
78
76
  "@peerbit/riblt": "1.2.0",
79
- "@peerbit/rpc": "6.1.25",
77
+ "@peerbit/time": "3.0.1",
78
+ "@peerbit/rpc": "6.1.26",
80
79
  "@peerbit/stream-interface": "6.0.16",
81
- "@peerbit/time": "3.0.1"
80
+ "@peerbit/pubsub-interface": "5.2.2",
81
+ "@peerbit/pubsub": "5.4.5"
82
82
  },
83
83
  "optionalDependencies": {
84
84
  "@peerbit/shared-log-rust": "0.1.7",
85
- "@peerbit/native-backbone": "0.2.11"
85
+ "@peerbit/native-backbone": "0.2.12"
86
86
  },
87
87
  "devDependencies": {
88
88
  "@types/libsodium-wrappers": "^0.7.14",
@@ -91,8 +91,8 @@
91
91
  "@peerbit/any-store-rust": "0.1.7",
92
92
  "@peerbit/indexer-rust": "1.0.14",
93
93
  "@peerbit/indexer-simple": "1.2.17",
94
- "@peerbit/test-utils": "3.1.37",
95
- "peerbit": "5.3.37"
94
+ "@peerbit/test-utils": "3.1.38",
95
+ "peerbit": "5.3.38"
96
96
  },
97
97
  "repository": {
98
98
  "type": "git",
package/src/index.ts CHANGED
@@ -322,6 +322,86 @@ type SharedLogServicesWithFanout = {
322
322
  const getSharedLogFanoutService = (services: unknown): FanoutTree | undefined =>
323
323
  (services as SharedLogServicesWithFanout).fanout;
324
324
 
325
+ const FANOUT_OPEN_METRICS = [
326
+ ["joinReqSent", "joinReqSent"],
327
+ ["joinAcceptReceived", "joinAcceptReceived"],
328
+ ["joinRejectReceived", "joinRejectReceived"],
329
+ ["bootstrapDialAttempts", "joinBootstrapDialAttempts"],
330
+ ["bootstrapDialFailures", "joinBootstrapDialFailures"],
331
+ ["candidateDialAttempts", "joinCandidateDialAttempts"],
332
+ ["candidateDialFailures", "joinCandidateDialFailures"],
333
+ ["connectedCandidateAttempts", "joinConnectedCandidateAttempts"],
334
+ ["unconnectedCandidateAttempts", "joinUnconnectedCandidateAttempts"],
335
+ ["joinReqTimeouts", "joinReqTimeouts"],
336
+ ["deadlineExpirations", "joinDeadlineExpirations"],
337
+ ] as const;
338
+
339
+ type FanoutOpenMetric = (typeof FANOUT_OPEN_METRICS)[number][0];
340
+ type FanoutOpenMetricSnapshot = Record<FanoutOpenMetric, number>;
341
+
342
+ const snapshotFanoutOpenMetrics = (
343
+ service: FanoutTree,
344
+ topic: string,
345
+ root: string,
346
+ ): FanoutOpenMetricSnapshot | undefined => {
347
+ try {
348
+ const metrics = (
349
+ service as FanoutTree & {
350
+ getChannelMetrics: (
351
+ topic: string,
352
+ root: string,
353
+ ) => Record<string, number>;
354
+ }
355
+ ).getChannelMetrics(topic, root);
356
+ return Object.fromEntries(
357
+ FANOUT_OPEN_METRICS.map(([name, source]) => [name, metrics[source] ?? 0]),
358
+ ) as FanoutOpenMetricSnapshot;
359
+ } catch {
360
+ return;
361
+ }
362
+ };
363
+
364
+ const emitFanoutOpenProfile = (properties: {
365
+ profile?: SyncProfileFn;
366
+ startedAt: number;
367
+ service: FanoutTree;
368
+ topic: string;
369
+ root: string;
370
+ mode: "root" | "node";
371
+ outcome: "error" | "opened" | "joined";
372
+ timeoutMs?: number;
373
+ before?: FanoutOpenMetricSnapshot;
374
+ }) => {
375
+ if (!properties.profile) return;
376
+ try {
377
+ const after = snapshotFanoutOpenMetrics(
378
+ properties.service,
379
+ properties.topic,
380
+ properties.root,
381
+ );
382
+ const deltas = Object.fromEntries(
383
+ FANOUT_OPEN_METRICS.map(([name]) => [
384
+ name,
385
+ (after?.[name] ?? 0) - (properties.before?.[name] ?? 0),
386
+ ]),
387
+ ) as FanoutOpenMetricSnapshot;
388
+ emitSyncProfileDuration(properties.profile, properties.startedAt, {
389
+ name: "sharedLog.open.fanout",
390
+ component: "shared-log",
391
+ messages: deltas.joinReqSent,
392
+ details: {
393
+ configured: true,
394
+ mode: properties.mode,
395
+ outcome: properties.outcome,
396
+ configuredTimeoutMs: properties.timeoutMs,
397
+ ...deltas,
398
+ },
399
+ });
400
+ } catch {
401
+ // Diagnostics must not affect open correctness.
402
+ }
403
+ };
404
+
325
405
  type PendingIHave<T> = {
326
406
  resetTimeout: () => void;
327
407
  requesting: Map<string, Uint8Array>;
@@ -471,6 +551,18 @@ export const logger = loggerFn("peerbit:shared-log");
471
551
  const warn = logger.newScope("warn");
472
552
  const traceLogger = logger.trace as typeof logger.trace & { enabled?: boolean };
473
553
 
554
+ const emitAdvisorySyncProfileDuration = (
555
+ profile: SyncProfileFn | undefined,
556
+ startedAt: number,
557
+ event: Parameters<typeof emitSyncProfileDuration>[2],
558
+ ): void => {
559
+ try {
560
+ emitSyncProfileDuration(profile, startedAt, event);
561
+ } catch {
562
+ // Diagnostics must not change open or provider-resolution correctness.
563
+ }
564
+ };
565
+
474
566
  const canUseOptionalNativeModuleImports = (): boolean => {
475
567
  const scope = globalThis as {
476
568
  ServiceWorkerGlobalScope?: unknown;
@@ -4341,16 +4433,38 @@ export class SharedLog<
4341
4433
  });
4342
4434
  channel.addEventListener("unicast", this._onFanoutUnicastFn);
4343
4435
 
4436
+ const profile = this._logProperties?.sync?.profile;
4437
+ const startedAt = syncProfileStart(profile);
4438
+ const mode =
4439
+ resolvedRoot === fanoutService.publicKeyHash ? "root" : "node";
4440
+ const before = profile
4441
+ ? snapshotFanoutOpenMetrics(fanoutService, this.topic, resolvedRoot)
4442
+ : undefined;
4443
+ let outcome: "error" | "opened" | "joined" = "error";
4344
4444
  try {
4345
4445
  const channelOptions = this.getFanoutChannelOptions(options);
4346
- if (resolvedRoot === fanoutService.publicKeyHash) {
4446
+ if (mode === "root") {
4347
4447
  await channel.openAsRoot(channelOptions);
4448
+ outcome = "opened";
4348
4449
  return;
4349
4450
  }
4350
4451
  await channel.join(channelOptions, options.join);
4452
+ outcome = "joined";
4351
4453
  } catch (error) {
4352
4454
  this._closeFanoutChannel();
4353
4455
  throw error;
4456
+ } finally {
4457
+ emitFanoutOpenProfile({
4458
+ profile,
4459
+ startedAt,
4460
+ service: fanoutService,
4461
+ topic: this.topic,
4462
+ root: resolvedRoot,
4463
+ mode,
4464
+ outcome,
4465
+ timeoutMs: options.join?.timeoutMs,
4466
+ before,
4467
+ });
4354
4468
  }
4355
4469
  }
4356
4470
 
@@ -17088,6 +17202,8 @@ export class SharedLog<
17088
17202
  (this.node as unknown as NodeWithSharedLogNativeDefaults)
17089
17203
  .sharedLogNativeDefaults,
17090
17204
  );
17205
+ const openProfile = options?.sync?.profile;
17206
+ const openStartedAt = syncProfileStart(openProfile);
17091
17207
  this.replicas = {
17092
17208
  min:
17093
17209
  options?.replicas?.min != null
@@ -17318,6 +17434,7 @@ export class SharedLog<
17318
17434
  this.keep = options?.keep;
17319
17435
  this.pendingMaturity = new Map();
17320
17436
 
17437
+ const localStateStartedAt = syncProfileStart(openProfile);
17321
17438
  const id = sha256Base64Sync(this.log.id);
17322
17439
  const [storage, logScope] = await Promise.all([
17323
17440
  this.node.storage.sublevel(id),
@@ -17373,6 +17490,11 @@ export class SharedLog<
17373
17490
  this._entryCoordinatesIndex = await replicationIndex.init({
17374
17491
  schema: this.indexableDomain.constructorEntry,
17375
17492
  });
17493
+ emitAdvisorySyncProfileDuration(openProfile, localStateStartedAt, {
17494
+ name: "sharedLog.open.localState",
17495
+ component: "shared-log",
17496
+ });
17497
+ const blockStoreStartedAt = syncProfileStart(openProfile);
17376
17498
  const deferStandaloneNativeRangePlanner =
17377
17499
  !!options?.nativeBackbone && options.nativeRangePlanner == null;
17378
17500
  await this.openNativeRangePlanner(
@@ -17423,6 +17545,14 @@ export class SharedLog<
17423
17545
  storage as unknown as DurableBlockSublevelStore,
17424
17546
  );
17425
17547
  }
17548
+ emitAdvisorySyncProfileDuration(openProfile, blockStoreStartedAt, {
17549
+ name: "sharedLog.open.blockStore",
17550
+ component: "shared-log",
17551
+ details: {
17552
+ nativeBackbone: this._nativeBackbone != null,
17553
+ directoryConfigured: this.node.directory != null,
17554
+ },
17555
+ });
17426
17556
  this.remoteBlocks = new RemoteBlocks({
17427
17557
  local: localBlocks,
17428
17558
  publish: (message, options) =>
@@ -17433,38 +17563,76 @@ export class SharedLog<
17433
17563
  // compatible eager path with bounded validation and storage budgets.
17434
17564
  eagerBlocks: options?.eagerBlocks ?? false,
17435
17565
  resolveProviders: async (cid, opts) => {
17566
+ const profile = this._logProperties?.sync?.profile;
17436
17567
  const maxPeers = 8;
17568
+ const excluded = new Set((opts?.exclude ?? []).slice(0, maxPeers));
17569
+ const lookupPeers = opts?.refresh
17570
+ ? Math.min(maxPeers * 2, maxPeers + excluded.size)
17571
+ : maxPeers;
17572
+ const resolutionStartedAt = syncProfileStart(profile);
17437
17573
  const localCandidates =
17438
17574
  (await this.resolveCandidatePeersForHash(cid, {
17439
17575
  signal: opts?.signal,
17440
- maxPeers,
17576
+ maxPeers: lookupPeers,
17441
17577
  })) ?? [];
17442
- if (opts?.signal?.aborted) return [];
17578
+ const emitResolution = profile
17579
+ ? (
17580
+ status: "aborted" | "local" | "directory",
17581
+ targets: number,
17582
+ directoryCandidates = 0,
17583
+ reachableCandidates = 0,
17584
+ ) =>
17585
+ emitAdvisorySyncProfileDuration(profile, resolutionStartedAt, {
17586
+ name: "sharedLog.blocks.resolveProviders",
17587
+ component: "shared-log",
17588
+ count: targets,
17589
+ targets,
17590
+ details: {
17591
+ status,
17592
+ refresh: opts?.refresh === true,
17593
+ excluded: excluded.size,
17594
+ lookupPeers,
17595
+ localCandidates: localCandidates.length,
17596
+ directoryCandidates,
17597
+ reachableCandidates,
17598
+ },
17599
+ })
17600
+ : undefined;
17601
+ if (opts?.signal?.aborted) {
17602
+ emitResolution?.("aborted", 0);
17603
+ return [];
17604
+ }
17443
17605
  const locallyReachable = new Set(
17444
17606
  await this._getLocalReachablePeerHashes(this.topic),
17445
17607
  );
17608
+ if (opts?.signal?.aborted) {
17609
+ emitResolution?.("aborted", 0, 0, locallyReachable.size);
17610
+ return [];
17611
+ }
17446
17612
  const confirmed = this._checkedPrune.getConfirmedReplicators(cid);
17447
17613
  const contacted = this._checkedPrune.getContactedReplicators(cid);
17614
+ const hasProviderEvidence = (peer: string) =>
17615
+ confirmed?.has(peer) === true ||
17616
+ contacted?.has(peer) ||
17617
+ this.uniqueReplicators.has(peer);
17448
17618
  const hasLiveCandidate = localCandidates.some(
17449
- (peer) =>
17450
- locallyReachable.has(peer) &&
17451
- (confirmed?.has(peer) ||
17452
- contacted?.has(peer) ||
17453
- this.uniqueReplicators.has(peer)),
17619
+ (peer) => locallyReachable.has(peer) && hasProviderEvidence(peer),
17454
17620
  );
17455
17621
 
17456
17622
  // Only reachability corroborated by provider/replicator evidence may
17457
17623
  // bypass the initial CID lookup. Arbitrary bootstrap connections are
17458
17624
  // useful fallbacks, but are not evidence that they hold this block.
17459
17625
  if (hasLiveCandidate && !opts?.refresh) {
17460
- return localCandidates;
17626
+ const selected = localCandidates.slice(0, maxPeers);
17627
+ emitResolution?.("local", selected.length, 0, locallyReachable.size);
17628
+ return selected;
17461
17629
  }
17462
17630
 
17463
17631
  let directoryProviders: string[] = [];
17464
17632
  try {
17465
17633
  const query = (namespace: string) =>
17466
17634
  fanoutService?.queryProviders(namespace, {
17467
- want: maxPeers,
17635
+ want: lookupPeers,
17468
17636
  timeoutMs: 2_000,
17469
17637
  queryTimeoutMs: 500,
17470
17638
  bootstrapMaxPeers: 2,
@@ -17476,12 +17644,21 @@ export class SharedLog<
17476
17644
  ]);
17477
17645
  for (const result of results) {
17478
17646
  if (result.status === "fulfilled") {
17479
- directoryProviders.push(...result.value);
17647
+ directoryProviders.push(...result.value.slice(0, lookupPeers));
17480
17648
  }
17481
17649
  }
17482
17650
  } catch {
17483
17651
  // Ignore discovery failures; local evidence remains usable.
17484
17652
  }
17653
+ if (opts?.signal?.aborted) {
17654
+ emitResolution?.(
17655
+ "aborted",
17656
+ 0,
17657
+ directoryProviders.length,
17658
+ locallyReachable.size,
17659
+ );
17660
+ return [];
17661
+ }
17485
17662
 
17486
17663
  const selected: string[] = [];
17487
17664
  const selectedSet = new Set<string>();
@@ -17492,15 +17669,62 @@ export class SharedLog<
17492
17669
  selectedSet.add(peer);
17493
17670
  selected.push(peer);
17494
17671
  };
17495
- for (
17496
- let index = 0;
17497
- selected.length < maxPeers &&
17498
- (index < localCandidates.length || index < directoryProviders.length);
17499
- index++
17500
- ) {
17501
- add(localCandidates[index]);
17502
- add(directoryProviders[index]);
17503
- }
17672
+ const append = (
17673
+ providers: readonly string[],
17674
+ includeExcluded: boolean,
17675
+ predicate?: (provider: string) => boolean,
17676
+ ) => {
17677
+ for (const provider of providers) {
17678
+ if (selected.length >= maxPeers) return;
17679
+ if (
17680
+ excluded.has(provider) === includeExcluded &&
17681
+ (!predicate || predicate(provider))
17682
+ ) {
17683
+ add(provider);
17684
+ }
17685
+ }
17686
+ };
17687
+ const appendInterleaved = (includeExcluded: boolean) => {
17688
+ for (
17689
+ let index = 0;
17690
+ selected.length < maxPeers &&
17691
+ (index < localCandidates.length ||
17692
+ index < directoryProviders.length);
17693
+ index++
17694
+ ) {
17695
+ const local = localCandidates[index];
17696
+ if (local && excluded.has(local) === includeExcluded) add(local);
17697
+ const directory = directoryProviders[index];
17698
+ if (directory && excluded.has(directory) === includeExcluded) {
17699
+ add(directory);
17700
+ }
17701
+ }
17702
+ };
17703
+ if (opts?.refresh) {
17704
+ // Retry results are wider than the regular eight-peer window. Prefer
17705
+ // untried reachable holders, then the remaining fresh directory
17706
+ // evidence, without discarding attempted peers as bounded transient-
17707
+ // failure fallbacks.
17708
+ append(directoryProviders, false, (peer) =>
17709
+ locallyReachable.has(peer),
17710
+ );
17711
+ append(
17712
+ localCandidates,
17713
+ false,
17714
+ (peer) => locallyReachable.has(peer) && hasProviderEvidence(peer),
17715
+ );
17716
+ append(directoryProviders, false);
17717
+ append(localCandidates, false);
17718
+ } else {
17719
+ appendInterleaved(false);
17720
+ }
17721
+ appendInterleaved(true);
17722
+ emitResolution?.(
17723
+ "directory",
17724
+ selected.length,
17725
+ directoryProviders.length,
17726
+ locallyReachable.size,
17727
+ );
17504
17728
  return selected;
17505
17729
  },
17506
17730
  watchProviders: fanoutService
@@ -17548,7 +17772,13 @@ export class SharedLog<
17548
17772
  : undefined,
17549
17773
  });
17550
17774
 
17551
- const remoteBlocksStartPromise = this.remoteBlocks.start();
17775
+ const remoteBlocksStartedAt = syncProfileStart(openProfile);
17776
+ const remoteBlocksStartPromise = this.remoteBlocks.start().then(() => {
17777
+ emitAdvisorySyncProfileDuration(openProfile, remoteBlocksStartedAt, {
17778
+ name: "sharedLog.open.remoteBlocks",
17779
+ component: "shared-log",
17780
+ });
17781
+ });
17552
17782
  const hasIndexedReplicationInfo =
17553
17783
  (await this.replicationIndex.count({
17554
17784
  query: [
@@ -17764,6 +17994,7 @@ export class SharedLog<
17764
17994
  // joins rely on: a replicate:false observer syncing a head whose parents
17765
17995
  // are not local would fail block resolution, and Log.join treats that as
17766
17996
  // recoverable and skips the entry without persisting anything.
17997
+ const lowerLogStartedAt = syncProfileStart(openProfile);
17767
17998
  await this.log.open(this.remoteBlocks, this.node.identity, {
17768
17999
  keychain: this.node.services.keychain,
17769
18000
  resolveRemotePeers: (hash, options) =>
@@ -17795,6 +18026,10 @@ export class SharedLog<
17795
18026
  },
17796
18027
  indexer: logIndex,
17797
18028
  });
18029
+ emitAdvisorySyncProfileDuration(openProfile, lowerLogStartedAt, {
18030
+ name: "sharedLog.open.lowerLog",
18031
+ component: "shared-log",
18032
+ });
17798
18033
  this._persistedReceiptStorage = this.resolvePersistedReceiptStorage();
17799
18034
  try {
17800
18035
  const recovered =
@@ -17859,6 +18094,7 @@ export class SharedLog<
17859
18094
  this._onUnsubscription(event),
17860
18095
  );
17861
18096
  });
18097
+ const communicationStartedAt = syncProfileStart(openProfile);
17862
18098
  await Promise.all([
17863
18099
  this.rpc.open({
17864
18100
  queryType: TransportMessage,
@@ -17877,7 +18113,12 @@ export class SharedLog<
17877
18113
  this._onUnsubscriptionFn,
17878
18114
  ),
17879
18115
  ]);
18116
+ emitAdvisorySyncProfileDuration(openProfile, communicationStartedAt, {
18117
+ name: "sharedLog.open.rpcSubscriptions",
18118
+ component: "shared-log",
18119
+ });
17880
18120
 
18121
+ const providerChannelStartedAt = syncProfileStart(openProfile);
17881
18122
  const fanoutOpenPromise = this._openFanoutChannel(options?.fanout);
17882
18123
  // Mark previously-owned replication ranges as "new" only when they already exist.
17883
18124
  // Fresh opens have nothing to touch here, so skip the extra scan/write entirely.
@@ -17885,6 +18126,11 @@ export class SharedLog<
17885
18126
  ? this.updateTimestampOfOwnedReplicationRanges()
17886
18127
  : Promise.resolve();
17887
18128
  await Promise.all([fanoutOpenPromise, updateOwnedReplicationPromise]);
18129
+ emitAdvisorySyncProfileDuration(openProfile, providerChannelStartedAt, {
18130
+ name: "sharedLog.open.providerAndOwnership",
18131
+ component: "shared-log",
18132
+ details: { indexedReplicationInfo: hasIndexedReplicationInfo },
18133
+ });
17888
18134
 
17889
18135
  // if we had a previous session with replication info, and new replication info dictates that we unreplicate
17890
18136
  // we should do that. Otherwise if options is a unreplication we dont need to do anything because
@@ -17902,17 +18148,35 @@ export class SharedLog<
17902
18148
  this.node.identity.publicKey,
17903
18149
  ));
17904
18150
 
18151
+ const replicationStartedAt = syncProfileStart(openProfile);
18152
+ let replicationAction: "replace" | "resume" | "reset";
17905
18153
  if (hasIndexedReplicationInfo && isUnreplicationOptionsDefined) {
18154
+ replicationAction = "replace";
17906
18155
  await this.replicate(options?.replicate, { checkDuplicates: true });
17907
18156
  } else if (canResumeReplication) {
18157
+ replicationAction = "resume";
17908
18158
  // dont do anthing since we are alread replicating stuff
17909
18159
  } else {
18160
+ replicationAction = "reset";
17910
18161
  await this.replicate(options?.replicate, {
17911
18162
  checkDuplicates: true,
17912
18163
  reset: true,
17913
18164
  });
17914
18165
  }
18166
+ emitAdvisorySyncProfileDuration(openProfile, replicationStartedAt, {
18167
+ name: "sharedLog.open.replication",
18168
+ component: "shared-log",
18169
+ details: {
18170
+ hadIndexedState: hasIndexedReplicationInfo,
18171
+ action: replicationAction,
18172
+ },
18173
+ });
18174
+ const synchronizerStartedAt = syncProfileStart(openProfile);
17915
18175
  await this.syncronizer.open();
18176
+ emitAdvisorySyncProfileDuration(openProfile, synchronizerStartedAt, {
18177
+ name: "sharedLog.open.synchronizer",
18178
+ component: "shared-log",
18179
+ });
17916
18180
 
17917
18181
  this.interval = setInterval(() => {
17918
18182
  void this.rebalanceParticipationDebounced?.call();
@@ -17920,6 +18184,10 @@ export class SharedLog<
17920
18184
 
17921
18185
  this._instanceLifecycle!.markOpenComplete();
17922
18186
  this.scheduleReplicationStatusRefresh();
18187
+ emitAdvisorySyncProfileDuration(openProfile, openStartedAt, {
18188
+ name: "sharedLog.open.total",
18189
+ component: "shared-log",
18190
+ });
17923
18191
  }
17924
18192
 
17925
18193
  private toNativeReplicationRange(
package/src/sync/index.ts CHANGED
@@ -93,7 +93,9 @@ export type SyncOptions<R extends "u32" | "u64"> = {
93
93
 
94
94
  /**
95
95
  * Optional profiling callback. It is only invoked when provided, and should
96
- * avoid blocking because it runs inside sync hot paths.
96
+ * avoid blocking because it runs inline during open, provider resolution,
97
+ * and sync paths. Open-phase events describe setup progress only; they are
98
+ * not replication or durable-write readiness barriers.
97
99
  */
98
100
  profile?: SyncProfileFn;
99
101
  };