@fluidframework/container-runtime 2.0.0-dev.1.3.0.96595 → 2.0.0-dev.1.4.5.105745
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.
- package/dist/containerRuntime.d.ts +1 -1
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +0 -1
- package/dist/containerRuntime.js.map +1 -1
- package/dist/garbageCollection.js +3 -3
- package/dist/garbageCollection.js.map +1 -1
- package/dist/gcSweepReadyUsageDetection.d.ts.map +1 -1
- package/dist/gcSweepReadyUsageDetection.js +12 -3
- package/dist/gcSweepReadyUsageDetection.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/summarizerHeuristics.d.ts.map +1 -1
- package/dist/summarizerHeuristics.js +3 -0
- package/dist/summarizerHeuristics.js.map +1 -1
- package/lib/containerRuntime.d.ts +1 -1
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +0 -1
- package/lib/containerRuntime.js.map +1 -1
- package/lib/garbageCollection.js +3 -3
- package/lib/garbageCollection.js.map +1 -1
- package/lib/gcSweepReadyUsageDetection.d.ts.map +1 -1
- package/lib/gcSweepReadyUsageDetection.js +12 -3
- package/lib/gcSweepReadyUsageDetection.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/summarizerHeuristics.d.ts.map +1 -1
- package/lib/summarizerHeuristics.js +3 -0
- package/lib/summarizerHeuristics.js.map +1 -1
- package/package.json +21 -18
- package/src/containerRuntime.ts +1 -3
- package/src/garbageCollection.ts +3 -3
- package/src/gcSweepReadyUsageDetection.ts +10 -2
- package/src/packageVersion.ts +1 -1
- package/src/summarizerHeuristics.ts +3 -0
|
@@ -1 +1 @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AC;YAExE,+DAA+D;YAC/D,IAAI,aAAa,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,aAAa,GAAG,mBAAmB,GAAG,QAAQ,EAAE;gBAC5F,WAAW,GAAG,KAAK,CAAC;aACvB;SACJ;QAED,MAAM,KAAK,GAAG,IAAI,oBAAoB,CAClC,iDAAiD,EACjD,EAAE,YAAY,EAAE,IAAI,CAAC,SAAS,iCAAM,UAAU,KAAE,aAAa,EAAE,mBAAmB,IAAG,EAAE,CAC1F,CAAC;QACF,IAAI,WAAW,EAAE;YACb,qDAAqD;YACrD,8FAA8F;YAC9F,mGAAmG;YACnG,eAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;YACzE,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,0BAA0B,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC;YAEvF,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;SACvB;aAAM;YACH,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,+BAA+B,EAAE,EAAE,KAAK,CAAC,CAAC;SACxF;IACL,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport {\n IConfigProvider,\n IFluidErrorBase,\n LoggingError,\n MonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport { oneDayMs } from \"./garbageCollection\";\n\n/**\n * Feature Gate Key -\n * How many days between closing the container from this error (avoids locking user out of their file altogether)\n */\nexport const skipClosureForXDaysKey = \"Fluid.GarbageCollection.Dogfood.SweepReadyUsageDetection.SkipClosureForXDays\";\n\n/**\n * LocalStorage key (NOT via feature gate / monitoring context)\n * A map from docId to info about the last time we closed due to this error\n */\nexport const closuresMapLocalStorageKey = \"Fluid.GarbageCollection.Dogfood.SweepReadyUsageDetection.Closures\";\n\n/**\n * Feature gate key to enable closing the container if SweepReady objects are used.\n * Value should contain keywords \"interactiveClient\" and/or \"summarizer\" to enable detection in each container type\n */\nconst sweepReadyUsageDetectionSetting = {\n read(config: IConfigProvider) {\n const sweepReadyUsageDetectionKey = \"Fluid.GarbageCollection.Dogfood.SweepReadyUsageDetection\";\n const value = config.getString(sweepReadyUsageDetectionKey);\n if (value === undefined) {\n return { interactiveClient: false, summarizer: false };\n }\n return {\n interactiveClient: value.includes(\"interactiveClient\"),\n summarizer: value.includes(\"summarizer\"),\n };\n },\n};\n\n/**\n * Error class raised when a SweepReady object is used, indicating a bug in how\n * references are managed in the container by the application, or a bug in how\n * GC tracks those references.\n *\n * There's a chance for false positives when this error is raised by an Interactive Container,\n * since only the Summarizer has the latest truth about unreferenced node tracking\n */\nexport class SweepReadyUsageError extends LoggingError implements IFluidErrorBase {\n /** This errorType will be in temporary use (until Sweep is fully implemented) so don't add to any errorType type */\n public errorType: string = \"unreferencedObjectUsedAfterGarbageCollected\";\n}\n\n/**\n * This class encapsulates the logic around what to do when a SweepReady object is used.\n * There are several tactics we plan to use in Dogfood environments to aid diagnosis of these cases:\n * - Closing the interactive container when either the interactive or summarizer client detects this kind of violation\n * (via sweepReadyUsageDetectionSetting above)\n * - Throttling the frequency of these crashes via a \"Skip Closure Period\" per container per device\n * (via skipClosureForXDaysKey above. Uses localStorage and closuresMapLocalStorageKey to implement this behavior)\n */\nexport class SweepReadyUsageDetectionHandler {\n private readonly localStorage: Pick<Storage, \"getItem\" | \"setItem\">;\n\n constructor(\n private readonly uniqueContainerKey: string,\n private readonly mc: MonitoringContext,\n private readonly closeFn: (error?: ICriticalContainerError) => void,\n localStorageOverride?: Pick<Storage, \"getItem\" | \"setItem\">,\n ) {\n const noopStorage = { getItem: () => null, setItem: () => {} };\n // localStorage is not defined in Node environment, so fall back to noopStorage if needed.\n this.localStorage = localStorageOverride ?? globalThis.localStorage ?? noopStorage;\n\n if (this.localStorage === noopStorage) {\n // This means the Skip Closure Period logic will not work.\n this.mc.logger.sendTelemetryEvent({ eventName: \"SweepReadyUsageDetectionHandlerNoopStorage\" });\n }\n }\n\n /**\n * If SweepReady Usage Detection is enabled, close the interactive container.\n * If the SkipClosureForXDays setting is set, don't close the container more than once in that period.\n *\n * Once Sweep is fully implemented, this will be removed since the objects will be gone\n * and errors will arise elsewhere in the runtime\n */\n public usageDetectedInInteractiveClient(errorProps: ITelemetryProperties) {\n if (!sweepReadyUsageDetectionSetting.read(this.mc.config).interactiveClient) {\n return;\n }\n\n // Default stance is we close every time - this reflects the severity of SweepReady Object Usage.\n // However, we may choose to \"throttle\" the closures by setting the SkipClosureForXDays setting,\n // which will only allow the container to close once during that period, to avoid locking users out.\n let shouldClose: boolean = true;\n let pastClosuresMap: Record<string, { lastCloseTime: number; } | undefined> = {};\n let lastCloseTime: number | undefined;\n const skipClosureForXDays = this.mc.config.getNumber(skipClosureForXDaysKey);\n if (skipClosureForXDays !== undefined) {\n // Read pastClosuresMap from localStorage then extract the lastCloseTime from the map\n try {\n const rawValue = this.localStorage.getItem(closuresMapLocalStorageKey);\n const parsedValue = rawValue === null ? {} : JSON.parse(rawValue);\n if (typeof parsedValue === \"object\") {\n pastClosuresMap = parsedValue;\n }\n } catch (e) {\n }\n lastCloseTime = pastClosuresMap[this.uniqueContainerKey]?.lastCloseTime;\n\n // Don't close if we did already within the Skip Closure Period\n if (lastCloseTime !== undefined && Date.now() < lastCloseTime + skipClosureForXDays * oneDayMs) {\n shouldClose = false;\n }\n }\n\n const error = new SweepReadyUsageError(\n \"SweepReady object used in Non-Summarizer Client\",\n { errorDetails: JSON.stringify({ ...errorProps, lastCloseTime, skipClosureForXDays }) },\n );\n if (shouldClose) {\n // Update closures map in localStorage before closing\n // Note there is a race condition between different tabs updating localStorage and overwriting\n // each others' updates. If so, some tab will crash again. Just reload one at a time to get unstuck\n pastClosuresMap[this.uniqueContainerKey] = { lastCloseTime: Date.now() };\n this.localStorage.setItem(closuresMapLocalStorageKey, JSON.stringify(pastClosuresMap));\n\n this.closeFn(error);\n } else {\n this.mc.logger.sendErrorEvent({ eventName: \"SweepReadyObject_UsageAllowed\" }, error);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"gcSweepReadyUsageDetection.js","sourceRoot":"","sources":["../src/gcSweepReadyUsageDetection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAGH,YAAY,GAEf,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,8EAA8E,CAAC;AAErH;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,mEAAmE,CAAC;AAE9G;;;GAGG;AACH,MAAM,+BAA+B,GAAG;IACpC,IAAI,CAAC,MAAuB;QACxB,MAAM,2BAA2B,GAAG,0DAA0D,CAAC;QAC/F,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC;QAC5D,IAAI,KAAK,KAAK,SAAS,EAAE;YACrB,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;SAC1D;QACD,OAAO;YACH,iBAAiB,EAAE,KAAK,CAAC,QAAQ,CAAC,mBAAmB,CAAC;YACtD,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC;SAC3C,CAAC;IACN,CAAC;CACJ,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,OAAO,oBAAqB,SAAQ,YAAY;IAAtD;;QACI,oHAAoH;QAC7G,cAAS,GAAW,6CAA6C,CAAC;IAC7E,CAAC;CAAA;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,+BAA+B;IAGxC,YACqB,kBAA0B,EAC1B,EAAqB,E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nimport { ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport {\n IConfigProvider,\n IFluidErrorBase,\n LoggingError,\n MonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport { oneDayMs } from \"./garbageCollection\";\n\n/**\n * Feature Gate Key -\n * How many days between closing the container from this error (avoids locking user out of their file altogether)\n */\nexport const skipClosureForXDaysKey = \"Fluid.GarbageCollection.Dogfood.SweepReadyUsageDetection.SkipClosureForXDays\";\n\n/**\n * LocalStorage key (NOT via feature gate / monitoring context)\n * A map from docId to info about the last time we closed due to this error\n */\nexport const closuresMapLocalStorageKey = \"Fluid.GarbageCollection.Dogfood.SweepReadyUsageDetection.Closures\";\n\n/**\n * Feature gate key to enable closing the container if SweepReady objects are used.\n * Value should contain keywords \"interactiveClient\" and/or \"summarizer\" to enable detection in each container type\n */\nconst sweepReadyUsageDetectionSetting = {\n read(config: IConfigProvider) {\n const sweepReadyUsageDetectionKey = \"Fluid.GarbageCollection.Dogfood.SweepReadyUsageDetection\";\n const value = config.getString(sweepReadyUsageDetectionKey);\n if (value === undefined) {\n return { interactiveClient: false, summarizer: false };\n }\n return {\n interactiveClient: value.includes(\"interactiveClient\"),\n summarizer: value.includes(\"summarizer\"),\n };\n },\n};\n\n/**\n * Error class raised when a SweepReady object is used, indicating a bug in how\n * references are managed in the container by the application, or a bug in how\n * GC tracks those references.\n *\n * There's a chance for false positives when this error is raised by an Interactive Container,\n * since only the Summarizer has the latest truth about unreferenced node tracking\n */\nexport class SweepReadyUsageError extends LoggingError implements IFluidErrorBase {\n /** This errorType will be in temporary use (until Sweep is fully implemented) so don't add to any errorType type */\n public errorType: string = \"unreferencedObjectUsedAfterGarbageCollected\";\n}\n\n/**\n * This class encapsulates the logic around what to do when a SweepReady object is used.\n * There are several tactics we plan to use in Dogfood environments to aid diagnosis of these cases:\n * - Closing the interactive container when either the interactive or summarizer client detects this kind of violation\n * (via sweepReadyUsageDetectionSetting above)\n * - Throttling the frequency of these crashes via a \"Skip Closure Period\" per container per device\n * (via skipClosureForXDaysKey above. Uses localStorage and closuresMapLocalStorageKey to implement this behavior)\n */\nexport class SweepReadyUsageDetectionHandler {\n private readonly localStorage: Pick<Storage, \"getItem\" | \"setItem\">;\n\n constructor(\n private readonly uniqueContainerKey: string,\n private readonly mc: MonitoringContext,\n private readonly closeFn: (error?: ICriticalContainerError) => void,\n localStorageOverride?: Pick<Storage, \"getItem\" | \"setItem\">,\n ) {\n const noopStorage = { getItem: () => null, setItem: () => {} };\n if (localStorageOverride !== undefined) {\n this.localStorage = localStorageOverride;\n } else {\n try {\n // localStorage is not defined in Node environment so this throws\n this.localStorage = localStorage ?? noopStorage;\n } catch (error) {\n this.localStorage = noopStorage;\n }\n }\n\n if (this.localStorage === noopStorage) {\n // This means the Skip Closure Period logic will not work.\n this.mc.logger.sendTelemetryEvent({ eventName: \"SweepReadyUsageDetectionHandlerNoopStorage\" });\n }\n }\n\n /**\n * If SweepReady Usage Detection is enabled, close the interactive container.\n * If the SkipClosureForXDays setting is set, don't close the container more than once in that period.\n *\n * Once Sweep is fully implemented, this will be removed since the objects will be gone\n * and errors will arise elsewhere in the runtime\n */\n public usageDetectedInInteractiveClient(errorProps: ITelemetryProperties) {\n if (!sweepReadyUsageDetectionSetting.read(this.mc.config).interactiveClient) {\n return;\n }\n\n // Default stance is we close every time - this reflects the severity of SweepReady Object Usage.\n // However, we may choose to \"throttle\" the closures by setting the SkipClosureForXDays setting,\n // which will only allow the container to close once during that period, to avoid locking users out.\n let shouldClose: boolean = true;\n let pastClosuresMap: Record<string, { lastCloseTime: number; } | undefined> = {};\n let lastCloseTime: number | undefined;\n const skipClosureForXDays = this.mc.config.getNumber(skipClosureForXDaysKey);\n if (skipClosureForXDays !== undefined) {\n // Read pastClosuresMap from localStorage then extract the lastCloseTime from the map\n try {\n const rawValue = this.localStorage.getItem(closuresMapLocalStorageKey);\n const parsedValue = rawValue === null ? {} : JSON.parse(rawValue);\n if (typeof parsedValue === \"object\") {\n pastClosuresMap = parsedValue;\n }\n } catch (e) {\n }\n lastCloseTime = pastClosuresMap[this.uniqueContainerKey]?.lastCloseTime;\n\n // Don't close if we did already within the Skip Closure Period\n if (lastCloseTime !== undefined && Date.now() < lastCloseTime + skipClosureForXDays * oneDayMs) {\n shouldClose = false;\n }\n }\n\n const error = new SweepReadyUsageError(\n \"SweepReady object used in Non-Summarizer Client\",\n { errorDetails: JSON.stringify({ ...errorProps, lastCloseTime, skipClosureForXDays }) },\n );\n if (shouldClose) {\n // Update closures map in localStorage before closing\n // Note there is a race condition between different tabs updating localStorage and overwriting\n // each others' updates. If so, some tab will crash again. Just reload one at a time to get unstuck\n pastClosuresMap[this.uniqueContainerKey] = { lastCloseTime: Date.now() };\n this.localStorage.setItem(closuresMapLocalStorageKey, JSON.stringify(pastClosuresMap));\n\n this.closeFn(error);\n } else {\n this.mc.logger.sendErrorEvent({ eventName: \"SweepReadyObject_UsageAllowed\" }, error);\n }\n }\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/container-runtime";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-dev.1.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-dev.1.4.5.105745";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,sCAAsC,CAAC;AAC3D,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,sCAAsC,CAAC;AAC3D,eAAO,MAAM,UAAU,2BAA2B,CAAC"}
|
package/lib/packageVersion.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export const pkgName = "@fluidframework/container-runtime";
|
|
8
|
-
export const pkgVersion = "2.0.0-dev.1.
|
|
8
|
+
export const pkgVersion = "2.0.0-dev.1.4.5.105745";
|
|
9
9
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,mCAAmC,CAAC;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,mCAAmC,CAAC;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-runtime\";\nexport const pkgVersion = \"2.0.0-dev.1.4.5.105745\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summarizerHeuristics.d.ts","sourceRoot":"","sources":["../src/summarizerHeuristics.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EAAE,+BAA+B,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EACH,uBAAuB,E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AKrE,aAAa,CAAC,iBAAiB,CAAC,EAAE,MAAM;IAWxC,2BAA2B;CAYrC;AAED;;GAEG;AACH,qBAAa,wBAAyB,YAAW,yBAAyB;IAKlE,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAE9B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IARxC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAoB;IAC9C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAoC;gBAG5C,aAAa,EAAE,uBAAuB,EACtC,aAAa,EAAE,+BAA+B,EAC/D,YAAY,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,EAC9B,MAAM,EAAE,gBAAgB,EACxB,mBAAmB,GAAE,yBAAyB,EAA2C;IAiB9G,IAAW,QAAQ,IAAI,MAAM,CAoB5B;IAED,IAAW,eAAe,IAAI,MAAM,CAEnC;IAEM,KAAK;IAIL,GAAG;IAUH,oBAAoB,IAAI,OAAO;IAa/B,OAAO;CAGjB"}
|
|
@@ -82,6 +82,9 @@ export class SummarizeHeuristicRunner {
|
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
get idleTime() {
|
|
85
|
+
if (this.configuration.idleTime !== undefined) {
|
|
86
|
+
return this.configuration.idleTime;
|
|
87
|
+
}
|
|
85
88
|
const maxIdleTime = this.configuration.maxIdleTime;
|
|
86
89
|
const minIdleTime = this.configuration.minIdleTime;
|
|
87
90
|
const weightedNumOfOps = getWeightedNumberOfOps(this.heuristicData.numRuntimeOps, this.heuristicData.numNonRuntimeOps, this.configuration.runtimeOpWeight, this.configuration.nonRuntimeOpWeight);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summarizerHeuristics.js","sourceRoot":"","sources":["../src/summarizerHeuristics.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,8BA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CAAC,CAAC;QAEH,OAAO,eAAe,IAAI,2BAA2B,CAAC;IAC1D,CAAC;IAEM,OAAO;;QACV,MAAA,IAAI,CAAC,SAAS,0CAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACJ;AAED,8FAA8F;AAC9F,MAAM,+BAA+B;IAArC;QACoB,oBAAe,GAA8B,SAAS,CAAC;IAS3E,CAAC;IAPU,gBAAgB,CACnB,aAA8C,EAC9C,aAAsC;QAEtC,MAAM,oBAAoB,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,aAAa,CAAC,qBAAqB,CAAC,WAAW,CAAC;QAC1F,OAAO,oBAAoB,GAAG,aAAa,CAAC,OAAO,CAAC;IACxD,CAAC;CACJ;AAED,SAAS,sBAAsB,CAC3B,cAAsB,EACtB,iBAAyB,EACzB,eAAuB,EACvB,kBAA0B;IAE1B,OAAO,CAAC,eAAe,GAAG,cAAc,CAAC;UAClC,CAAC,kBAAkB,GAAG,iBAAiB,CAAC,CAAC;AACpD,CAAC;AAED,2GAA2G;AAC3G,MAAM,mCAAmC;IAAzC;QACoB,oBAAe,GAA8B,QAAQ,CAAC;IAc1E,CAAC;IAZU,gBAAgB,CACnB,aAA8C,EAC9C,aAAsC;QAEtC,MAAM,gBAAgB,GAAG,sBAAsB,CAC3C,aAAa,CAAC,aAAa,EAC3B,aAAa,CAAC,gBAAgB,EAC9B,aAAa,CAAC,eAAe,EAC7B,aAAa,CAAC,kBAAkB,CACnC,CAAC;QACF,OAAO,gBAAgB,GAAG,aAAa,CAAC,MAAM,CAAC;IACnD,CAAC;CACJ;AAED,SAAS,oCAAoC;IACzC,OAAO;QACH,IAAI,+BAA+B,EAAE;QACrC,IAAI,mCAAmC,EAAE;KAC5C,CAAC;AACN,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { Timer } from \"@fluidframework/common-utils\";\nimport { ISummaryConfigurationHeuristics } from \"./containerRuntime\";\nimport {\n ISummarizeHeuristicData,\n ISummarizeHeuristicRunner,\n ISummarizeAttempt,\n ISummaryHeuristicStrategy,\n} from \"./summarizerTypes\";\nimport { SummarizeReason } from \"./summaryGenerator\";\n\n/** Simple implementation of class for tracking summarize heuristic data. */\nexport class SummarizeHeuristicData implements ISummarizeHeuristicData {\n protected _lastAttempt: ISummarizeAttempt;\n public get lastAttempt(): ISummarizeAttempt {\n return this._lastAttempt;\n }\n\n protected _lastSuccessfulSummary: Readonly<ISummarizeAttempt>;\n public get lastSuccessfulSummary(): Readonly<ISummarizeAttempt> {\n return this._lastSuccessfulSummary;\n }\n\n public numNonRuntimeOps: number = 0;\n public totalOpsSize: number = 0;\n public hasMissingOpData: boolean = false;\n\n /**\n * Cumulative size in bytes of all the ops at the beginning of the summarization attempt.\n * Is used to adjust totalOpsSize appropriately after successful summarization.\n */\n /** */\n private totalOpsSizeBefore: number = 0;\n\n /**\n * Number of system ops at beginning of attempting to summarize.\n * Is used to adjust numSystemOps appropriately after successful summarization.\n */\n private numSystemOpsBefore: number = 0;\n\n public numRuntimeOps: number = 0;\n /**\n * Number of non-system ops at beginning of attempting to summarize.\n * Is used to adjust numNonSystemOps appropriately after successful summarization.\n */\n private numNonSystemOpsBefore: number = 0;\n\n constructor(\n public lastOpSequenceNumber: number,\n /** Baseline attempt data used for comparisons with subsequent attempts/calculations. */\n attemptBaseline: ISummarizeAttempt,\n ) {\n this._lastAttempt = attemptBaseline;\n this._lastSuccessfulSummary = { ...attemptBaseline };\n }\n\n public updateWithLastSummaryAckInfo(lastSummary: Readonly<ISummarizeAttempt>) {\n this._lastAttempt = lastSummary;\n this._lastSuccessfulSummary = { ...lastSummary };\n }\n\n public recordAttempt(refSequenceNumber?: number) {\n this._lastAttempt = {\n refSequenceNumber: refSequenceNumber ?? this.lastOpSequenceNumber,\n summaryTime: Date.now(),\n };\n\n this.numSystemOpsBefore = this.numNonRuntimeOps;\n this.numNonSystemOpsBefore = this.numRuntimeOps;\n this.totalOpsSizeBefore = this.totalOpsSize;\n }\n\n public markLastAttemptAsSuccessful() {\n this._lastSuccessfulSummary = { ...this.lastAttempt };\n\n this.numNonRuntimeOps -= this.numSystemOpsBefore;\n this.numSystemOpsBefore = 0;\n\n this.numRuntimeOps -= this.numNonSystemOpsBefore;\n this.numNonSystemOpsBefore = 0;\n\n this.totalOpsSize -= this.totalOpsSizeBefore;\n this.totalOpsSizeBefore = 0;\n }\n}\n\n/**\n * This class contains the heuristics for when to summarize.\n */\nexport class SummarizeHeuristicRunner implements ISummarizeHeuristicRunner {\n private readonly idleTimer: Timer | undefined;\n private readonly runSummarize: (reason: SummarizeReason) => void;\n\n public constructor(\n private readonly heuristicData: ISummarizeHeuristicData,\n private readonly configuration: ISummaryConfigurationHeuristics,\n trySummarize: (reason: SummarizeReason) => void,\n private readonly logger: ITelemetryLogger,\n private readonly summarizeStrategies: ISummaryHeuristicStrategy[] = getDefaultSummaryHeuristicStrategies(),\n ) {\n this.idleTimer = new Timer(\n this.idleTime,\n () => this.runSummarize(\"idle\"));\n\n this.runSummarize = (reason: SummarizeReason) => {\n this.idleTimer?.clear();\n\n // We shouldn't attempt a summary if there are no new processed ops\n const opsSinceLastAck = this.opsSinceLastAck;\n if (opsSinceLastAck > 0) {\n trySummarize(reason);\n }\n };\n }\n\n public get idleTime(): number {\n const maxIdleTime = this.configuration.maxIdleTime;\n const minIdleTime = this.configuration.minIdleTime;\n const weightedNumOfOps = getWeightedNumberOfOps(\n this.heuristicData.numRuntimeOps,\n this.heuristicData.numNonRuntimeOps,\n this.configuration.runtimeOpWeight,\n this.configuration.nonRuntimeOpWeight,\n );\n const pToMaxOps = weightedNumOfOps * 1.0 / this.configuration.maxOps;\n\n if (pToMaxOps >= 1) {\n return minIdleTime;\n }\n\n // Return a ratioed idle time based on the percentage of ops\n return maxIdleTime - ((maxIdleTime - minIdleTime) * pToMaxOps);\n }\n\n public get opsSinceLastAck(): number {\n return this.heuristicData.lastOpSequenceNumber - this.heuristicData.lastSuccessfulSummary.refSequenceNumber;\n }\n\n public start() {\n this.idleTimer?.start(this.idleTime);\n }\n\n public run() {\n for (const strategy of this.summarizeStrategies) {\n if (strategy.shouldRunSummary(this.configuration, this.heuristicData)) {\n return this.runSummarize(strategy.summarizeReason);\n }\n }\n\n this.idleTimer?.restart(this.idleTime);\n }\n\n public shouldRunLastSummary(): boolean {\n const opsSinceLastAck = this.opsSinceLastAck;\n const minOpsForLastSummaryAttempt = this.configuration.minOpsForLastSummaryAttempt;\n\n this.logger.sendTelemetryEvent({\n eventName: \"ShouldRunLastSummary\",\n opsSinceLastAck,\n minOpsForLastSummaryAttempt,\n });\n\n return opsSinceLastAck >= minOpsForLastSummaryAttempt;\n }\n\n public dispose() {\n this.idleTimer?.clear();\n }\n}\n\n/** Strategy used to run a summary when it's been a while since our last successful summary */\nclass MaxTimeSummaryHeuristicStrategy implements ISummaryHeuristicStrategy {\n public readonly summarizeReason: Readonly<SummarizeReason> = \"maxTime\";\n\n public shouldRunSummary(\n configuration: ISummaryConfigurationHeuristics,\n heuristicData: ISummarizeHeuristicData,\n ): boolean {\n const timeSinceLastSummary = Date.now() - heuristicData.lastSuccessfulSummary.summaryTime;\n return timeSinceLastSummary > configuration.maxTime;\n }\n}\n\nfunction getWeightedNumberOfOps(\n runtimeOpCount: number,\n nonRuntimeOpCount: number,\n runtimeOpWeight: number,\n nonRuntimeOpWeight: number,\n): number {\n return (runtimeOpWeight * runtimeOpCount)\n + (nonRuntimeOpWeight * nonRuntimeOpCount);\n}\n\n/** Strategy used to do a weighted analysis on the ops we've processed since the last successful summary */\nclass WeightedOpsSummaryHeuristicStrategy implements ISummaryHeuristicStrategy {\n public readonly summarizeReason: Readonly<SummarizeReason> = \"maxOps\";\n\n public shouldRunSummary(\n configuration: ISummaryConfigurationHeuristics,\n heuristicData: ISummarizeHeuristicData,\n ): boolean {\n const weightedNumOfOps = getWeightedNumberOfOps(\n heuristicData.numRuntimeOps,\n heuristicData.numNonRuntimeOps,\n configuration.runtimeOpWeight,\n configuration.nonRuntimeOpWeight,\n );\n return weightedNumOfOps > configuration.maxOps;\n }\n}\n\nfunction getDefaultSummaryHeuristicStrategies() {\n return [\n new MaxTimeSummaryHeuristicStrategy(),\n new WeightedOpsSummaryHeuristicStrategy(),\n ];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"summarizerHeuristics.js","sourceRoot":"","sources":["../src/summarizerHeuristics.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAUrD,4EAA4E;AAC5E,MAAM,OAAO,sBAAsB;IAmC/B,YACW,oBAA4B;IACnC,wFAAwF;IACxF,eAAkC;QAF3B,yBAAoB,GAApB,oBAAoB,CAAQ;QAzBhC,qBAAgB,GAAW,CAAC,CAAC;QAC7B,iBAAY,GAAW,CAAC,CAAC;QACzB,qBAAgB,GAAY,KAAK,CAAC;QAEzC;;;WAGG;QACF,MAAM;QACC,uBAAkB,GAAW,CAAC,CAAC;QAEvC;;;WAGG;QACK,uBAAkB,GAAW,CAAC,CAAC;QAEhC,kBAAa,GAAW,CAAC,CAAC;QACjC;;;WAGG;QACK,0BAAqB,GAAW,CAAC,CAAC;QAOtC,IAAI,CAAC,YAAY,GAAG,eAAe,CAAC;QACpC,IAAI,CAAC,sBAAsB,qBAAQ,eAAe,CAAE,CAAC;IACzD,CAAC;IAxCD,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAGD,IAAW,qBAAqB;QAC5B,OAAO,IAAI,CAAC,sBAAsB,CAAC;IACvC,CAAC;IAmCM,4BAA4B,CAAC,WAAwC;QACxE,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,sBAAsB,qBAAQ,WAAW,CAAE,CAAC;IACrD,CAAC;IAEM,aAAa,CAAC,iBAA0B;QAC3C,IAAI,CAAC,YAAY,GAAG;YAChB,iBAAiB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AAM,gBAAgB,GAAG,sBAAsB,CAC3C,aAAa,CAAC,aAAa,EAC3B,aAAa,CAAC,gBAAgB,EAC9B,aAAa,CAAC,eAAe,EAC7B,aAAa,CAAC,kBAAkB,CACnC,CAAC;QACF,OAAO,gBAAgB,GAAG,aAAa,CAAC,MAAM,CAAC;IACnD,CAAC;CACJ;AAED,SAAS,oCAAoC;IACzC,OAAO;QACH,IAAI,+BAA+B,EAAE;QACrC,IAAI,mCAAmC,EAAE;KAC5C,CAAC;AACN,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { Timer } from \"@fluidframework/common-utils\";\nimport { ISummaryConfigurationHeuristics } from \"./containerRuntime\";\nimport {\n ISummarizeHeuristicData,\n ISummarizeHeuristicRunner,\n ISummarizeAttempt,\n ISummaryHeuristicStrategy,\n} from \"./summarizerTypes\";\nimport { SummarizeReason } from \"./summaryGenerator\";\n\n/** Simple implementation of class for tracking summarize heuristic data. */\nexport class SummarizeHeuristicData implements ISummarizeHeuristicData {\n protected _lastAttempt: ISummarizeAttempt;\n public get lastAttempt(): ISummarizeAttempt {\n return this._lastAttempt;\n }\n\n protected _lastSuccessfulSummary: Readonly<ISummarizeAttempt>;\n public get lastSuccessfulSummary(): Readonly<ISummarizeAttempt> {\n return this._lastSuccessfulSummary;\n }\n\n public numNonRuntimeOps: number = 0;\n public totalOpsSize: number = 0;\n public hasMissingOpData: boolean = false;\n\n /**\n * Cumulative size in bytes of all the ops at the beginning of the summarization attempt.\n * Is used to adjust totalOpsSize appropriately after successful summarization.\n */\n /** */\n private totalOpsSizeBefore: number = 0;\n\n /**\n * Number of system ops at beginning of attempting to summarize.\n * Is used to adjust numSystemOps appropriately after successful summarization.\n */\n private numSystemOpsBefore: number = 0;\n\n public numRuntimeOps: number = 0;\n /**\n * Number of non-system ops at beginning of attempting to summarize.\n * Is used to adjust numNonSystemOps appropriately after successful summarization.\n */\n private numNonSystemOpsBefore: number = 0;\n\n constructor(\n public lastOpSequenceNumber: number,\n /** Baseline attempt data used for comparisons with subsequent attempts/calculations. */\n attemptBaseline: ISummarizeAttempt,\n ) {\n this._lastAttempt = attemptBaseline;\n this._lastSuccessfulSummary = { ...attemptBaseline };\n }\n\n public updateWithLastSummaryAckInfo(lastSummary: Readonly<ISummarizeAttempt>) {\n this._lastAttempt = lastSummary;\n this._lastSuccessfulSummary = { ...lastSummary };\n }\n\n public recordAttempt(refSequenceNumber?: number) {\n this._lastAttempt = {\n refSequenceNumber: refSequenceNumber ?? this.lastOpSequenceNumber,\n summaryTime: Date.now(),\n };\n\n this.numSystemOpsBefore = this.numNonRuntimeOps;\n this.numNonSystemOpsBefore = this.numRuntimeOps;\n this.totalOpsSizeBefore = this.totalOpsSize;\n }\n\n public markLastAttemptAsSuccessful() {\n this._lastSuccessfulSummary = { ...this.lastAttempt };\n\n this.numNonRuntimeOps -= this.numSystemOpsBefore;\n this.numSystemOpsBefore = 0;\n\n this.numRuntimeOps -= this.numNonSystemOpsBefore;\n this.numNonSystemOpsBefore = 0;\n\n this.totalOpsSize -= this.totalOpsSizeBefore;\n this.totalOpsSizeBefore = 0;\n }\n}\n\n/**\n * This class contains the heuristics for when to summarize.\n */\nexport class SummarizeHeuristicRunner implements ISummarizeHeuristicRunner {\n private readonly idleTimer: Timer | undefined;\n private readonly runSummarize: (reason: SummarizeReason) => void;\n\n public constructor(\n private readonly heuristicData: ISummarizeHeuristicData,\n private readonly configuration: ISummaryConfigurationHeuristics,\n trySummarize: (reason: SummarizeReason) => void,\n private readonly logger: ITelemetryLogger,\n private readonly summarizeStrategies: ISummaryHeuristicStrategy[] = getDefaultSummaryHeuristicStrategies(),\n ) {\n this.idleTimer = new Timer(\n this.idleTime,\n () => this.runSummarize(\"idle\"));\n\n this.runSummarize = (reason: SummarizeReason) => {\n this.idleTimer?.clear();\n\n // We shouldn't attempt a summary if there are no new processed ops\n const opsSinceLastAck = this.opsSinceLastAck;\n if (opsSinceLastAck > 0) {\n trySummarize(reason);\n }\n };\n }\n\n public get idleTime(): number {\n if (this.configuration.idleTime !== undefined) {\n return this.configuration.idleTime;\n }\n const maxIdleTime = this.configuration.maxIdleTime;\n const minIdleTime = this.configuration.minIdleTime;\n const weightedNumOfOps = getWeightedNumberOfOps(\n this.heuristicData.numRuntimeOps,\n this.heuristicData.numNonRuntimeOps,\n this.configuration.runtimeOpWeight,\n this.configuration.nonRuntimeOpWeight,\n );\n const pToMaxOps = weightedNumOfOps * 1.0 / this.configuration.maxOps;\n\n if (pToMaxOps >= 1) {\n return minIdleTime;\n }\n\n // Return a ratioed idle time based on the percentage of ops\n return maxIdleTime - ((maxIdleTime - minIdleTime) * pToMaxOps);\n }\n\n public get opsSinceLastAck(): number {\n return this.heuristicData.lastOpSequenceNumber - this.heuristicData.lastSuccessfulSummary.refSequenceNumber;\n }\n\n public start() {\n this.idleTimer?.start(this.idleTime);\n }\n\n public run() {\n for (const strategy of this.summarizeStrategies) {\n if (strategy.shouldRunSummary(this.configuration, this.heuristicData)) {\n return this.runSummarize(strategy.summarizeReason);\n }\n }\n\n this.idleTimer?.restart(this.idleTime);\n }\n\n public shouldRunLastSummary(): boolean {\n const opsSinceLastAck = this.opsSinceLastAck;\n const minOpsForLastSummaryAttempt = this.configuration.minOpsForLastSummaryAttempt;\n\n this.logger.sendTelemetryEvent({\n eventName: \"ShouldRunLastSummary\",\n opsSinceLastAck,\n minOpsForLastSummaryAttempt,\n });\n\n return opsSinceLastAck >= minOpsForLastSummaryAttempt;\n }\n\n public dispose() {\n this.idleTimer?.clear();\n }\n}\n\n/** Strategy used to run a summary when it's been a while since our last successful summary */\nclass MaxTimeSummaryHeuristicStrategy implements ISummaryHeuristicStrategy {\n public readonly summarizeReason: Readonly<SummarizeReason> = \"maxTime\";\n\n public shouldRunSummary(\n configuration: ISummaryConfigurationHeuristics,\n heuristicData: ISummarizeHeuristicData,\n ): boolean {\n const timeSinceLastSummary = Date.now() - heuristicData.lastSuccessfulSummary.summaryTime;\n return timeSinceLastSummary > configuration.maxTime;\n }\n}\n\nfunction getWeightedNumberOfOps(\n runtimeOpCount: number,\n nonRuntimeOpCount: number,\n runtimeOpWeight: number,\n nonRuntimeOpWeight: number,\n): number {\n return (runtimeOpWeight * runtimeOpCount)\n + (nonRuntimeOpWeight * nonRuntimeOpCount);\n}\n\n/** Strategy used to do a weighted analysis on the ops we've processed since the last successful summary */\nclass WeightedOpsSummaryHeuristicStrategy implements ISummaryHeuristicStrategy {\n public readonly summarizeReason: Readonly<SummarizeReason> = \"maxOps\";\n\n public shouldRunSummary(\n configuration: ISummaryConfigurationHeuristics,\n heuristicData: ISummarizeHeuristicData,\n ): boolean {\n const weightedNumOfOps = getWeightedNumberOfOps(\n heuristicData.numRuntimeOps,\n heuristicData.numNonRuntimeOps,\n configuration.runtimeOpWeight,\n configuration.nonRuntimeOpWeight,\n );\n return weightedNumOfOps > configuration.maxOps;\n }\n}\n\nfunction getDefaultSummaryHeuristicStrategies() {\n return [\n new MaxTimeSummaryHeuristicStrategy(),\n new WeightedOpsSummaryHeuristicStrategy(),\n ];\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/container-runtime",
|
|
3
|
-
"version": "2.0.0-dev.1.
|
|
3
|
+
"version": "2.0.0-dev.1.4.5.105745",
|
|
4
4
|
"description": "Fluid container runtime",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -63,29 +63,29 @@
|
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
65
65
|
"@fluidframework/common-utils": "^1.0.0",
|
|
66
|
-
"@fluidframework/container-definitions": "2.0.0-dev.1.
|
|
67
|
-
"@fluidframework/container-runtime-definitions": "2.0.0-dev.1.
|
|
68
|
-
"@fluidframework/container-utils": "2.0.0-dev.1.
|
|
69
|
-
"@fluidframework/core-interfaces": "2.0.0-dev.1.
|
|
70
|
-
"@fluidframework/datastore": "2.0.0-dev.1.
|
|
71
|
-
"@fluidframework/driver-definitions": "2.0.0-dev.1.
|
|
72
|
-
"@fluidframework/driver-utils": "2.0.0-dev.1.
|
|
73
|
-
"@fluidframework/garbage-collector": "2.0.0-dev.1.
|
|
66
|
+
"@fluidframework/container-definitions": "2.0.0-dev.1.4.5.105745",
|
|
67
|
+
"@fluidframework/container-runtime-definitions": "2.0.0-dev.1.4.5.105745",
|
|
68
|
+
"@fluidframework/container-utils": "2.0.0-dev.1.4.5.105745",
|
|
69
|
+
"@fluidframework/core-interfaces": "2.0.0-dev.1.4.5.105745",
|
|
70
|
+
"@fluidframework/datastore": "2.0.0-dev.1.4.5.105745",
|
|
71
|
+
"@fluidframework/driver-definitions": "2.0.0-dev.1.4.5.105745",
|
|
72
|
+
"@fluidframework/driver-utils": "2.0.0-dev.1.4.5.105745",
|
|
73
|
+
"@fluidframework/garbage-collector": "2.0.0-dev.1.4.5.105745",
|
|
74
74
|
"@fluidframework/protocol-base": "^0.1037.2001",
|
|
75
75
|
"@fluidframework/protocol-definitions": "^1.0.0",
|
|
76
|
-
"@fluidframework/runtime-definitions": "2.0.0-dev.1.
|
|
77
|
-
"@fluidframework/runtime-utils": "2.0.0-dev.1.
|
|
78
|
-
"@fluidframework/telemetry-utils": "2.0.0-dev.1.
|
|
76
|
+
"@fluidframework/runtime-definitions": "2.0.0-dev.1.4.5.105745",
|
|
77
|
+
"@fluidframework/runtime-utils": "2.0.0-dev.1.4.5.105745",
|
|
78
|
+
"@fluidframework/telemetry-utils": "2.0.0-dev.1.4.5.105745",
|
|
79
79
|
"double-ended-queue": "^2.1.0-0",
|
|
80
80
|
"uuid": "^8.3.1"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@fluidframework/build-common": "^1.0.0",
|
|
84
|
-
"@fluidframework/build-tools": "^0.4.
|
|
84
|
+
"@fluidframework/build-tools": "^0.4.4000",
|
|
85
85
|
"@fluidframework/container-runtime-previous": "npm:@fluidframework/container-runtime@^1.0.0",
|
|
86
86
|
"@fluidframework/eslint-config-fluid": "^1.0.0",
|
|
87
|
-
"@fluidframework/mocha-test-setup": "2.0.0-dev.1.
|
|
88
|
-
"@fluidframework/test-runtime-utils": "2.0.0-dev.1.
|
|
87
|
+
"@fluidframework/mocha-test-setup": "2.0.0-dev.1.4.5.105745",
|
|
88
|
+
"@fluidframework/test-runtime-utils": "2.0.0-dev.1.4.5.105745",
|
|
89
89
|
"@microsoft/api-extractor": "^7.22.2",
|
|
90
90
|
"@rushstack/eslint-config": "^2.5.1",
|
|
91
91
|
"@types/double-ended-queue": "^2.1.0",
|
|
@@ -108,13 +108,16 @@
|
|
|
108
108
|
"version": "2.0.0",
|
|
109
109
|
"broken": {
|
|
110
110
|
"VariableDeclaration_DefaultSummaryConfiguration": {
|
|
111
|
-
"forwardCompat": false
|
|
111
|
+
"forwardCompat": false,
|
|
112
|
+
"backCompat": false
|
|
112
113
|
},
|
|
113
114
|
"TypeAliasDeclaration_ISummaryConfiguration": {
|
|
114
|
-
"forwardCompat": false
|
|
115
|
+
"forwardCompat": false,
|
|
116
|
+
"backCompat": false
|
|
115
117
|
},
|
|
116
118
|
"InterfaceDeclaration_ISummaryConfigurationHeuristics": {
|
|
117
|
-
"forwardCompat": false
|
|
119
|
+
"forwardCompat": false,
|
|
120
|
+
"backCompat": false
|
|
118
121
|
},
|
|
119
122
|
"InterfaceDeclaration_IGeneratedSummaryStats": {
|
|
120
123
|
"backCompat": false
|
package/src/containerRuntime.ts
CHANGED
|
@@ -233,7 +233,7 @@ export interface ISummaryConfigurationHeuristics extends ISummaryBaseConfigurati
|
|
|
233
233
|
* @deprecated Please move all implementations to {@link ISummaryConfigurationHeuristics.minIdleTime} and
|
|
234
234
|
* {@link ISummaryConfigurationHeuristics.maxIdleTime} instead.
|
|
235
235
|
*/
|
|
236
|
-
idleTime
|
|
236
|
+
idleTime?: number;
|
|
237
237
|
/**
|
|
238
238
|
* Defines the maximum allowed time, since the last received Ack, before running the summary
|
|
239
239
|
* with reason maxTime.
|
|
@@ -297,8 +297,6 @@ export type ISummaryConfiguration =
|
|
|
297
297
|
export const DefaultSummaryConfiguration: ISummaryConfiguration = {
|
|
298
298
|
state: "enabled",
|
|
299
299
|
|
|
300
|
-
idleTime: 15 * 1000, // 15 secs.
|
|
301
|
-
|
|
302
300
|
minIdleTime: 0,
|
|
303
301
|
|
|
304
302
|
maxIdleTime: 30 * 1000, // 30 secs.
|
package/src/garbageCollection.ts
CHANGED
|
@@ -544,10 +544,10 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
544
544
|
);
|
|
545
545
|
this.sessionExpiryTimer.start();
|
|
546
546
|
|
|
547
|
-
// TEMPORARY: Hardcode a default of
|
|
547
|
+
// TEMPORARY: Hardcode a default of 5 days which will be >= the policy's value in the ODSP driver.
|
|
548
548
|
// This unblocks the Sweep Log (see logSweepEvents function).
|
|
549
549
|
// This will be removed before sweep is fully implemented.
|
|
550
|
-
const snapshotCacheExpiryMs = createParams.snapshotCacheExpiryMs ??
|
|
550
|
+
const snapshotCacheExpiryMs = createParams.snapshotCacheExpiryMs ?? 5 * 24 * 60 * 60 * 1000;
|
|
551
551
|
|
|
552
552
|
/**
|
|
553
553
|
* Sweep timeout is the time after which unreferenced content can be swept.
|
|
@@ -855,7 +855,7 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
855
855
|
const gcResult = runGarbageCollection(gcData.gcNodes, ["/"]);
|
|
856
856
|
|
|
857
857
|
const gcStats = await this.runPostGCSteps(gcData, gcResult, logger, currentReferenceTimestampMs);
|
|
858
|
-
event.end({ ...gcStats
|
|
858
|
+
event.end({ ...gcStats });
|
|
859
859
|
this.completedRuns++;
|
|
860
860
|
return gcStats;
|
|
861
861
|
}, { end: true, cancel: "error" });
|
|
@@ -74,8 +74,16 @@ export class SweepReadyUsageDetectionHandler {
|
|
|
74
74
|
localStorageOverride?: Pick<Storage, "getItem" | "setItem">,
|
|
75
75
|
) {
|
|
76
76
|
const noopStorage = { getItem: () => null, setItem: () => {} };
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
if (localStorageOverride !== undefined) {
|
|
78
|
+
this.localStorage = localStorageOverride;
|
|
79
|
+
} else {
|
|
80
|
+
try {
|
|
81
|
+
// localStorage is not defined in Node environment so this throws
|
|
82
|
+
this.localStorage = localStorage ?? noopStorage;
|
|
83
|
+
} catch (error) {
|
|
84
|
+
this.localStorage = noopStorage;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
79
87
|
|
|
80
88
|
if (this.localStorage === noopStorage) {
|
|
81
89
|
// This means the Skip Closure Period logic will not work.
|
package/src/packageVersion.ts
CHANGED
|
@@ -119,6 +119,9 @@ export class SummarizeHeuristicRunner implements ISummarizeHeuristicRunner {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
public get idleTime(): number {
|
|
122
|
+
if (this.configuration.idleTime !== undefined) {
|
|
123
|
+
return this.configuration.idleTime;
|
|
124
|
+
}
|
|
122
125
|
const maxIdleTime = this.configuration.maxIdleTime;
|
|
123
126
|
const minIdleTime = this.configuration.minIdleTime;
|
|
124
127
|
const weightedNumOfOps = getWeightedNumberOfOps(
|