@fluidframework/container-runtime 1.2.2 → 2.0.0-internal.1.0.0.82159

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.
Files changed (135) hide show
  1. package/dist/blobManager.d.ts +81 -25
  2. package/dist/blobManager.d.ts.map +1 -1
  3. package/dist/blobManager.js +301 -100
  4. package/dist/blobManager.js.map +1 -1
  5. package/dist/containerRuntime.d.ts +65 -11
  6. package/dist/containerRuntime.d.ts.map +1 -1
  7. package/dist/containerRuntime.js +101 -82
  8. package/dist/containerRuntime.js.map +1 -1
  9. package/dist/dataStore.d.ts +1 -1
  10. package/dist/dataStore.d.ts.map +1 -1
  11. package/dist/dataStore.js +32 -26
  12. package/dist/dataStore.js.map +1 -1
  13. package/dist/dataStoreContext.d.ts +3 -4
  14. package/dist/dataStoreContext.d.ts.map +1 -1
  15. package/dist/dataStoreContext.js +16 -23
  16. package/dist/dataStoreContext.js.map +1 -1
  17. package/dist/dataStores.d.ts +5 -2
  18. package/dist/dataStores.d.ts.map +1 -1
  19. package/dist/dataStores.js +11 -3
  20. package/dist/dataStores.js.map +1 -1
  21. package/dist/garbageCollection.d.ts.map +1 -1
  22. package/dist/garbageCollection.js +17 -12
  23. package/dist/garbageCollection.js.map +1 -1
  24. package/dist/opProperties.d.ts +7 -0
  25. package/dist/opProperties.d.ts.map +1 -0
  26. package/dist/opProperties.js +20 -0
  27. package/dist/opProperties.js.map +1 -0
  28. package/dist/packageVersion.d.ts +1 -1
  29. package/dist/packageVersion.d.ts.map +1 -1
  30. package/dist/packageVersion.js +1 -1
  31. package/dist/packageVersion.js.map +1 -1
  32. package/dist/runningSummarizer.d.ts +14 -4
  33. package/dist/runningSummarizer.d.ts.map +1 -1
  34. package/dist/runningSummarizer.js +68 -26
  35. package/dist/runningSummarizer.js.map +1 -1
  36. package/dist/summarizer.d.ts +0 -2
  37. package/dist/summarizer.d.ts.map +1 -1
  38. package/dist/summarizer.js +1 -12
  39. package/dist/summarizer.js.map +1 -1
  40. package/dist/summarizerHeuristics.d.ts +26 -4
  41. package/dist/summarizerHeuristics.d.ts.map +1 -1
  42. package/dist/summarizerHeuristics.js +95 -18
  43. package/dist/summarizerHeuristics.js.map +1 -1
  44. package/dist/summarizerTypes.d.ts +30 -10
  45. package/dist/summarizerTypes.d.ts.map +1 -1
  46. package/dist/summarizerTypes.js.map +1 -1
  47. package/dist/summaryCollection.js +1 -1
  48. package/dist/summaryCollection.js.map +1 -1
  49. package/dist/summaryFormat.d.ts +0 -5
  50. package/dist/summaryFormat.d.ts.map +1 -1
  51. package/dist/summaryFormat.js.map +1 -1
  52. package/dist/summaryGenerator.d.ts +1 -0
  53. package/dist/summaryGenerator.d.ts.map +1 -1
  54. package/dist/summaryGenerator.js +11 -9
  55. package/dist/summaryGenerator.js.map +1 -1
  56. package/lib/blobManager.d.ts +81 -25
  57. package/lib/blobManager.d.ts.map +1 -1
  58. package/lib/blobManager.js +302 -101
  59. package/lib/blobManager.js.map +1 -1
  60. package/lib/containerRuntime.d.ts +65 -11
  61. package/lib/containerRuntime.d.ts.map +1 -1
  62. package/lib/containerRuntime.js +103 -84
  63. package/lib/containerRuntime.js.map +1 -1
  64. package/lib/dataStore.d.ts +1 -1
  65. package/lib/dataStore.d.ts.map +1 -1
  66. package/lib/dataStore.js +32 -26
  67. package/lib/dataStore.js.map +1 -1
  68. package/lib/dataStoreContext.d.ts +3 -4
  69. package/lib/dataStoreContext.d.ts.map +1 -1
  70. package/lib/dataStoreContext.js +17 -24
  71. package/lib/dataStoreContext.js.map +1 -1
  72. package/lib/dataStores.d.ts +5 -2
  73. package/lib/dataStores.d.ts.map +1 -1
  74. package/lib/dataStores.js +11 -3
  75. package/lib/dataStores.js.map +1 -1
  76. package/lib/garbageCollection.d.ts.map +1 -1
  77. package/lib/garbageCollection.js +17 -12
  78. package/lib/garbageCollection.js.map +1 -1
  79. package/lib/opProperties.d.ts +7 -0
  80. package/lib/opProperties.d.ts.map +1 -0
  81. package/lib/opProperties.js +16 -0
  82. package/lib/opProperties.js.map +1 -0
  83. package/lib/packageVersion.d.ts +1 -1
  84. package/lib/packageVersion.d.ts.map +1 -1
  85. package/lib/packageVersion.js +1 -1
  86. package/lib/packageVersion.js.map +1 -1
  87. package/lib/runningSummarizer.d.ts +14 -4
  88. package/lib/runningSummarizer.d.ts.map +1 -1
  89. package/lib/runningSummarizer.js +68 -26
  90. package/lib/runningSummarizer.js.map +1 -1
  91. package/lib/summarizer.d.ts +0 -2
  92. package/lib/summarizer.d.ts.map +1 -1
  93. package/lib/summarizer.js +1 -12
  94. package/lib/summarizer.js.map +1 -1
  95. package/lib/summarizerHeuristics.d.ts +26 -4
  96. package/lib/summarizerHeuristics.d.ts.map +1 -1
  97. package/lib/summarizerHeuristics.js +95 -18
  98. package/lib/summarizerHeuristics.js.map +1 -1
  99. package/lib/summarizerTypes.d.ts +30 -10
  100. package/lib/summarizerTypes.d.ts.map +1 -1
  101. package/lib/summarizerTypes.js.map +1 -1
  102. package/lib/summaryCollection.js +1 -1
  103. package/lib/summaryCollection.js.map +1 -1
  104. package/lib/summaryFormat.d.ts +0 -5
  105. package/lib/summaryFormat.d.ts.map +1 -1
  106. package/lib/summaryFormat.js.map +1 -1
  107. package/lib/summaryGenerator.d.ts +1 -0
  108. package/lib/summaryGenerator.d.ts.map +1 -1
  109. package/lib/summaryGenerator.js +11 -9
  110. package/lib/summaryGenerator.js.map +1 -1
  111. package/package.json +45 -20
  112. package/src/blobManager.ts +360 -119
  113. package/src/containerRuntime.ts +203 -103
  114. package/src/dataStore.ts +53 -38
  115. package/src/dataStoreContext.ts +16 -23
  116. package/src/dataStores.ts +14 -3
  117. package/src/garbageCollection.ts +13 -7
  118. package/src/opProperties.ts +19 -0
  119. package/src/packageVersion.ts +1 -1
  120. package/src/runningSummarizer.ts +75 -22
  121. package/src/summarizer.ts +1 -18
  122. package/src/summarizerHeuristics.ts +133 -19
  123. package/src/summarizerTypes.ts +37 -10
  124. package/src/summaryCollection.ts +1 -1
  125. package/src/summaryFormat.ts +0 -6
  126. package/src/summaryGenerator.ts +40 -22
  127. package/dist/opTelemetry.d.ts +0 -22
  128. package/dist/opTelemetry.d.ts.map +0 -1
  129. package/dist/opTelemetry.js +0 -59
  130. package/dist/opTelemetry.js.map +0 -1
  131. package/lib/opTelemetry.d.ts +0 -22
  132. package/lib/opTelemetry.d.ts.map +0 -1
  133. package/lib/opTelemetry.js +0 -55
  134. package/lib/opTelemetry.js.map +0 -1
  135. package/src/opTelemetry.ts +0 -71
@@ -6,11 +6,11 @@
6
6
  import { ITelemetryLogger } from "@fluidframework/common-definitions";
7
7
  import { Timer } from "@fluidframework/common-utils";
8
8
  import { ISummaryConfigurationHeuristics } from "./containerRuntime";
9
-
10
9
  import {
11
10
  ISummarizeHeuristicData,
12
11
  ISummarizeHeuristicRunner,
13
12
  ISummarizeAttempt,
13
+ ISummaryHeuristicStrategy,
14
14
  } from "./summarizerTypes";
15
15
  import { SummarizeReason } from "./summaryGenerator";
16
16
 
@@ -26,6 +26,30 @@ export class SummarizeHeuristicData implements ISummarizeHeuristicData {
26
26
  return this._lastSuccessfulSummary;
27
27
  }
28
28
 
29
+ public numNonRuntimeOps: number = 0;
30
+ public totalOpsSize: number = 0;
31
+ public hasMissingOpData: boolean = false;
32
+
33
+ /**
34
+ * Cumulative size in bytes of all the ops at the beginning of the summarization attempt.
35
+ * Is used to adjust totalOpsSize appropriately after successful summarization.
36
+ */
37
+ /** */
38
+ private totalOpsSizeBefore: number = 0;
39
+
40
+ /**
41
+ * Number of system ops at beginning of attempting to summarize.
42
+ * Is used to adjust numSystemOps appropriately after successful summarization.
43
+ */
44
+ private numSystemOpsBefore: number = 0;
45
+
46
+ public numRuntimeOps: number = 0;
47
+ /**
48
+ * Number of non-system ops at beginning of attempting to summarize.
49
+ * Is used to adjust numNonSystemOps appropriately after successful summarization.
50
+ */
51
+ private numNonSystemOpsBefore: number = 0;
52
+
29
53
  constructor(
30
54
  public lastOpSequenceNumber: number,
31
55
  /** Baseline attempt data used for comparisons with subsequent attempts/calculations. */
@@ -45,10 +69,23 @@ export class SummarizeHeuristicData implements ISummarizeHeuristicData {
45
69
  refSequenceNumber: refSequenceNumber ?? this.lastOpSequenceNumber,
46
70
  summaryTime: Date.now(),
47
71
  };
72
+
73
+ this.numSystemOpsBefore = this.numNonRuntimeOps;
74
+ this.numNonSystemOpsBefore = this.numRuntimeOps;
75
+ this.totalOpsSizeBefore = this.totalOpsSize;
48
76
  }
49
77
 
50
78
  public markLastAttemptAsSuccessful() {
51
79
  this._lastSuccessfulSummary = { ...this.lastAttempt };
80
+
81
+ this.numNonRuntimeOps -= this.numSystemOpsBefore;
82
+ this.numSystemOpsBefore = 0;
83
+
84
+ this.numRuntimeOps -= this.numNonSystemOpsBefore;
85
+ this.numNonSystemOpsBefore = 0;
86
+
87
+ this.totalOpsSize -= this.totalOpsSizeBefore;
88
+ this.totalOpsSizeBefore = 0;
52
89
  }
53
90
  }
54
91
 
@@ -56,42 +93,71 @@ export class SummarizeHeuristicData implements ISummarizeHeuristicData {
56
93
  * This class contains the heuristics for when to summarize.
57
94
  */
58
95
  export class SummarizeHeuristicRunner implements ISummarizeHeuristicRunner {
59
- private readonly idleTimer: Timer;
60
- private readonly minOpsForLastSummaryAttempt: number;
96
+ private readonly idleTimer: Timer | undefined;
97
+ private readonly runSummarize: (reason: SummarizeReason) => void;
61
98
 
62
99
  public constructor(
63
100
  private readonly heuristicData: ISummarizeHeuristicData,
64
101
  private readonly configuration: ISummaryConfigurationHeuristics,
65
- private readonly trySummarize: (reason: SummarizeReason) => void,
102
+ trySummarize: (reason: SummarizeReason) => void,
66
103
  private readonly logger: ITelemetryLogger,
104
+ private readonly summarizeStrategies: ISummaryHeuristicStrategy[] = getDefaultSummaryHeuristicStrategies(),
67
105
  ) {
68
106
  this.idleTimer = new Timer(
69
- this.configuration.idleTime,
70
- () => this.trySummarize("idle"));
71
- this.minOpsForLastSummaryAttempt = this.configuration.minOpsForLastSummaryAttempt;
107
+ this.idleTime,
108
+ () => this.runSummarize("idle"));
109
+
110
+ this.runSummarize = (reason: SummarizeReason) => {
111
+ this.idleTimer?.clear();
112
+
113
+ // We shouldn't attempt a summary if there are no new processed ops
114
+ const opsSinceLastAck = this.opsSinceLastAck;
115
+ if (opsSinceLastAck > 0) {
116
+ trySummarize(reason);
117
+ }
118
+ };
119
+ }
120
+
121
+ public get idleTime(): number {
122
+ const maxIdleTime = this.configuration.maxIdleTime;
123
+ const minIdleTime = this.configuration.minIdleTime;
124
+ const weightedNumOfOps = getWeightedNumberOfOps(
125
+ this.heuristicData.numRuntimeOps,
126
+ this.heuristicData.numNonRuntimeOps,
127
+ this.configuration.runtimeOpWeight,
128
+ this.configuration.nonRuntimeOpWeight,
129
+ );
130
+ const pToMaxOps = weightedNumOfOps * 1.0 / this.configuration.maxOps;
131
+
132
+ if (pToMaxOps >= 1) {
133
+ return minIdleTime;
134
+ }
135
+
136
+ // Return a ratioed idle time based on the percentage of ops
137
+ return maxIdleTime - ((maxIdleTime - minIdleTime) * pToMaxOps);
72
138
  }
73
139
 
74
140
  public get opsSinceLastAck(): number {
75
141
  return this.heuristicData.lastOpSequenceNumber - this.heuristicData.lastSuccessfulSummary.refSequenceNumber;
76
142
  }
77
143
 
144
+ public start() {
145
+ this.idleTimer?.start(this.idleTime);
146
+ }
147
+
78
148
  public run() {
79
- const timeSinceLastSummary = Date.now() - this.heuristicData.lastSuccessfulSummary.summaryTime;
80
- const opsSinceLastAck = this.opsSinceLastAck;
81
- if (timeSinceLastSummary > this.configuration.maxTime) {
82
- this.idleTimer.clear();
83
- this.trySummarize("maxTime");
84
- } else if (opsSinceLastAck > this.configuration.maxOps) {
85
- this.idleTimer.clear();
86
- this.trySummarize("maxOps");
87
- } else {
88
- this.idleTimer.restart();
149
+ for (const strategy of this.summarizeStrategies) {
150
+ if (strategy.shouldRunSummary(this.configuration, this.heuristicData)) {
151
+ return this.runSummarize(strategy.summarizeReason);
152
+ }
89
153
  }
154
+
155
+ this.idleTimer?.restart(this.idleTime);
90
156
  }
91
157
 
92
158
  public shouldRunLastSummary(): boolean {
93
159
  const opsSinceLastAck = this.opsSinceLastAck;
94
- const minOpsForLastSummaryAttempt = this.minOpsForLastSummaryAttempt;
160
+ const minOpsForLastSummaryAttempt = this.configuration.minOpsForLastSummaryAttempt;
95
161
 
96
162
  this.logger.sendTelemetryEvent({
97
163
  eventName: "ShouldRunLastSummary",
@@ -103,6 +169,54 @@ export class SummarizeHeuristicRunner implements ISummarizeHeuristicRunner {
103
169
  }
104
170
 
105
171
  public dispose() {
106
- this.idleTimer.clear();
172
+ this.idleTimer?.clear();
173
+ }
174
+ }
175
+
176
+ /** Strategy used to run a summary when it's been a while since our last successful summary */
177
+ class MaxTimeSummaryHeuristicStrategy implements ISummaryHeuristicStrategy {
178
+ public readonly summarizeReason: Readonly<SummarizeReason> = "maxTime";
179
+
180
+ public shouldRunSummary(
181
+ configuration: ISummaryConfigurationHeuristics,
182
+ heuristicData: ISummarizeHeuristicData,
183
+ ): boolean {
184
+ const timeSinceLastSummary = Date.now() - heuristicData.lastSuccessfulSummary.summaryTime;
185
+ return timeSinceLastSummary > configuration.maxTime;
107
186
  }
108
187
  }
188
+
189
+ function getWeightedNumberOfOps(
190
+ runtimeOpCount: number,
191
+ nonRuntimeOpCount: number,
192
+ runtimeOpWeight: number,
193
+ nonRuntimeOpWeight: number,
194
+ ): number {
195
+ return (runtimeOpWeight * runtimeOpCount)
196
+ + (nonRuntimeOpWeight * nonRuntimeOpCount);
197
+ }
198
+
199
+ /** Strategy used to do a weighted analysis on the ops we've processed since the last successful summary */
200
+ class WeightedOpsSummaryHeuristicStrategy implements ISummaryHeuristicStrategy {
201
+ public readonly summarizeReason: Readonly<SummarizeReason> = "maxOps";
202
+
203
+ public shouldRunSummary(
204
+ configuration: ISummaryConfigurationHeuristics,
205
+ heuristicData: ISummarizeHeuristicData,
206
+ ): boolean {
207
+ const weightedNumOfOps = getWeightedNumberOfOps(
208
+ heuristicData.numRuntimeOps,
209
+ heuristicData.numNonRuntimeOps,
210
+ configuration.runtimeOpWeight,
211
+ configuration.nonRuntimeOpWeight,
212
+ );
213
+ return weightedNumOfOps > configuration.maxOps;
214
+ }
215
+ }
216
+
217
+ function getDefaultSummaryHeuristicStrategies() {
218
+ return [
219
+ new MaxTimeSummaryHeuristicStrategy(),
220
+ new WeightedOpsSummaryHeuristicStrategy(),
221
+ ];
222
+ }
@@ -21,6 +21,8 @@ import {
21
21
  } from "@fluidframework/protocol-definitions";
22
22
  import { ISummaryStats } from "@fluidframework/runtime-definitions";
23
23
  import { ISummaryAckMessage, ISummaryNackMessage, ISummaryOpMessage } from "./summaryCollection";
24
+ import { SummarizeReason } from "./summaryGenerator";
25
+ import { ISummaryConfigurationHeuristics } from ".";
24
26
 
25
27
  /**
26
28
  * @deprecated - This will be removed in a later release.
@@ -98,7 +100,9 @@ export interface ISummarizerRuntime extends IConnectableRuntime {
98
100
  /** clientId of parent (non-summarizing) container that owns summarizer container */
99
101
  readonly summarizerClientId: string | undefined;
100
102
  closeFn(): void;
103
+ /** @deprecated 1.0, please remove all implementations and usage */
101
104
  on(event: "batchEnd", listener: (error: any, op: ISequencedDocumentMessage) => void): this;
105
+ /** @deprecated 1.0, please remove all implementations and usage */
102
106
  removeListener(event: "batchEnd", listener: (error: any, op: ISequencedDocumentMessage) => void): this;
103
107
  }
104
108
 
@@ -150,10 +154,6 @@ export interface IGeneratedSummaryStats extends ISummaryStats {
150
154
  readonly gcTotalBlobsSize?: number;
151
155
  /** The number of gc blobs in this summary. */
152
156
  readonly gcBlobNodeCount?: number;
153
- /** Sum of the sizes of all op contents since the last summary */
154
- readonly opsSizesSinceLastSummary: number;
155
- /** Number of non-system ops since the last summary. See {@link @fluidframework/protocol-base#isSystemMessage} */
156
- readonly nonSystemOpsSinceLastSummary: number;
157
157
  /** The summary number for a container's summary. Incremented on summaries throughout its lifetime. */
158
158
  readonly summaryNumber: number;
159
159
  }
@@ -361,6 +361,18 @@ export interface ISummarizeHeuristicData {
361
361
  /** Most recent summary that received an ack */
362
362
  readonly lastSuccessfulSummary: Readonly<ISummarizeAttempt>;
363
363
 
364
+ /** Number of runtime ops since last summary */
365
+ numRuntimeOps: number;
366
+
367
+ /** Number of non-runtime ops since last summary */
368
+ numNonRuntimeOps: number;
369
+
370
+ /** Cumulative size in bytes of all the ops since the last summary */
371
+ totalOpsSize: number;
372
+
373
+ /** Wether or not this instance contains adjusted metrics due to missing op data */
374
+ hasMissingOpData: boolean;
375
+
364
376
  /**
365
377
  * Updates lastAttempt and lastSuccessfulAttempt based on the last summary.
366
378
  * @param lastSummary - last ack summary
@@ -381,7 +393,10 @@ export interface ISummarizeHeuristicData {
381
393
 
382
394
  /** Responsible for running heuristics determining when to summarize. */
383
395
  export interface ISummarizeHeuristicRunner {
384
- /** Runs the heuristic to determine if it should try to summarize */
396
+ /** Start specific heuristic trackers (ex: idle timer) */
397
+ start(): void;
398
+
399
+ /** Runs the heuristics to determine if it should try to summarize */
385
400
  run(): void;
386
401
 
387
402
  /** Runs a different heuristic to check if it should summarize before closing */
@@ -408,6 +423,19 @@ export type ISummarizeTelemetryProperties =
408
423
  Pick<ITelemetryProperties, ISummarizeTelemetryRequiredProperties> &
409
424
  Partial<Pick<ITelemetryProperties, ISummarizeTelemetryOptionalProperties>>;
410
425
 
426
+ /** Strategy used to heuristically determine when we should run a summary */
427
+ export interface ISummaryHeuristicStrategy {
428
+ /** Summarize reason for this summarize heuristic strategy (ex: "maxTime") */
429
+ summarizeReason: Readonly<SummarizeReason>;
430
+
431
+ /**
432
+ * Determines if this strategy's summarize criteria been met
433
+ * @param configuration - summary configuration we are to check against
434
+ * @param heuristicData - heuristic data used to confirm conditions are met
435
+ */
436
+ shouldRunSummary(configuration: ISummaryConfigurationHeuristics, heuristicData: ISummarizeHeuristicData): boolean;
437
+ }
438
+
411
439
  type SummaryGeneratorRequiredTelemetryProperties =
412
440
  /** True to generate the full tree with no handle reuse optimizations */
413
441
  "fullTree" |
@@ -428,11 +456,10 @@ type SummaryGeneratorOptionalTelemetryProperties =
428
456
  /** Delta in sum of op sizes between the current reference sequence number and the reference
429
457
  * sequence number of the last summary */
430
458
  "opsSizesSinceLastSummary" |
431
- /**
432
- * Delta between the number of non-system ops since the last summary.
433
- * See {@link @fluidframework/protocol-base#isSystemMessage}
434
- */
435
- "nonSystemOpsSinceLastSummary" |
459
+ /** Delta between the number of non-runtime ops since the last summary */
460
+ "nonRuntimeOpsSinceLastSummary" |
461
+ /** Wether or not this instance contains adjusted metrics due to missing op data */
462
+ "hasMissingOpData" |
436
463
  /** Time it took to generate the summary tree and stats. */
437
464
  "generateDuration" |
438
465
  /** The handle returned by storage pointing to the uploaded summary tree. */
@@ -370,7 +370,7 @@ export class SummaryCollection extends TypedEventEmitter<ISummaryCollectionOpEve
370
370
  // Potential causes for it to be later than our initialSequenceNumber
371
371
  // are that the summaryOp was nacked then acked, double-acked, or
372
372
  // the summarySequenceNumber is incorrect.
373
- this.logger.sendErrorEvent({
373
+ this.logger.sendTelemetryEvent({
374
374
  eventName: "SummaryAckWithoutOp",
375
375
  sequenceNumber: op.sequenceNumber, // summary ack seq #
376
376
  summarySequenceNumber: seq, // missing summary seq #
@@ -73,7 +73,6 @@ export function getAttributesFormatVersion(attributes: ReadFluidDataStoreAttribu
73
73
  export function hasIsolatedChannels(attributes: ReadFluidDataStoreAttributes): boolean {
74
74
  return !!attributes.summaryFormatVersion && !attributes.disableIsolatedChannels;
75
75
  }
76
-
77
76
  export interface IContainerRuntimeMetadata extends ICreateContainerMetadata, IGCMetadata {
78
77
  readonly summaryFormatVersion: 1;
79
78
  /** The last message processed at the time of summary. Only primitive property types are added to the summary. */
@@ -82,11 +81,6 @@ export interface IContainerRuntimeMetadata extends ICreateContainerMetadata, IGC
82
81
  readonly disableIsolatedChannels?: true;
83
82
  /** The summary number for a container's summary. Incremented on summaries throughout its lifetime. */
84
83
  readonly summaryNumber?: number;
85
- /**
86
- * @deprecated - User summaryNumber instead.
87
- * Counter of the last summary happened, increments every time we summarize
88
- */
89
- readonly summaryCount?: number;
90
84
  }
91
85
 
92
86
  export interface ICreateContainerMetadata {
@@ -264,28 +264,7 @@ export class SummaryGenerator {
264
264
  opsSinceLastAttempt: referenceSequenceNumber - this.heuristicData.lastAttempt.refSequenceNumber,
265
265
  opsSinceLastSummary,
266
266
  };
267
- if (summaryData.stage !== "base") {
268
- summarizeTelemetryProps = {
269
- ...summarizeTelemetryProps,
270
- ...summaryData.summaryStats,
271
- generateDuration: summaryData.generateDuration,
272
- };
273
-
274
- if (summaryData.stage !== "generate") {
275
- summarizeTelemetryProps = {
276
- ...summarizeTelemetryProps,
277
- handle: summaryData.handle,
278
- uploadDuration: summaryData.uploadDuration,
279
- };
280
-
281
- if (summaryData.stage !== "upload") {
282
- summarizeTelemetryProps = {
283
- ...summarizeTelemetryProps,
284
- clientSequenceNumber: summaryData.clientSequenceNumber,
285
- };
286
- }
287
- }
288
- }
267
+ summarizeTelemetryProps = this.addSummaryDataToTelemetryProps(summaryData, summarizeTelemetryProps);
289
268
 
290
269
  if (summaryData.stage !== "submit") {
291
270
  return fail("submitSummaryFailure", summaryData.error, summarizeTelemetryProps);
@@ -408,6 +387,45 @@ export class SummaryGenerator {
408
387
  }
409
388
  }
410
389
 
390
+ private addSummaryDataToTelemetryProps(
391
+ summaryData: SubmitSummaryResult,
392
+ initialProps: SummaryGeneratorTelemetry,
393
+ ): SummaryGeneratorTelemetry {
394
+ switch (summaryData.stage) {
395
+ case "base": return initialProps;
396
+
397
+ case "generate": return {
398
+ ...initialProps,
399
+ ...summaryData.summaryStats,
400
+ generateDuration: summaryData.generateDuration,
401
+ };
402
+
403
+ case "upload": return {
404
+ ...initialProps,
405
+ ...summaryData.summaryStats,
406
+ generateDuration: summaryData.generateDuration,
407
+ handle: summaryData.handle,
408
+ uploadDuration: summaryData.uploadDuration,
409
+ };
410
+
411
+ case "submit": return {
412
+ ...initialProps,
413
+ ...summaryData.summaryStats,
414
+ generateDuration: summaryData.generateDuration,
415
+ handle: summaryData.handle,
416
+ uploadDuration: summaryData.uploadDuration,
417
+ clientSequenceNumber: summaryData.clientSequenceNumber,
418
+ hasMissingOpData: this.heuristicData.hasMissingOpData,
419
+ opsSizesSinceLastSummary: this.heuristicData.totalOpsSize,
420
+ nonRuntimeOpsSinceLastSummary: this.heuristicData.numNonRuntimeOps,
421
+ };
422
+
423
+ default: assert(true, "Unexpected summary stage");
424
+ }
425
+
426
+ return initialProps;
427
+ }
428
+
411
429
  private summarizeTimerHandler(time: number, count: number) {
412
430
  this.logger.sendPerformanceEvent({
413
431
  eventName: "SummarizeTimeout",
@@ -1,22 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { IDeltaManager } from "@fluidframework/container-definitions";
6
- import { IDocumentMessage, ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
7
- export declare class OpTracker {
8
- /**
9
- * Used for storing the message content size when
10
- * the message is pushed onto the inbound queue.
11
- */
12
- private readonly messageSize;
13
- private _nonSystemOpCount;
14
- get nonSystemOpCount(): number;
15
- private _opsSizeAccumulator;
16
- get opsSizeAccumulator(): number;
17
- constructor(deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>, disabled: boolean);
18
- private static messageId;
19
- private static messageHasData;
20
- reset(): void;
21
- }
22
- //# sourceMappingURL=opTelemetry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"opTelemetry.d.ts","sourceRoot":"","sources":["../src/opTelemetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EACH,gBAAgB,EAChB,yBAAyB,EAE5B,MAAM,sCAAsC,CAAC;AAG9C,qBAAa,SAAS;IAClB;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA6B;IACzD,OAAO,CAAC,iBAAiB,CAAa;IACtC,IAAW,gBAAgB,IAAI,MAAM,CAEpC;IAED,OAAO,CAAC,mBAAmB,CAAa;IACxC,IAAW,kBAAkB,IAAI,MAAM,CAEtC;gBAGG,YAAY,EAAE,aAAa,CAAC,yBAAyB,EAAE,gBAAgB,CAAC,EACxE,QAAQ,EAAE,OAAO;IA2BrB,OAAO,CAAC,MAAM,CAAC,SAAS;IAIxB,OAAO,CAAC,MAAM,CAAC,cAAc;IAItB,KAAK;CAIf"}
@@ -1,59 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.OpTracker = void 0;
8
- const driver_utils_1 = require("@fluidframework/driver-utils");
9
- class OpTracker {
10
- constructor(deltaManager, disabled) {
11
- /**
12
- * Used for storing the message content size when
13
- * the message is pushed onto the inbound queue.
14
- */
15
- this.messageSize = new Map();
16
- this._nonSystemOpCount = 0;
17
- this._opsSizeAccumulator = 0;
18
- if (disabled) {
19
- return;
20
- }
21
- // Record the message content size when we receive it.
22
- // We should not log this value, as summarization can happen between the time the message
23
- // is received and until it is processed (the 'op' event).
24
- deltaManager.inbound.on("push", (message) => {
25
- // Some messages my already have string contents at this point,
26
- // so stringifying them again will add inaccurate overhead.
27
- const messageContent = typeof message.contents === "string" ?
28
- message.contents :
29
- JSON.stringify(message.contents);
30
- const messageData = OpTracker.messageHasData(message) ? message.data : "";
31
- this.messageSize[OpTracker.messageId(message)] = messageContent.length + messageData.length;
32
- });
33
- deltaManager.on("op", (message) => {
34
- var _a;
35
- this._nonSystemOpCount += !(0, driver_utils_1.isRuntimeMessage)(message) ? 0 : 1;
36
- const id = OpTracker.messageId(message);
37
- this._opsSizeAccumulator += (_a = this.messageSize[id]) !== null && _a !== void 0 ? _a : 0;
38
- this.messageSize.delete(id);
39
- });
40
- }
41
- get nonSystemOpCount() {
42
- return this._nonSystemOpCount;
43
- }
44
- get opsSizeAccumulator() {
45
- return this._opsSizeAccumulator;
46
- }
47
- static messageId(message) {
48
- return message.sequenceNumber;
49
- }
50
- static messageHasData(message) {
51
- return message.data !== undefined;
52
- }
53
- reset() {
54
- this._nonSystemOpCount = 0;
55
- this._opsSizeAccumulator = 0;
56
- }
57
- }
58
- exports.OpTracker = OpTracker;
59
- //# sourceMappingURL=opTelemetry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"opTelemetry.js","sourceRoot":"","sources":["../src/opTelemetry.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,+DAAgE;AAEhE,MAAa,SAAS;IAgBlB,YACI,YAAwE,EACxE,QAAiB;QAjBrB;;;WAGG;QACc,gBAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;QACjD,sBAAiB,GAAW,CAAC,CAAC;QAK9B,wBAAmB,GAAW,CAAC,CAAC;QASpC,IAAI,QAAQ,EAAE;YACV,OAAO;SACV;QAED,sDAAsD;QACtD,yFAAyF;QACzF,0DAA0D;QAC1D,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,OAAkC,EAAE,EAAE;YACnE,+DAA+D;YAC/D,2DAA2D;YAC3D,MAAM,cAAc,GAAG,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;gBACzD,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAClB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACrC,MAAM,WAAW,GAAG,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1E,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,GAAG,cAAc,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;QAChG,CAAC,CAAC,CAAC;QAEH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,OAAkC,EAAE,EAAE;;YACzD,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAA,+BAAgB,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7D,MAAM,EAAE,GAAG,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YACxC,IAAI,CAAC,mBAAmB,IAAI,MAAA,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,mCAAI,CAAC,CAAC;YACtD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;IACP,CAAC;IApCD,IAAW,gBAAgB;QACvB,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAClC,CAAC;IAGD,IAAW,kBAAkB;QACzB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IACpC,CAAC;IA+BO,MAAM,CAAC,SAAS,CAAC,OAAkC;QACvD,OAAO,OAAO,CAAC,cAAc,CAAC;IAClC,CAAC;IAEO,MAAM,CAAC,cAAc,CAAC,OAAkC;QAC5D,OAAQ,OAA2C,CAAC,IAAI,KAAK,SAAS,CAAC;IAC3E,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC;QAC3B,IAAI,CAAC,mBAAmB,GAAG,CAAC,CAAC;IACjC,CAAC;CACJ;AAzDD,8BAyDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDeltaManager } from \"@fluidframework/container-definitions\";\nimport {\n IDocumentMessage,\n ISequencedDocumentMessage,\n ISequencedDocumentSystemMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport { isRuntimeMessage } from \"@fluidframework/driver-utils\";\n\nexport class OpTracker {\n /**\n * Used for storing the message content size when\n * the message is pushed onto the inbound queue.\n */\n private readonly messageSize = new Map<number, number>();\n private _nonSystemOpCount: number = 0;\n public get nonSystemOpCount(): number {\n return this._nonSystemOpCount;\n }\n\n private _opsSizeAccumulator: number = 0;\n public get opsSizeAccumulator(): number {\n return this._opsSizeAccumulator;\n }\n\n public constructor(\n deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n disabled: boolean,\n ) {\n if (disabled) {\n return;\n }\n\n // Record the message content size when we receive it.\n // We should not log this value, as summarization can happen between the time the message\n // is received and until it is processed (the 'op' event).\n deltaManager.inbound.on(\"push\", (message: ISequencedDocumentMessage) => {\n // Some messages my already have string contents at this point,\n // so stringifying them again will add inaccurate overhead.\n const messageContent = typeof message.contents === \"string\" ?\n message.contents :\n JSON.stringify(message.contents);\n const messageData = OpTracker.messageHasData(message) ? message.data : \"\";\n this.messageSize[OpTracker.messageId(message)] = messageContent.length + messageData.length;\n });\n\n deltaManager.on(\"op\", (message: ISequencedDocumentMessage) => {\n this._nonSystemOpCount += !isRuntimeMessage(message) ? 0 : 1;\n const id = OpTracker.messageId(message);\n this._opsSizeAccumulator += this.messageSize[id] ?? 0;\n this.messageSize.delete(id);\n });\n }\n\n private static messageId(message: ISequencedDocumentMessage): number {\n return message.sequenceNumber;\n }\n\n private static messageHasData(message: ISequencedDocumentMessage): message is ISequencedDocumentSystemMessage {\n return (message as ISequencedDocumentSystemMessage).data !== undefined;\n }\n\n public reset() {\n this._nonSystemOpCount = 0;\n this._opsSizeAccumulator = 0;\n }\n}\n"]}
@@ -1,22 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { IDeltaManager } from "@fluidframework/container-definitions";
6
- import { IDocumentMessage, ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
7
- export declare class OpTracker {
8
- /**
9
- * Used for storing the message content size when
10
- * the message is pushed onto the inbound queue.
11
- */
12
- private readonly messageSize;
13
- private _nonSystemOpCount;
14
- get nonSystemOpCount(): number;
15
- private _opsSizeAccumulator;
16
- get opsSizeAccumulator(): number;
17
- constructor(deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>, disabled: boolean);
18
- private static messageId;
19
- private static messageHasData;
20
- reset(): void;
21
- }
22
- //# sourceMappingURL=opTelemetry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"opTelemetry.d.ts","sourceRoot":"","sources":["../src/opTelemetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EACH,gBAAgB,EAChB,yBAAyB,EAE5B,MAAM,sCAAsC,CAAC;AAG9C,qBAAa,SAAS;IAClB;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA6B;IACzD,OAAO,CAAC,iBAAiB,CAAa;IACtC,IAAW,gBAAgB,IAAI,MAAM,CAEpC;IAED,OAAO,CAAC,mBAAmB,CAAa;IACxC,IAAW,kBAAkB,IAAI,MAAM,CAEtC;gBAGG,YAAY,EAAE,aAAa,CAAC,yBAAyB,EAAE,gBAAgB,CAAC,EACxE,QAAQ,EAAE,OAAO;IA2BrB,OAAO,CAAC,MAAM,CAAC,SAAS;IAIxB,OAAO,CAAC,MAAM,CAAC,cAAc;IAItB,KAAK;CAIf"}
@@ -1,55 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { isRuntimeMessage } from "@fluidframework/driver-utils";
6
- export class OpTracker {
7
- constructor(deltaManager, disabled) {
8
- /**
9
- * Used for storing the message content size when
10
- * the message is pushed onto the inbound queue.
11
- */
12
- this.messageSize = new Map();
13
- this._nonSystemOpCount = 0;
14
- this._opsSizeAccumulator = 0;
15
- if (disabled) {
16
- return;
17
- }
18
- // Record the message content size when we receive it.
19
- // We should not log this value, as summarization can happen between the time the message
20
- // is received and until it is processed (the 'op' event).
21
- deltaManager.inbound.on("push", (message) => {
22
- // Some messages my already have string contents at this point,
23
- // so stringifying them again will add inaccurate overhead.
24
- const messageContent = typeof message.contents === "string" ?
25
- message.contents :
26
- JSON.stringify(message.contents);
27
- const messageData = OpTracker.messageHasData(message) ? message.data : "";
28
- this.messageSize[OpTracker.messageId(message)] = messageContent.length + messageData.length;
29
- });
30
- deltaManager.on("op", (message) => {
31
- var _a;
32
- this._nonSystemOpCount += !isRuntimeMessage(message) ? 0 : 1;
33
- const id = OpTracker.messageId(message);
34
- this._opsSizeAccumulator += (_a = this.messageSize[id]) !== null && _a !== void 0 ? _a : 0;
35
- this.messageSize.delete(id);
36
- });
37
- }
38
- get nonSystemOpCount() {
39
- return this._nonSystemOpCount;
40
- }
41
- get opsSizeAccumulator() {
42
- return this._opsSizeAccumulator;
43
- }
44
- static messageId(message) {
45
- return message.sequenceNumber;
46
- }
47
- static messageHasData(message) {
48
- return message.data !== undefined;
49
- }
50
- reset() {
51
- this._nonSystemOpCount = 0;
52
- this._opsSizeAccumulator = 0;
53
- }
54
- }
55
- //# sourceMappingURL=opTelemetry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"opTelemetry.js","sourceRoot":"","sources":["../src/opTelemetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,MAAM,OAAO,SAAS;IAgBlB,YACI,YAAwE,EACxE,QAAiB;QAjBrB;;;WAGG;QACc,gBAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;QACjD,sBAAiB,GAAW,CAAC,CAAC;QAK9B,wBAAmB,GAAW,CAAC,CAAC;QASpC,IAAI,QAAQ,EAAE;YACV,OAAO;SACV;QAED,sDAAsD;QACtD,yFAAyF;QACzF,0DAA0D;QAC1D,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,OAAkC,EAAE,EAAE;YACnE,+DAA+D;YAC/D,2DAA2D;YAC3D,MAAM,cAAc,GAAG,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;gBACzD,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAClB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACrC,MAAM,WAAW,GAAG,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1E,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,GAAG,cAAc,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;QAChG,CAAC,CAAC,CAAC;QAEH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,OAAkC,EAAE,EAAE;;YACzD,IAAI,CAAC,iBAAiB,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7D,MAAM,EAAE,GAAG,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YACxC,IAAI,CAAC,mBAAmB,IAAI,MAAA,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,mCAAI,CAAC,CAAC;YACtD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;IACP,CAAC;IApCD,IAAW,gBAAgB;QACvB,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAClC,CAAC;IAGD,IAAW,kBAAkB;QACzB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IACpC,CAAC;IA+BO,MAAM,CAAC,SAAS,CAAC,OAAkC;QACvD,OAAO,OAAO,CAAC,cAAc,CAAC;IAClC,CAAC;IAEO,MAAM,CAAC,cAAc,CAAC,OAAkC;QAC5D,OAAQ,OAA2C,CAAC,IAAI,KAAK,SAAS,CAAC;IAC3E,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC;QAC3B,IAAI,CAAC,mBAAmB,GAAG,CAAC,CAAC;IACjC,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDeltaManager } from \"@fluidframework/container-definitions\";\nimport {\n IDocumentMessage,\n ISequencedDocumentMessage,\n ISequencedDocumentSystemMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport { isRuntimeMessage } from \"@fluidframework/driver-utils\";\n\nexport class OpTracker {\n /**\n * Used for storing the message content size when\n * the message is pushed onto the inbound queue.\n */\n private readonly messageSize = new Map<number, number>();\n private _nonSystemOpCount: number = 0;\n public get nonSystemOpCount(): number {\n return this._nonSystemOpCount;\n }\n\n private _opsSizeAccumulator: number = 0;\n public get opsSizeAccumulator(): number {\n return this._opsSizeAccumulator;\n }\n\n public constructor(\n deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n disabled: boolean,\n ) {\n if (disabled) {\n return;\n }\n\n // Record the message content size when we receive it.\n // We should not log this value, as summarization can happen between the time the message\n // is received and until it is processed (the 'op' event).\n deltaManager.inbound.on(\"push\", (message: ISequencedDocumentMessage) => {\n // Some messages my already have string contents at this point,\n // so stringifying them again will add inaccurate overhead.\n const messageContent = typeof message.contents === \"string\" ?\n message.contents :\n JSON.stringify(message.contents);\n const messageData = OpTracker.messageHasData(message) ? message.data : \"\";\n this.messageSize[OpTracker.messageId(message)] = messageContent.length + messageData.length;\n });\n\n deltaManager.on(\"op\", (message: ISequencedDocumentMessage) => {\n this._nonSystemOpCount += !isRuntimeMessage(message) ? 0 : 1;\n const id = OpTracker.messageId(message);\n this._opsSizeAccumulator += this.messageSize[id] ?? 0;\n this.messageSize.delete(id);\n });\n }\n\n private static messageId(message: ISequencedDocumentMessage): number {\n return message.sequenceNumber;\n }\n\n private static messageHasData(message: ISequencedDocumentMessage): message is ISequencedDocumentSystemMessage {\n return (message as ISequencedDocumentSystemMessage).data !== undefined;\n }\n\n public reset() {\n this._nonSystemOpCount = 0;\n this._opsSizeAccumulator = 0;\n }\n}\n"]}