@fluidframework/id-compressor 3.2.0 → 3.4.0

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 (102) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/api-report/id-compressor.legacy.beta.api.md +0 -49
  3. package/dist/idCompressor.d.ts +65 -22
  4. package/dist/idCompressor.d.ts.map +1 -1
  5. package/dist/idCompressor.js +401 -60
  6. package/dist/idCompressor.js.map +1 -1
  7. package/dist/index.d.ts +2 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +3 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/legacy.d.ts +1 -12
  12. package/dist/packageVersion.d.ts +1 -1
  13. package/dist/packageVersion.js +1 -1
  14. package/dist/packageVersion.js.map +1 -1
  15. package/dist/test/idCompressor.perf.spec.js.map +1 -1
  16. package/dist/test/idCompressor.spec.js.map +1 -1
  17. package/dist/test/idCompressorTestUtilities.d.ts.map +1 -1
  18. package/dist/test/idCompressorTestUtilities.js +8 -3
  19. package/dist/test/idCompressorTestUtilities.js.map +1 -1
  20. package/dist/test/sharding.fuzz.spec.d.ts +6 -0
  21. package/dist/test/sharding.fuzz.spec.d.ts.map +1 -0
  22. package/dist/test/sharding.fuzz.spec.js.map +1 -0
  23. package/dist/test/sharding.spec.d.ts +6 -0
  24. package/dist/test/sharding.spec.d.ts.map +1 -0
  25. package/dist/test/sharding.spec.js.map +1 -0
  26. package/dist/test/snapshots/summary.spec.js.map +1 -1
  27. package/dist/test/types/validateIdCompressorPrevious.generated.js.map +1 -1
  28. package/dist/types/idCompressor.d.ts +205 -20
  29. package/dist/types/idCompressor.d.ts.map +1 -1
  30. package/dist/types/idCompressor.js +15 -0
  31. package/dist/types/idCompressor.js.map +1 -1
  32. package/dist/types/index.d.ts +2 -1
  33. package/dist/types/index.d.ts.map +1 -1
  34. package/dist/types/index.js +3 -0
  35. package/dist/types/index.js.map +1 -1
  36. package/dist/types/persisted-types/0.0.1.d.ts +4 -4
  37. package/dist/types/persisted-types/0.0.1.js.map +1 -1
  38. package/dist/utilities.d.ts +1 -1
  39. package/dist/utilities.js +1 -1
  40. package/dist/utilities.js.map +1 -1
  41. package/lib/idCompressor.d.ts +65 -22
  42. package/lib/idCompressor.d.ts.map +1 -1
  43. package/lib/idCompressor.js +402 -61
  44. package/lib/idCompressor.js.map +1 -1
  45. package/lib/index.d.ts +2 -1
  46. package/lib/index.d.ts.map +1 -1
  47. package/lib/index.js +1 -0
  48. package/lib/index.js.map +1 -1
  49. package/lib/legacy.d.ts +1 -12
  50. package/lib/packageVersion.d.ts +1 -1
  51. package/lib/packageVersion.js +1 -1
  52. package/lib/packageVersion.js.map +1 -1
  53. package/lib/test/idCompressor.perf.spec.js.map +1 -1
  54. package/lib/test/idCompressor.spec.js.map +1 -1
  55. package/lib/test/idCompressorTestUtilities.d.ts.map +1 -1
  56. package/lib/test/idCompressorTestUtilities.js +8 -3
  57. package/lib/test/idCompressorTestUtilities.js.map +1 -1
  58. package/lib/test/sharding.fuzz.spec.d.ts +6 -0
  59. package/lib/test/sharding.fuzz.spec.d.ts.map +1 -0
  60. package/lib/test/sharding.fuzz.spec.js.map +1 -0
  61. package/lib/test/sharding.spec.d.ts +6 -0
  62. package/lib/test/sharding.spec.d.ts.map +1 -0
  63. package/lib/test/sharding.spec.js.map +1 -0
  64. package/lib/test/snapshots/summary.spec.js.map +1 -1
  65. package/lib/test/types/validateIdCompressorPrevious.generated.js.map +1 -1
  66. package/lib/types/idCompressor.d.ts +205 -20
  67. package/lib/types/idCompressor.d.ts.map +1 -1
  68. package/lib/types/idCompressor.js +14 -1
  69. package/lib/types/idCompressor.js.map +1 -1
  70. package/lib/types/index.d.ts +2 -1
  71. package/lib/types/index.d.ts.map +1 -1
  72. package/lib/types/index.js +1 -1
  73. package/lib/types/index.js.map +1 -1
  74. package/lib/types/persisted-types/0.0.1.d.ts +4 -4
  75. package/lib/types/persisted-types/0.0.1.js.map +1 -1
  76. package/lib/utilities.d.ts +1 -1
  77. package/lib/utilities.js +1 -1
  78. package/lib/utilities.js.map +1 -1
  79. package/package.json +8 -8
  80. package/src/idCompressor.ts +550 -78
  81. package/src/index.ts +11 -5
  82. package/src/packageVersion.ts +1 -1
  83. package/src/test/idCompressorTestUtilities.ts +16 -3
  84. package/src/test/snapshots/v2/compressor-with-finalized-range-from-one-client +1 -0
  85. package/src/test/snapshots/v2/compressor-with-finalized-range-from-one-client-client2 +1 -0
  86. package/src/test/snapshots/v2/compressors-with-finalized-ranges-from-two-clients +1 -0
  87. package/src/test/snapshots/v2/compressors-with-finalized-ranges-from-two-clients-client2 +1 -0
  88. package/src/test/snapshots/v2/empty-compressor-summary +1 -0
  89. package/src/test/snapshots/v2/expansion-semantics +1 -0
  90. package/src/test/snapshots/v2/expansion-semantics-client2 +1 -0
  91. package/src/test/snapshots/v3/compressor-with-finalized-range-from-one-client +1 -0
  92. package/src/test/snapshots/v3/compressor-with-finalized-range-from-one-client-client2 +1 -0
  93. package/src/test/snapshots/v3/compressors-with-finalized-ranges-from-two-clients +1 -0
  94. package/src/test/snapshots/v3/compressors-with-finalized-ranges-from-two-clients-client2 +1 -0
  95. package/src/test/snapshots/v3/empty-compressor-summary +1 -0
  96. package/src/test/snapshots/v3/expansion-semantics +1 -0
  97. package/src/test/snapshots/v3/expansion-semantics-client2 +1 -0
  98. package/src/test/types/validateIdCompressorPrevious.generated.ts +1 -109
  99. package/src/types/idCompressor.ts +225 -20
  100. package/src/types/index.ts +13 -1
  101. package/src/types/persisted-types/0.0.1.ts +4 -4
  102. package/src/utilities.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"idCompressor.js","sourceRoot":"","sources":["../src/idCompressor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9E,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EACN,YAAY,EAC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EAAE,MAAM,EAAE,CAAC,CAChE,CAAC;IACF,OAAO,UAAU,CAAC;AACnB,CAAC;AAqBD,MAAM,UAAU,uBAAuB,CACtC,UAAwE,EACxE,iBAA8D,EAC9D,iBAAuC;IAEvC,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE,CAAC;QAC3C,OAAO,YAAY,CAAC,WAAW,CAAC;YAC/B,UAAU,EAAE,UAAiD;YAC7D,MAAM,EAAE,yBAAyB,CAA8B,iBAAiB,CAAC;YACjF,YAAY,EAAE,iBAAiB;SAC/B,CAAC,CAAC;IACJ,CAAC;IAED,MAAM,CACL,iBAAiB,KAAK,SAAS,EAC/B,KAAK,CAAC,2DAA2D,CACjE,CAAC;IACF,OAAO,YAAY,CAAC,WAAW,CAAC;QAC/B,UAAU,EAAE,UAAsD;QAClE,MAAM,EAAE,yBAAyB,CAA8B,iBAAiB,CAAC;KACjF,CAAC,CAAC;AACJ,CAAC;AAwBD,MAAM,UAAU,qBAAqB,CACpC,UAAyB,EACzB,WAAoB;IAEpB,MAAM,IAAI,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;IAChD,OAAO,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,sBAAsB,CACrC,UAAyB;IAEzB,MAAM,CACL,WAAW,IAAI,UAAU,EACzB,KAAK,CAAC,wDAAwD,CAC9D,CAAC;IACF,OAAO,UAA+C,CAAC;AACxD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport type { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { TelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\nimport {\n\tLoggingError,\n\tcreateChildLogger,\n\textractTelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n// eslint-disable-next-line import-x/no-internal-modules -- Needed to avoid specialized /internal ITelemetryLoggerExt\nimport type { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/legacy\";\n\nimport { FinalSpace } from \"./finalSpace.js\";\nimport {\n\ttype FinalCompressedId,\n\ttype LocalCompressedId,\n\ttype NumericUuid,\n\tisFinalId,\n} from \"./identifiers.js\";\nimport {\n\ttype Index,\n\treadBoolean,\n\treadNumber,\n\treadNumericUuid,\n\twriteBoolean,\n\twriteNumber,\n\twriteNumericUuid,\n} from \"./persistanceUtilities.js\";\nimport { SessionSpaceNormalizer } from \"./sessionSpaceNormalizer.js\";\nimport {\n\ttype IdCluster,\n\tSession,\n\tSessions,\n\tgetAlignedFinal,\n\tgetAlignedLocal,\n\tlastFinalizedFinal,\n\tlastFinalizedLocal,\n} from \"./sessions.js\";\nimport type {\n\tIIdCompressor,\n\tIIdCompressorCore,\n\tIdCreationRange,\n\tOpSpaceCompressedId,\n\tSerializedIdCompressor,\n\tSerializedIdCompressorWithNoSession,\n\tSerializedIdCompressorWithOngoingSession,\n\tSessionId,\n\tSessionSpaceCompressedId,\n\tStableId,\n} from \"./types/index.js\";\nimport {\n\tcreateSessionId,\n\tgenCountFromLocalId,\n\tlocalIdFromGenCount,\n\tnumericUuidFromStableId,\n\toffsetNumericUuid,\n\tstableIdFromNumericUuid,\n\tsubtractNumericUuids,\n} from \"./utilities.js\";\n\n/**\n * The version of IdCompressor that is currently persisted.\n * This should not be changed without careful consideration to compatibility.\n */\nconst currentWrittenVersion = 2;\n\nfunction rangeFinalizationError(expectedStart: number, actualStart: number): LoggingError {\n\treturn new LoggingError(\"Ranges finalized out of order\", {\n\t\texpectedStart,\n\t\tactualStart,\n\t});\n}\n\n/**\n * See {@link IIdCompressor} and {@link IIdCompressorCore}\n */\nexport class IdCompressor implements IIdCompressor, IIdCompressorCore {\n\t/**\n\t * Max allowed initial cluster size.\n\t */\n\tpublic static readonly maxClusterSize = 2 ** 20;\n\n\t// #region Local state\n\n\tpublic readonly localSessionId: SessionId;\n\tprivate readonly localSession: Session;\n\tprivate readonly normalizer = new SessionSpaceNormalizer();\n\t// The number of IDs generated by the local session\n\tprivate localGenCount = 0;\n\n\t// #endregion\n\n\t// #region Final state\n\n\t/**\n\t * The gen count to be annotated on the range returned by the next call to `takeNextCreationRange`.\n\t * This is advanced to `generatedIdCount` + 1 each time it is called.\n\t * On the other hand, when `resetUnfinalizedCreationRange` is called,\n\t * this is moved back to the start of the unfinalized range, to ensure those IDs are included in the next range.\n\t */\n\tprivate nextRangeBaseGenCount = 1;\n\tprivate readonly sessions = new Sessions();\n\tprivate readonly finalSpace = new FinalSpace();\n\n\t// #endregion\n\n\t// #region Ephemeral state\n\n\t/**\n\t * Roughly equates to a minimum of 1M sessions before we start allocating 64 bit IDs.\n\t * Eventually, this can be adjusted dynamically to have cluster reservation policies that\n\t * optimize the number of eager finals.\n\t * It is not readonly as it is accessed by tests for clear-box testing.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/prefer-readonly\n\tprivate nextRequestedClusterSize: number = 512;\n\t// The number of local IDs generated since the last telemetry was sent.\n\tprivate telemetryLocalIdCount = 0;\n\t// The number of eager final IDs generated since the last telemetry was sent.\n\tprivate telemetryEagerFinalIdCount = 0;\n\t// The ongoing ghost session, if one exists.\n\tprivate ongoingGhostSession?: { cluster?: IdCluster; ghostSessionId: SessionId } | undefined;\n\n\t// #endregion\n\n\tpublic constructor(\n\t\tlocalSessionIdOrDeserialized: SessionId | Sessions,\n\t\tprivate readonly logger: TelemetryLoggerExt | undefined,\n\t) {\n\t\tif (typeof localSessionIdOrDeserialized === \"string\") {\n\t\t\tthis.localSessionId = localSessionIdOrDeserialized;\n\t\t\tthis.localSession = this.sessions.getOrCreate(localSessionIdOrDeserialized);\n\t\t} else {\n\t\t\t// Deserialize case\n\t\t\tthis.sessions = localSessionIdOrDeserialized;\n\t\t\t// As policy, the first session is always the local session. Preserve this invariant\n\t\t\t// during deserialization.\n\t\t\tconst firstSession = localSessionIdOrDeserialized.sessions().next();\n\t\t\tassert(!firstSession.done, 0x754 /* First session must be present. */);\n\t\t\tthis.localSession = firstSession.value;\n\t\t\tthis.localSessionId = stableIdFromNumericUuid(\n\t\t\t\tthis.localSession.sessionUuid,\n\t\t\t) as SessionId;\n\t\t}\n\t}\n\n\tpublic generateCompressedId(): SessionSpaceCompressedId {\n\t\t// This ghost session code inside this block should not be changed without a version bump (it is performed at a consensus point)\n\t\tif (this.ongoingGhostSession) {\n\t\t\tif (this.ongoingGhostSession.cluster === undefined) {\n\t\t\t\tthis.ongoingGhostSession.cluster = this.addEmptyCluster(\n\t\t\t\t\tthis.sessions.getOrCreate(this.ongoingGhostSession.ghostSessionId),\n\t\t\t\t\t1,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.ongoingGhostSession.cluster.capacity++;\n\t\t\t}\n\t\t\tthis.ongoingGhostSession.cluster.count++;\n\t\t\treturn lastFinalizedFinal(\n\t\t\t\tthis.ongoingGhostSession.cluster,\n\t\t\t) as unknown as SessionSpaceCompressedId;\n\t\t} else {\n\t\t\tthis.localGenCount++;\n\t\t\tconst lastCluster = this.localSession.getLastCluster();\n\t\t\tif (lastCluster === undefined) {\n\t\t\t\tthis.telemetryLocalIdCount++;\n\t\t\t\treturn this.generateNextLocalId();\n\t\t\t}\n\n\t\t\t// If there exists a cluster of final IDs already claimed by the local session that still has room in it,\n\t\t\t// it is known prior to range sequencing what a local ID's corresponding final ID will be.\n\t\t\t// In this case, it is safe to return the final ID immediately. This is guaranteed to be safe because\n\t\t\t// any op that the local session sends that contains one of those final IDs are guaranteed to arrive to\n\t\t\t// collaborators *after* the one containing the creation range.\n\t\t\tconst clusterOffset = this.localGenCount - genCountFromLocalId(lastCluster.baseLocalId);\n\t\t\tif (lastCluster.capacity > clusterOffset) {\n\t\t\t\tthis.telemetryEagerFinalIdCount++;\n\t\t\t\t// Space in the cluster: eager final\n\t\t\t\treturn ((lastCluster.baseFinalId as number) +\n\t\t\t\t\tclusterOffset) as SessionSpaceCompressedId;\n\t\t\t}\n\t\t\t// No space in the cluster, return next local\n\t\t\tthis.telemetryLocalIdCount++;\n\t\t\treturn this.generateNextLocalId();\n\t\t}\n\t}\n\n\tpublic generateDocumentUniqueId():\n\t\t| (SessionSpaceCompressedId & OpSpaceCompressedId)\n\t\t| StableId {\n\t\tconst id = this.generateCompressedId();\n\t\treturn isFinalId(id) ? id : this.decompress(id);\n\t}\n\n\t/**\n\t * Starts a ghost session. Only exposed for test purposes (this class is not exported from the package).\n\t * @param ghostSessionId - The session ID to start the ghost session with.\n\t */\n\tpublic startGhostSession(ghostSessionId: SessionId): void {\n\t\tassert(!this.ongoingGhostSession, 0x8fe /* Ghost session already in progress. */);\n\t\tthis.ongoingGhostSession = { ghostSessionId };\n\t}\n\n\t/**\n\t * {@inheritdoc IIdCompressorCore.beginGhostSession}\n\t */\n\tpublic beginGhostSession(ghostSessionId: SessionId, ghostSessionCallback: () => void): void {\n\t\tthis.startGhostSession(ghostSessionId);\n\t\ttry {\n\t\t\tghostSessionCallback();\n\t\t} finally {\n\t\t\tthis.ongoingGhostSession = undefined;\n\t\t}\n\t}\n\n\tprivate generateNextLocalId(): LocalCompressedId {\n\t\t// Must tell the normalizer that we generated a local ID\n\t\tthis.normalizer.addLocalRange(this.localGenCount, 1);\n\t\treturn localIdFromGenCount(this.localGenCount);\n\t}\n\n\tpublic takeNextCreationRange(): IdCreationRange {\n\t\tassert(\n\t\t\t!this.ongoingGhostSession,\n\t\t\t0x8a6 /* IdCompressor should not be operated normally when in a ghost session */,\n\t\t);\n\t\tconst count = this.localGenCount - (this.nextRangeBaseGenCount - 1);\n\t\tif (count === 0) {\n\t\t\treturn {\n\t\t\t\tsessionId: this.localSessionId,\n\t\t\t};\n\t\t}\n\t\tconst range: IdCreationRange = {\n\t\t\tsessionId: this.localSessionId,\n\t\t\tids: {\n\t\t\t\tfirstGenCount: this.nextRangeBaseGenCount,\n\t\t\t\tcount,\n\t\t\t\trequestedClusterSize: this.nextRequestedClusterSize,\n\t\t\t\tlocalIdRanges: this.normalizer.getRangesBetween(\n\t\t\t\t\tthis.nextRangeBaseGenCount,\n\t\t\t\t\tthis.localGenCount,\n\t\t\t\t),\n\t\t\t},\n\t\t};\n\t\treturn this.updateToRange(range);\n\t}\n\n\tpublic takeUnfinalizedCreationRange(): IdCreationRange {\n\t\tthis.resetUnfinalizedCreationRange();\n\t\treturn this.takeNextCreationRange();\n\t}\n\n\tpublic resetUnfinalizedCreationRange(): void {\n\t\tassert(\n\t\t\t!this.ongoingGhostSession,\n\t\t\t0xcec /* IdCompressor should not be operated normally when in a ghost session */,\n\t\t);\n\n\t\tconst lastLocalCluster = this.localSession.getLastCluster();\n\t\tthis.nextRangeBaseGenCount =\n\t\t\tlastLocalCluster === undefined\n\t\t\t\t? 1\n\t\t\t\t: genCountFromLocalId(\n\t\t\t\t\t\t(lastLocalCluster.baseLocalId - lastLocalCluster.count) as LocalCompressedId,\n\t\t\t\t\t);\n\t}\n\n\tprivate updateToRange(range: IdCreationRange): IdCreationRange {\n\t\tthis.nextRangeBaseGenCount = this.localGenCount + 1;\n\t\treturn IdCompressor.assertValidRange(range);\n\t}\n\n\tprivate static assertValidRange(range: IdCreationRange): IdCreationRange {\n\t\tif (range.ids === undefined) {\n\t\t\treturn range;\n\t\t}\n\t\tconst { count, requestedClusterSize } = range.ids;\n\t\tassert(count > 0, 0x755 /* Malformed ID Range. */);\n\t\tassert(requestedClusterSize > 0, 0x876 /* Clusters must have a positive capacity. */);\n\t\tassert(\n\t\t\trequestedClusterSize <= IdCompressor.maxClusterSize,\n\t\t\t0x877 /* Clusters must not exceed max cluster size. */,\n\t\t);\n\t\treturn range;\n\t}\n\n\tpublic finalizeCreationRange(range: IdCreationRange): void {\n\t\tassert(\n\t\t\t!this.ongoingGhostSession,\n\t\t\t0x8a7 /* IdCompressor should not be operated normally when in a ghost session */,\n\t\t);\n\t\t// Check if the range has IDs\n\t\tif (range.ids === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tIdCompressor.assertValidRange(range);\n\t\tconst { sessionId, ids } = range;\n\t\tconst { count, firstGenCount, requestedClusterSize } = ids;\n\t\tconst session = this.sessions.getOrCreate(sessionId);\n\t\tconst isLocal = session === this.localSession;\n\t\tconst rangeBaseLocal = localIdFromGenCount(firstGenCount);\n\t\tlet lastCluster = session.getLastCluster();\n\t\tif (lastCluster === undefined) {\n\t\t\t// This is the first cluster in the session space\n\t\t\tif (rangeBaseLocal !== -1) {\n\t\t\t\tthrow rangeFinalizationError(-1, rangeBaseLocal);\n\t\t\t}\n\t\t\tlastCluster = this.addEmptyCluster(session, requestedClusterSize + count);\n\t\t\tif (isLocal) {\n\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\teventName: \"RuntimeIdCompressor:FirstCluster\",\n\t\t\t\t\tsessionId: this.localSessionId,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tconst remainingCapacity = lastCluster.capacity - lastCluster.count;\n\t\tif (lastCluster.baseLocalId - lastCluster.count !== rangeBaseLocal) {\n\t\t\tthrow rangeFinalizationError(\n\t\t\t\tlastCluster.baseLocalId - lastCluster.count,\n\t\t\t\trangeBaseLocal,\n\t\t\t);\n\t\t}\n\n\t\tif (remainingCapacity >= count) {\n\t\t\t// The current range fits in the existing cluster\n\t\t\tlastCluster.count += count;\n\t\t} else {\n\t\t\tconst overflow = count - remainingCapacity;\n\t\t\tconst newClaimedFinalCount = overflow + requestedClusterSize;\n\t\t\tif (lastCluster === this.finalSpace.getLastCluster()) {\n\t\t\t\t// The last cluster in the sessions chain is the last cluster globally, so it can be expanded.\n\t\t\t\tlastCluster.capacity += newClaimedFinalCount;\n\t\t\t\tlastCluster.count += count;\n\t\t\t\tassert(\n\t\t\t\t\t!this.sessions.clusterCollides(lastCluster),\n\t\t\t\t\t0x756 /* Cluster collision detected. */,\n\t\t\t\t);\n\t\t\t\tif (isLocal) {\n\t\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"RuntimeIdCompressor:ClusterExpansion\",\n\t\t\t\t\t\tsessionId: this.localSessionId,\n\t\t\t\t\t\tpreviousCapacity: lastCluster.capacity - newClaimedFinalCount,\n\t\t\t\t\t\tnewCapacity: lastCluster.capacity,\n\t\t\t\t\t\toverflow,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// The last cluster in the sessions chain is *not* the last cluster globally. Fill and overflow to new.\n\t\t\t\tlastCluster.count = lastCluster.capacity;\n\t\t\t\tconst newCluster = this.addEmptyCluster(session, newClaimedFinalCount);\n\t\t\t\tnewCluster.count += overflow;\n\t\t\t\tif (isLocal) {\n\t\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"RuntimeIdCompressor:NewCluster\",\n\t\t\t\t\t\tsessionId: this.localSessionId,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (isLocal) {\n\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\teventName: \"RuntimeIdCompressor:IdCompressorStatus\",\n\t\t\t\teagerFinalIdCount: this.telemetryEagerFinalIdCount,\n\t\t\t\tlocalIdCount: this.telemetryLocalIdCount,\n\t\t\t\tsessionId: this.localSessionId,\n\t\t\t});\n\t\t\tthis.telemetryEagerFinalIdCount = 0;\n\t\t\tthis.telemetryLocalIdCount = 0;\n\t\t}\n\n\t\tassert(!session.isEmpty(), 0x757 /* Empty sessions should not be created. */);\n\t}\n\n\tprivate addEmptyCluster(session: Session, capacity: number): IdCluster {\n\t\tassert(\n\t\t\t!this.ongoingGhostSession?.cluster,\n\t\t\t0x8a8 /* IdCompressor should not be operated normally when in a ghost session */,\n\t\t);\n\t\tconst newCluster = session.addNewCluster(\n\t\t\tthis.finalSpace.getAllocatedIdLimit(),\n\t\t\tcapacity,\n\t\t\t0,\n\t\t);\n\t\tassert(\n\t\t\t!this.sessions.clusterCollides(newCluster),\n\t\t\t0x758 /* Cluster collision detected. */,\n\t\t);\n\t\tthis.finalSpace.addCluster(newCluster);\n\t\treturn newCluster;\n\t}\n\n\tpublic normalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId {\n\t\tif (isFinalId(id)) {\n\t\t\treturn id;\n\t\t} else {\n\t\t\tconst local = id as unknown as LocalCompressedId;\n\t\t\tif (!this.normalizer.contains(local)) {\n\t\t\t\tthrow new Error(\"Invalid ID to normalize.\");\n\t\t\t}\n\t\t\tconst finalForm = this.localSession.tryConvertToFinal(local, true);\n\t\t\treturn finalForm === undefined\n\t\t\t\t? (local as unknown as OpSpaceCompressedId)\n\t\t\t\t: (finalForm as OpSpaceCompressedId);\n\t\t}\n\t}\n\n\tpublic tryNormalizeToSessionSpaceWithoutSession(\n\t\tid: OpSpaceCompressedId,\n\t): SessionSpaceCompressedId | undefined {\n\t\tif (isFinalId(id)) {\n\t\t\tconst containingCluster = this.localSession.getClusterByAllocatedFinal(id);\n\t\t\tif (containingCluster === undefined) {\n\t\t\t\t// Does not exist in local cluster chain\n\t\t\t\tif (id >= this.finalSpace.getFinalizedIdLimit()) {\n\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t}\n\t\t\t\treturn id as unknown as SessionSpaceCompressedId;\n\t\t\t} else {\n\t\t\t\tconst alignedLocal = getAlignedLocal(containingCluster, id);\n\t\t\t\tif (this.normalizer.contains(alignedLocal)) {\n\t\t\t\t\treturn alignedLocal;\n\t\t\t\t} else {\n\t\t\t\t\tif (genCountFromLocalId(alignedLocal) > this.localGenCount) {\n\t\t\t\t\t\t// The ID is not valid in this compressor. It is either from a future version of this compressor, or another compressor.\n\t\t\t\t\t\t// Since IDs from other compressors often are valid in this one, but uncompress incorrectly,\n\t\t\t\t\t\t// we cannot rely on this function (tryNormalizeToSessionSpaceWithoutSession) to validate that the IDs are from the same compressor.\n\t\t\t\t\t\t// Since such validation can not be robust, this \"try\" function is explicitly documented not to be allowed to be used for this case.\n\t\t\t\t\t\t// Therefore, as documented in the API docs for this function, calls can not rely on a specific output in this case,\n\t\t\t\t\t\t// and therefore the document behavior of throwing makes the most sense (helps catch bugs).\n\t\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t\t}\n\t\t\t\t\treturn id as unknown as SessionSpaceCompressedId;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tpublic normalizeToSessionSpace(\n\t\tid: OpSpaceCompressedId,\n\t\toriginSessionId: SessionId,\n\t): SessionSpaceCompressedId {\n\t\tconst normalizedWithoutSession = this.tryNormalizeToSessionSpaceWithoutSession(id);\n\t\tif (normalizedWithoutSession === undefined) {\n\t\t\tconst localToNormalize = id as unknown as LocalCompressedId;\n\t\t\tif (originSessionId === this.localSessionId) {\n\t\t\t\tif (this.normalizer.contains(localToNormalize)) {\n\t\t\t\t\treturn localToNormalize;\n\t\t\t\t} else {\n\t\t\t\t\t// We never generated this local ID, so fail\n\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// LocalId from a remote session\n\t\t\t\tconst remoteSession = this.sessions.get(originSessionId);\n\t\t\t\tif (remoteSession === undefined) {\n\t\t\t\t\tthrow new Error(\"No IDs have ever been finalized by the supplied session.\");\n\t\t\t\t}\n\t\t\t\tconst correspondingFinal = remoteSession.tryConvertToFinal(localToNormalize, false);\n\t\t\t\tif (correspondingFinal === undefined) {\n\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t}\n\t\t\t\treturn correspondingFinal as unknown as SessionSpaceCompressedId;\n\t\t\t}\n\t\t} else {\n\t\t\treturn normalizedWithoutSession;\n\t\t}\n\t}\n\n\tpublic decompress(id: SessionSpaceCompressedId): StableId {\n\t\tif (isFinalId(id)) {\n\t\t\tconst containingCluster = Session.getContainingCluster(id, this.finalSpace.clusters);\n\t\t\tif (containingCluster === undefined) {\n\t\t\t\tthrow new Error(\"Unknown ID\");\n\t\t\t}\n\t\t\tconst alignedLocal = getAlignedLocal(containingCluster, id);\n\t\t\tconst alignedGenCount = genCountFromLocalId(alignedLocal);\n\t\t\tconst lastFinalizedGenCount = genCountFromLocalId(lastFinalizedLocal(containingCluster));\n\t\t\tif (alignedGenCount > lastFinalizedGenCount) {\n\t\t\t\t// should be an eager final id generated by the local session\n\t\t\t\tif (containingCluster.session === this.localSession) {\n\t\t\t\t\tassert(!this.normalizer.contains(alignedLocal), 0x759 /* Normalizer out of sync. */);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(\"Unknown ID\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn stableIdFromNumericUuid(\n\t\t\t\toffsetNumericUuid(containingCluster.session.sessionUuid, alignedGenCount - 1),\n\t\t\t);\n\t\t} else {\n\t\t\tconst localToDecompress = id as unknown as LocalCompressedId;\n\t\t\tif (!this.normalizer.contains(localToDecompress)) {\n\t\t\t\tthrow new Error(\"Unknown ID\");\n\t\t\t}\n\t\t\treturn stableIdFromNumericUuid(\n\t\t\t\toffsetNumericUuid(\n\t\t\t\t\tthis.localSession.sessionUuid,\n\t\t\t\t\tgenCountFromLocalId(localToDecompress) - 1,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic recompress(uncompressed: StableId): SessionSpaceCompressedId {\n\t\tconst recompressed = this.tryRecompress(uncompressed);\n\t\tif (recompressed === undefined) {\n\t\t\tthrow new Error(\"Could not recompress.\");\n\t\t}\n\t\treturn recompressed;\n\t}\n\n\tpublic tryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined {\n\t\tconst match = this.sessions.getContainingCluster(uncompressed);\n\t\tif (match === undefined) {\n\t\t\tconst numericUncompressed = numericUuidFromStableId(uncompressed);\n\t\t\tconst offset = subtractNumericUuids(numericUncompressed, this.localSession.sessionUuid);\n\t\t\tif (offset < Number.MAX_SAFE_INTEGER) {\n\t\t\t\tconst genCountEquivalent = Number(offset) + 1;\n\t\t\t\tconst localEquivalent = localIdFromGenCount(genCountEquivalent);\n\t\t\t\tif (this.normalizer.contains(localEquivalent)) {\n\t\t\t\t\treturn localEquivalent;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn undefined;\n\t\t} else {\n\t\t\tconst [containingCluster, alignedLocal] = match;\n\t\t\tif (containingCluster.session === this.localSession) {\n\t\t\t\t// Local session\n\t\t\t\tif (this.normalizer.contains(alignedLocal)) {\n\t\t\t\t\treturn alignedLocal;\n\t\t\t\t} else {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tgenCountFromLocalId(alignedLocal) <= this.localGenCount,\n\t\t\t\t\t\t0x75a /* Clusters out of sync. */,\n\t\t\t\t\t);\n\t\t\t\t\t// Id is an eager final\n\t\t\t\t\treturn getAlignedFinal(containingCluster, alignedLocal) as\n\t\t\t\t\t\t| SessionSpaceCompressedId\n\t\t\t\t\t\t| undefined;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Not the local session\n\t\t\t\treturn genCountFromLocalId(alignedLocal) >= lastFinalizedLocal(containingCluster)\n\t\t\t\t\t? (getAlignedFinal(containingCluster, alignedLocal) as\n\t\t\t\t\t\t\t| SessionSpaceCompressedId\n\t\t\t\t\t\t\t| undefined)\n\t\t\t\t\t: undefined;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic serialize(withSession: true): SerializedIdCompressorWithOngoingSession;\n\tpublic serialize(withSession: false): SerializedIdCompressorWithNoSession;\n\tpublic serialize(hasLocalState: boolean): SerializedIdCompressor {\n\t\tassert(\n\t\t\t!this.ongoingGhostSession,\n\t\t\t0x8a9 /* IdCompressor should not be operated normally when in a ghost session */,\n\t\t);\n\t\tconst { normalizer, finalSpace, sessions, localGenCount, logger, nextRangeBaseGenCount } =\n\t\t\tthis;\n\t\tconst sessionIndexMap = new Map<Session, number>();\n\t\tlet sessionIndex = 0;\n\t\tfor (const session of sessions.sessions()) {\n\t\t\t// Filter empty sessions to prevent them accumulating in the serialized state\n\t\t\tif (!session.isEmpty() || hasLocalState) {\n\t\t\t\tsessionIndexMap.set(session, sessionIndex);\n\t\t\t\tsessionIndex++;\n\t\t\t}\n\t\t}\n\t\tconst localStateSize = hasLocalState\n\t\t\t? 1 + // generated ID count\n\t\t\t\t1 + // next range base genCount\n\t\t\t\t1 + // count of normalizer pairs\n\t\t\t\tnormalizer.idRanges.size * 2 // pairs\n\t\t\t: 0;\n\t\t// Layout size, in 8 byte increments\n\t\tconst totalSize =\n\t\t\t1 + // version\n\t\t\t1 + // hasLocalState\n\t\t\t1 + // session count\n\t\t\t1 + // cluster count\n\t\t\tsessionIndexMap.size * 2 + // session IDs\n\t\t\tfinalSpace.clusters.length * 3 + // clusters: (sessionIndex, capacity, count)[]\n\t\t\tlocalStateSize; // local state, if present\n\n\t\tconst serializedFloat = new Float64Array(totalSize);\n\t\tconst serializedUint = new BigUint64Array(serializedFloat.buffer);\n\t\tlet index = 0;\n\t\tindex = writeNumber(serializedFloat, index, currentWrittenVersion);\n\t\tindex = writeBoolean(serializedFloat, index, hasLocalState);\n\t\tindex = writeNumber(serializedFloat, index, sessionIndexMap.size);\n\t\tindex = writeNumber(serializedFloat, index, finalSpace.clusters.length);\n\n\t\tfor (const [session] of sessionIndexMap.entries()) {\n\t\t\tindex = writeNumericUuid(serializedUint, index, session.sessionUuid);\n\t\t}\n\n\t\tfor (const cluster of finalSpace.clusters) {\n\t\t\tindex = writeNumber(\n\t\t\t\tserializedFloat,\n\t\t\t\tindex,\n\t\t\t\tsessionIndexMap.get(cluster.session) as number,\n\t\t\t);\n\t\t\tindex = writeNumber(serializedFloat, index, cluster.capacity);\n\t\t\tindex = writeNumber(serializedFloat, index, cluster.count);\n\t\t}\n\n\t\tif (hasLocalState) {\n\t\t\tindex = writeNumber(serializedFloat, index, localGenCount);\n\t\t\tindex = writeNumber(serializedFloat, index, nextRangeBaseGenCount);\n\t\t\tindex = writeNumber(serializedFloat, index, normalizer.idRanges.size);\n\t\t\tfor (const [leadingGenCount, count] of normalizer.idRanges.entries()) {\n\t\t\t\tindex = writeNumber(serializedFloat, index, leadingGenCount);\n\t\t\t\tindex = writeNumber(serializedFloat, index, count);\n\t\t\t}\n\t\t}\n\n\t\tassert(index === totalSize, 0x75b /* Serialized size was incorrectly calculated. */);\n\t\tlogger?.sendTelemetryEvent({\n\t\t\teventName: \"RuntimeIdCompressor:SerializedIdCompressorSize\",\n\t\t\tsize: serializedFloat.byteLength,\n\t\t\tclusterCount: finalSpace.clusters.length,\n\t\t\tsessionCount: sessionIndexMap.size,\n\t\t});\n\n\t\treturn bufferToString(serializedFloat.buffer, \"base64\") as SerializedIdCompressor;\n\t}\n\n\tpublic static deserialize(\n\t\tparams:\n\t\t\t| {\n\t\t\t\t\tserialized: SerializedIdCompressorWithOngoingSession;\n\t\t\t\t\tlogger?: TelemetryLoggerExt | undefined;\n\t\t\t\t\tnewSessionId?: never;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tserialized: SerializedIdCompressorWithNoSession;\n\t\t\t\t\tnewSessionId: SessionId;\n\t\t\t\t\tlogger?: TelemetryLoggerExt | undefined;\n\t\t\t },\n\t): IdCompressor {\n\t\tconst { serialized, newSessionId, logger } = params;\n\t\tconst buffer = stringToBuffer(serialized, \"base64\");\n\t\tconst index: Index = {\n\t\t\tindex: 0,\n\t\t\tbufferFloat: new Float64Array(buffer),\n\t\t\tbufferUint: new BigUint64Array(buffer),\n\t\t};\n\t\tconst version = readNumber(index);\n\t\tswitch (version) {\n\t\t\tcase 1: {\n\t\t\t\tthrow new Error(\"IdCompressor version 1.0 is no longer supported.\");\n\t\t\t}\n\t\t\tcase 2: {\n\t\t\t\treturn IdCompressor.deserialize2_0(index, newSessionId, logger);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(\"Unknown IdCompressor serialized version.\");\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic deserialize2_0(\n\t\tindex: Index,\n\t\tsessionId: SessionId | undefined,\n\t\tlogger: TelemetryLoggerExt | undefined,\n\t): IdCompressor {\n\t\tconst hasLocalState = readBoolean(index);\n\t\tconst sessionCount = readNumber(index);\n\t\tconst clusterCount = readNumber(index);\n\n\t\t// Sessions\n\t\tlet sessionOffset = 0;\n\t\tconst sessions: [NumericUuid, Session][] = [];\n\t\tif (hasLocalState) {\n\t\t\tassert(\n\t\t\t\tsessionId === undefined,\n\t\t\t\t0x75e /* Local state should not exist in serialized form. */,\n\t\t\t);\n\t\t} else {\n\t\t\t// If !hasLocalState, there won't be a serialized local session ID so insert one at the beginning\n\t\t\tassert(sessionId !== undefined, 0x75d /* Local session ID is undefined. */);\n\t\t\tconst localSessionNumeric = numericUuidFromStableId(sessionId);\n\t\t\tsessions.push([localSessionNumeric, new Session(localSessionNumeric)]);\n\t\t\tsessionOffset = 1;\n\t\t}\n\n\t\tfor (let i = 0; i < sessionCount; i++) {\n\t\t\tconst numeric = readNumericUuid(index);\n\t\t\tsessions.push([numeric, new Session(numeric)]);\n\t\t}\n\n\t\tconst compressor = new IdCompressor(new Sessions(sessions), logger);\n\n\t\t// Clusters\n\t\tlet baseFinalId = 0;\n\t\tfor (let i = 0; i < clusterCount; i++) {\n\t\t\tconst sessionIndex = readNumber(index);\n\t\t\tconst sessionArray = sessions[sessionIndex + sessionOffset];\n\t\t\tassert(\n\t\t\t\tsessionArray !== undefined,\n\t\t\t\t0x9d8 /* sessionArray is undefined in IdCompressor.deserialize2_0 */,\n\t\t\t);\n\t\t\tconst session = sessionArray[1];\n\t\t\tconst capacity = readNumber(index);\n\t\t\tconst count = readNumber(index);\n\t\t\tconst cluster = session.addNewCluster(baseFinalId as FinalCompressedId, capacity, count);\n\t\t\tcompressor.finalSpace.addCluster(cluster);\n\t\t\tbaseFinalId += capacity;\n\t\t}\n\n\t\t// Local state\n\t\tif (hasLocalState) {\n\t\t\tcompressor.localGenCount = readNumber(index);\n\t\t\tcompressor.nextRangeBaseGenCount = readNumber(index);\n\t\t\tconst normalizerCount = readNumber(index);\n\t\t\tfor (let i = 0; i < normalizerCount; i++) {\n\t\t\t\tcompressor.normalizer.addLocalRange(readNumber(index), readNumber(index));\n\t\t\t}\n\t\t}\n\n\t\tassert(\n\t\t\tindex.index === index.bufferFloat.length,\n\t\t\t0x75f /* Failed to read entire serialized compressor. */,\n\t\t);\n\t\treturn compressor;\n\t}\n\n\tpublic equals(other: IdCompressor, includeLocalState: boolean): boolean {\n\t\tif (\n\t\t\tincludeLocalState &&\n\t\t\t(this.localSessionId !== other.localSessionId ||\n\t\t\t\t!this.localSession.equals(other.localSession) ||\n\t\t\t\t!this.normalizer.equals(other.normalizer) ||\n\t\t\t\tthis.nextRangeBaseGenCount !== other.nextRangeBaseGenCount ||\n\t\t\t\tthis.localGenCount !== other.localGenCount)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\treturn (\n\t\t\tthis.sessions.equals(other.sessions, includeLocalState) &&\n\t\t\tthis.finalSpace.equals(other.finalSpace)\n\t\t);\n\t}\n}\n\n/**\n * Create a new {@link IIdCompressor}.\n *\n * @legacy @beta\n */\nexport function createIdCompressor(logger?: ITelemetryBaseLogger): IIdCompressor;\n/**\n * Create a new {@link IIdCompressor}.\n * @param sessionId - The seed ID for the compressor.\n *\n * @legacy @beta\n */\nexport function createIdCompressor(\n\tsessionId: SessionId,\n\tlogger?: ITelemetryBaseLogger,\n): IIdCompressor;\nexport function createIdCompressor(\n\tsessionIdOrLogger?: SessionId | ITelemetryBaseLogger,\n\tloggerOrUndefined?: ITelemetryBaseLogger,\n): IIdCompressor & IIdCompressorCore {\n\tlet localSessionId: SessionId;\n\tlet logger: ITelemetryBaseLogger | undefined;\n\tif (sessionIdOrLogger === undefined) {\n\t\tlocalSessionId = createSessionId();\n\t} else {\n\t\tif (typeof sessionIdOrLogger === \"string\") {\n\t\t\tlocalSessionId = sessionIdOrLogger;\n\t\t\tlogger = loggerOrUndefined;\n\t\t} else {\n\t\t\tlocalSessionId = createSessionId();\n\t\t\tlogger = sessionIdOrLogger;\n\t\t}\n\t}\n\tconst compressor = new IdCompressor(\n\t\tlocalSessionId,\n\t\tlogger === undefined ? undefined : createChildLogger({ logger }),\n\t);\n\treturn compressor;\n}\n\n/**\n * Deserializes the supplied state into an ID compressor.\n *\n * @legacy @beta\n */\nexport function deserializeIdCompressor(\n\tserialized: SerializedIdCompressorWithOngoingSession,\n\tlogger?: ITelemetryLoggerExt,\n): IIdCompressor;\n/**\n * Deserializes the supplied state into an ID compressor.\n *\n * @legacy @beta\n */\nexport function deserializeIdCompressor(\n\tserialized: SerializedIdCompressorWithNoSession,\n\tnewSessionId: SessionId,\n\tlogger?: ITelemetryLoggerExt,\n): IIdCompressor;\nexport function deserializeIdCompressor(\n\tserialized: SerializedIdCompressor | SerializedIdCompressorWithNoSession,\n\tsessionIdOrLogger: SessionId | ITelemetryLoggerExt | undefined,\n\tloggerOrUndefined?: ITelemetryLoggerExt,\n): IIdCompressor & IIdCompressorCore {\n\tif (typeof sessionIdOrLogger === \"string\") {\n\t\treturn IdCompressor.deserialize({\n\t\t\tserialized: serialized as SerializedIdCompressorWithNoSession,\n\t\t\tlogger: extractTelemetryLoggerExt<{ PossiblyUndefined: true }>(loggerOrUndefined),\n\t\t\tnewSessionId: sessionIdOrLogger,\n\t\t});\n\t}\n\n\tassert(\n\t\tloggerOrUndefined === undefined,\n\t\t0xc2d /* logger would be in sessionIdOrLogger in this codepath */,\n\t);\n\treturn IdCompressor.deserialize({\n\t\tserialized: serialized as SerializedIdCompressorWithOngoingSession,\n\t\tlogger: extractTelemetryLoggerExt<{ PossiblyUndefined: true }>(sessionIdOrLogger),\n\t});\n}\n\n/**\n * Serializes an ID compressor.\n * @param compressor - The compressor to serialize.\n * @param withSession - If true, the serialized state will include local session\n * state (for stashing). If false, only finalized state is included (for summaries).\n * @legacy @beta\n */\nexport function serializeIdCompressor(\n\tcompressor: IIdCompressor,\n\twithSession: true,\n): SerializedIdCompressorWithOngoingSession;\n/**\n * Serializes an ID compressor.\n * @param compressor - The compressor to serialize.\n * @param withSession - If true, the serialized state will include local session\n * state (for stashing). If false, only finalized state is included (for summaries).\n * @legacy @beta\n */\nexport function serializeIdCompressor(\n\tcompressor: IIdCompressor,\n\twithSession: false,\n): SerializedIdCompressorWithNoSession;\nexport function serializeIdCompressor(\n\tcompressor: IIdCompressor,\n\twithSession: boolean,\n): SerializedIdCompressorWithOngoingSession | SerializedIdCompressorWithNoSession {\n\tconst core = toIdCompressorWithCore(compressor);\n\treturn withSession ? core.serialize(true) : core.serialize(false);\n}\n\n/**\n * Casts an {@link IIdCompressor} to include {@link IIdCompressorCore}.\n *\n * @remarks\n * Compressors returned by `createIdCompressor` and `deserializeIdCompressor`\n * always implement both {@link IIdCompressor} and {@link IIdCompressorCore}, but their\n * public return type is narrowed to {@link IIdCompressor}. Internal consumers that\n * need access to core compressor operations (serialization, range management, etc.)\n * use this function to recover the {@link IIdCompressorCore} surface.\n *\n * @param compressor - A compressor created by `createIdCompressor` or\n * `deserializeIdCompressor`.\n * @returns The same compressor, typed to include {@link IIdCompressorCore}.\n * @internal\n */\nexport function toIdCompressorWithCore(\n\tcompressor: IIdCompressor,\n): IIdCompressor & IIdCompressorCore {\n\tassert(\n\t\t\"serialize\" in compressor,\n\t\t0xced /* Expected compressor to implement IIdCompressorCore */,\n\t);\n\treturn compressor as IIdCompressor & IIdCompressorCore;\n}\n"]}
1
+ {"version":3,"file":"idCompressor.js","sourceRoot":"","sources":["../src/idCompressor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE7F,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EACN,YAAY,EACZ,iBAAiB,EACjB,yBAAyB,GACzB,MAAM,0CAA0C,CAAC;AAIlD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;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C,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1C,IAAI,GAAG,KAAK,aAAa,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,UAAU,EAAE,CAAC;YAC5E,8EAA8E;YAC9E,gFAAgF;YAChF,gFAAgF;YAChF,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,GAAG,EAAE;gBACtC,KAAK,EAAE,aAAa;gBACpB,YAAY,EAAE,IAAI;gBAClB,QAAQ,EAAE,IAAI;aACd,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;AACF,CAAC;AAwBD,MAAM,UAAU,qBAAqB,CACpC,UAAyB,EACzB,WAAoB;IAEpB,MAAM,IAAI,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;IAChD,OAAO,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,sBAAsB,CACrC,UAAyB;IAEzB,MAAM,CACL,WAAW,IAAI,UAAU,EACzB,KAAK,CAAC,wDAAwD,CAC9D,CAAC;IACF,OAAO,UAA+C,CAAC;AACxD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString, createEmitter, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport type { ITelemetryBaseLogger, Listenable } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { TelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\nimport {\n\tLoggingError,\n\tcreateChildLogger,\n\textractTelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n// eslint-disable-next-line import-x/no-internal-modules -- Needed to avoid specialized /internal ITelemetryLoggerExt\nimport type { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/legacy\";\n\nimport { FinalSpace } from \"./finalSpace.js\";\nimport {\n\ttype FinalCompressedId,\n\ttype LocalCompressedId,\n\ttype NumericUuid,\n\tisFinalId,\n} from \"./identifiers.js\";\nimport {\n\ttype Index,\n\treadBoolean,\n\treadNumber,\n\treadNumericUuid,\n\twriteBoolean,\n\twriteNumber,\n\twriteNumericUuid,\n} from \"./persistanceUtilities.js\";\nimport { SessionSpaceNormalizer } from \"./sessionSpaceNormalizer.js\";\nimport {\n\ttype IdCluster,\n\tSession,\n\tSessions,\n\tgetAlignedFinal,\n\tgetAlignedLocal,\n\tlastFinalizedFinal,\n\tlastFinalizedLocal,\n} from \"./sessions.js\";\nimport type {\n\tShardToken,\n\tIIdCompressor,\n\tIIdCompressorCore,\n\tIdCreationRange,\n\tOpSpaceCompressedId,\n\tSerializedIdCompressor,\n\tSerializedIdCompressorWithNoSession,\n\tSerializedIdCompressorWithOngoingSession,\n\tSessionId,\n\tSessionSpaceCompressedId,\n\tStableId,\n\tShardSynchronizationToken,\n\tSerializedIdCompressorShard,\n\tParentShardSynchronizationToken,\n\tIdCompressorEvents,\n} from \"./types/index.js\";\nimport { SerializationVersion } from \"./types/index.js\";\nimport {\n\tcreateSessionId,\n\tgenCountFromLocalId,\n\tlocalIdFromGenCount,\n\tnumericUuidFromStableId,\n\toffsetNumericUuid,\n\tstableIdFromNumericUuid,\n\tsubtractNumericUuids,\n} from \"./utilities.js\";\n\nfunction rangeFinalizationError(expectedStart: number, actualStart: number): LoggingError {\n\treturn new LoggingError(\"Ranges finalized out of order\", {\n\t\texpectedStart,\n\t\tactualStart,\n\t});\n}\n\nconst MAX_STRIDE_LENGTH = 1000000;\n\n/**\n * Validates the generation count in a shard synchronization token.\n *\n * @param localGenCount - The number of positions filled, including backfilled positions.\n * @throws {@link TypeError} if the count is not a nonnegative safe integer.\n */\nfunction validateShardGenerationCount(localGenCount: number): void {\n\tif (!Number.isSafeInteger(localGenCount) || localGenCount < 0) {\n\t\tthrow new TypeError(\"Invalid shard synchronization token generation count.\");\n\t}\n}\n\n/**\n * See {@link IIdCompressor} and {@link IIdCompressorCore}\n */\nexport class IdCompressor implements IIdCompressor, IIdCompressorCore {\n\tprivate readonly eventEmitter = createEmitter<IdCompressorEvents>();\n\n\tpublic readonly events: Listenable<IdCompressorEvents> = this.eventEmitter;\n\n\t/**\n\t * Max allowed initial cluster size.\n\t */\n\tpublic static readonly maxClusterSize = 2 ** 20;\n\n\t// #region Local state\n\n\tpublic readonly localSessionId: SessionId;\n\tprivate readonly localSession: Session;\n\tprivate readonly normalizer = new SessionSpaceNormalizer();\n\t// The number of IDs generated by the local session\n\tprivate localGenCount = 0;\n\n\t/**\n\t * The sharding state of this compressor, if it has been sharded or is a shard itself.\n\t * When defined, this compressor operates in \"sharding mode\" where:\n\t * - IDs are generated using stride-based allocation (no eager finals)\n\t * - The normalizer backfills all IDs in each stride cycle\n\t * - Normal operation resumes when all children are disposed\n\t */\n\tprivate shardingState?:\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Current stride - used when this compressor has active children.\n\t\t\t\t * Changes each time shard() is called.\n\t\t\t\t */\n\t\t\t\tcurrentStride: number;\n\n\t\t\t\t/**\n\t\t\t\t * Original stride - the stride this compressor was created with.\n\t\t\t\t * Used when this compressor has no children (is a leaf).\n\t\t\t\t * IMMUTABLE after creation.\n\t\t\t\t */\n\t\t\t\toriginalStride: number;\n\n\t\t\t\t/**\n\t\t\t\t * Set of unique child shard IDs (UUIDs) currently active.\n\t\t\t\t * Each child is assigned a UUID when created via shard().\n\t\t\t\t * Safe across serialization/deserialization cycles.\n\t\t\t\t */\n\t\t\t\tactiveChildIds: Set<SessionId>;\n\n\t\t\t\t/**\n\t\t\t\t * This compressor's unique shard ID within its parent (if it's a child).\n\t\t\t\t * Undefined for root compressors.\n\t\t\t\t * Assigned by parent when creating this shard.\n\t\t\t\t */\n\t\t\t\tshardId?: SessionId;\n\t\t }\n\t\t| undefined;\n\n\t// #endregion\n\n\t// #region Final state\n\n\t/**\n\t * The gen count to be annotated on the range returned by the next call to `takeNextCreationRange`.\n\t * This is advanced to `localGenCount` + 1 each time it is called.\n\t * On the other hand, when `resetUnfinalizedCreationRange` is called,\n\t * this is moved back to the start of the unfinalized range, to ensure those IDs are included in the next range.\n\t */\n\tprivate nextRangeBaseGenCount = 1;\n\tprivate readonly sessions = new Sessions();\n\tprivate readonly finalSpace = new FinalSpace();\n\n\t// #endregion\n\n\t// #region Ephemeral state\n\n\t/**\n\t * Roughly equates to a minimum of 1M sessions before we start allocating 64 bit IDs.\n\t * Eventually, this can be adjusted dynamically to have cluster reservation policies that\n\t * optimize the number of eager finals.\n\t * It is not readonly as it is accessed by tests for clear-box testing.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/prefer-readonly\n\tprivate nextRequestedClusterSize: number = 512;\n\t// The number of local IDs generated since the last telemetry was sent.\n\tprivate telemetryLocalIdCount = 0;\n\t// The number of eager final IDs generated since the last telemetry was sent.\n\tprivate telemetryEagerFinalIdCount = 0;\n\t// The ongoing ghost session, if one exists.\n\tprivate ongoingGhostSession?: { cluster?: IdCluster; ghostSessionId: SessionId } | undefined;\n\n\t// #endregion\n\n\tpublic constructor(\n\t\tlocalSessionIdOrDeserialized: SessionId | Sessions,\n\t\tprivate readonly logger: TelemetryLoggerExt | undefined,\n\t\t/**\n\t\t * The version this compressor will write out.\n\t\t * This applies to both `serialize` and creation range functions.\n\t\t * This number also determines what features are available (e.g. sharding support starts at V3).\n\t\t */\n\t\tprivate readonly writeVersion: SerializationVersion,\n\t) {\n\t\tif (typeof localSessionIdOrDeserialized === \"string\") {\n\t\t\tthis.localSessionId = localSessionIdOrDeserialized;\n\t\t\tthis.localSession = this.sessions.getOrCreate(localSessionIdOrDeserialized);\n\t\t} else {\n\t\t\t// Deserialize case\n\t\t\tthis.sessions = localSessionIdOrDeserialized;\n\t\t\t// As policy, the first session is always the local session. Preserve this invariant\n\t\t\t// during deserialization.\n\t\t\tconst firstSession = localSessionIdOrDeserialized.sessions().next();\n\t\t\tassert(!firstSession.done, 0x754 /* First session must be present. */);\n\t\t\tthis.localSession = firstSession.value;\n\t\t\tthis.localSessionId = stableIdFromNumericUuid(\n\t\t\t\tthis.localSession.sessionUuid,\n\t\t\t) as SessionId;\n\t\t}\n\t}\n\n\tpublic generateCompressedId(): SessionSpaceCompressedId {\n\t\t// This ghost session code inside this block should not be changed without a version bump (it is performed at a consensus point)\n\t\tif (this.ongoingGhostSession) {\n\t\t\tif (this.ongoingGhostSession.cluster === undefined) {\n\t\t\t\tthis.ongoingGhostSession.cluster = this.addEmptyCluster(\n\t\t\t\t\tthis.sessions.getOrCreate(this.ongoingGhostSession.ghostSessionId),\n\t\t\t\t\t1,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.ongoingGhostSession.cluster.capacity++;\n\t\t\t}\n\t\t\tthis.ongoingGhostSession.cluster.count++;\n\t\t\treturn lastFinalizedFinal(\n\t\t\t\tthis.ongoingGhostSession.cluster,\n\t\t\t) as unknown as SessionSpaceCompressedId;\n\t\t}\n\n\t\t// In sharding mode, always generate local IDs with stride-based allocation.\n\t\t// Eager finals are disabled because shards backfill IDs not in their stride cycle.\n\t\t// If another shard generated them as eager finals, ingesting IDs from another shard\n\t\t// would fail depending on timing.\n\t\tif (this.shardingState !== undefined) {\n\t\t\tthis.telemetryLocalIdCount++;\n\t\t\tconst { currentStride } = this.shardingState;\n\t\t\tthis.normalizer.addLocalRange(this.localGenCount + 1, currentStride);\n\t\t\tthis.localGenCount += currentStride;\n\t\t\treturn localIdFromGenCount(this.localGenCount);\n\t\t}\n\n\t\t// Normal ID generation\n\t\tthis.localGenCount++;\n\t\tconst lastCluster = this.localSession.getLastCluster();\n\t\tif (lastCluster === undefined) {\n\t\t\tthis.telemetryLocalIdCount++;\n\t\t\treturn this.generateNextLocalId();\n\t\t}\n\n\t\t// If there exists a cluster of final IDs already claimed by the local session that still has room in it,\n\t\t// it is known prior to range sequencing what a local ID's corresponding final ID will be.\n\t\t// In this case, it is safe to return the final ID immediately. This is guaranteed to be safe because\n\t\t// any op that the local session sends that contains one of those final IDs are guaranteed to arrive to\n\t\t// collaborators *after* the one containing the creation range.\n\t\tconst clusterOffset = this.localGenCount - genCountFromLocalId(lastCluster.baseLocalId);\n\t\tif (lastCluster.capacity > clusterOffset) {\n\t\t\tthis.telemetryEagerFinalIdCount++;\n\t\t\t// Space in the cluster: eager final\n\t\t\treturn ((lastCluster.baseFinalId as number) + clusterOffset) as SessionSpaceCompressedId;\n\t\t}\n\t\t// No space in the cluster, return next local\n\t\tthis.telemetryLocalIdCount++;\n\t\treturn this.generateNextLocalId();\n\t}\n\n\tpublic generateDocumentUniqueId():\n\t\t| (SessionSpaceCompressedId & OpSpaceCompressedId)\n\t\t| StableId {\n\t\tconst id = this.generateCompressedId();\n\t\treturn isFinalId(id) ? id : this.decompress(id);\n\t}\n\n\t/**\n\t * Starts a ghost session. Only exposed for test purposes (this class is not exported from the package).\n\t * @param ghostSessionId - The session ID to start the ghost session with.\n\t */\n\tpublic startGhostSession(ghostSessionId: SessionId): void {\n\t\tassert(!this.ongoingGhostSession, 0x8fe /* Ghost session already in progress. */);\n\t\tthis.ongoingGhostSession = { ghostSessionId };\n\t}\n\n\tpublic beginGhostSession(ghostSessionId: SessionId, ghostSessionCallback: () => void): void {\n\t\tif (this.shardingState) {\n\t\t\tthrow new Error(\"Cannot start a ghost session while sharded.\");\n\t\t}\n\t\tthis.startGhostSession(ghostSessionId);\n\t\ttry {\n\t\t\tghostSessionCallback();\n\t\t} finally {\n\t\t\tthis.ongoingGhostSession = undefined;\n\t\t}\n\t}\n\n\tpublic shard(newShardCount: number): SerializedIdCompressorShard[] {\n\t\tif (!Number.isSafeInteger(newShardCount) || newShardCount <= 0) {\n\t\t\tthrow new Error(\"Shard count must be a positive safe integer\");\n\t\t}\n\t\tif (this.ongoingGhostSession) {\n\t\t\tthrow new Error(\"Cannot shard during ghost session\");\n\t\t}\n\t\tif (this.writeVersion < SerializationVersion.V3) {\n\t\t\tthrow new Error(\n\t\t\t\t`Sharding requires document version ${SerializationVersion.V3} or higher, but this document is version ${this.writeVersion}`,\n\t\t\t);\n\t\t}\n\n\t\tconst currentStride = this.shardingState?.currentStride ?? 1;\n\t\tconst newStride = currentStride * (newShardCount + 1);\n\n\t\t// ID usage is exponential in stride count. Limit to practical size to avoid overflow.\n\t\tif (newStride > MAX_STRIDE_LENGTH) {\n\t\t\tthrow new Error(\"Sharding limit reached.\");\n\t\t}\n\t\tassert(Number.isSafeInteger(newStride), 0xd52 /* Shard stride must be a safe integer */);\n\n\t\tif (this.shardingState === undefined) {\n\t\t\t// First time sharding - initialize state\n\t\t\tthis.shardingState = {\n\t\t\t\tcurrentStride: newStride,\n\t\t\t\toriginalStride: 1,\n\t\t\t\tactiveChildIds: new Set(),\n\t\t\t};\n\t\t} else {\n\t\t\tthis.shardingState.currentStride = newStride;\n\t\t}\n\n\t\t// Cache to avoid repeating per child\n\t\tconst serialized = this.serialize(true);\n\t\tconst { localGenCount: parentGenCount } = this;\n\n\t\tconst shards: SerializedIdCompressorShard[] = [];\n\n\t\t// Children are positioned at consecutive positions within the parents current stride cycle\n\t\t// e.g. if parent owns the \"evens\" space (-2, -4, -6, ...) and is sharded into 3 (two children)\n\t\t// while at -8, then the child shards will start at -10 and -12 with a stride of 6\n\t\tfor (let i = 1; i <= newShardCount; i++) {\n\t\t\tconst childShardId = createSessionId();\n\t\t\tthis.shardingState.activeChildIds.add(childShardId);\n\n\t\t\tconst childLocalGenCount = parentGenCount + i * currentStride;\n\n\t\t\t// This code results in a double roundtrip, but is probably plenty fast enough for scenarios that need sharding,\n\t\t\t// as they necessarily have process boundaries to deal with.\n\t\t\t// If this ever became an issue we can implement a fast clone of compressors\n\t\t\tconst child = deserializeIdCompressor(serialized, this.writeVersion) as IdCompressor;\n\t\t\tconst genCountJump = childLocalGenCount - parentGenCount;\n\t\t\tassert(\n\t\t\t\tchild.localGenCount === parentGenCount && genCountJump > 0,\n\t\t\t\t0xd53 /* Child offsets incorrectly calculated. */,\n\t\t\t);\n\n\t\t\tchild.normalizer.addLocalRange(child.localGenCount + 1, genCountJump);\n\t\t\tchild.localGenCount = childLocalGenCount;\n\t\t\tchild.shardingState = {\n\t\t\t\tcurrentStride: newStride,\n\t\t\t\toriginalStride: newStride,\n\t\t\t\tactiveChildIds: new Set(),\n\t\t\t\tshardId: childShardId,\n\t\t\t};\n\n\t\t\tshards.push({\n\t\t\t\tserialized: child.serialize(true),\n\t\t\t\tsyncToken: child.makeShardToken(false),\n\t\t\t});\n\t\t}\n\n\t\treturn shards;\n\t}\n\n\tpublic synchronizeWithShard(syncToken: ShardSynchronizationToken): void {\n\t\tconst isNowLeaf = this.synchronizeChild(syncToken);\n\t\t// A disposal token additionally reclaims the child's ID space. If reclaiming the last child\n\t\t// returns this compressor to a leaf and it is the root (originalStride === 1), exit sharding mode.\n\t\tif (syncToken.disposed) {\n\t\t\tassert(this.shardingState !== undefined, 0xd54 /* Must be sharded */);\n\t\t\tif (isNowLeaf && this.shardingState.originalStride === 1) {\n\t\t\t\tthis.shardingState = undefined;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic getChildShardSyncToken(\n\t\tchildToken: ShardSynchronizationToken,\n\t): ParentShardSynchronizationToken {\n\t\tif (!this.shardingState?.activeChildIds.has(childToken.shardId)) {\n\t\t\tthrow new Error(\"Cannot get a synchronization token for an inactive child shard.\");\n\t\t}\n\t\tconst token: ParentShardSynchronizationToken = {\n\t\t\ttype: \"parentIdSpaceShardSyncToken\",\n\t\t\tshardId: childToken.shardId,\n\t\t\tlocalGenCount: this.localGenCount,\n\t\t};\n\t\treturn token;\n\t}\n\n\tpublic synchronizeWithParent(token: ParentShardSynchronizationToken): void {\n\t\tconst state = this.shardingState;\n\t\tif (\n\t\t\ttoken.type !== \"parentIdSpaceShardSyncToken\" ||\n\t\t\tstate?.shardId === undefined ||\n\t\t\tstate.shardId !== token.shardId\n\t\t) {\n\t\t\tthrow new Error(\"Invalid parent synchronization token for this child shard.\");\n\t\t}\n\t\tvalidateShardGenerationCount(token.localGenCount);\n\t\tif (token.localGenCount <= this.localGenCount) {\n\t\t\t// A child can already be ahead through its own allocations. Its local range\n\t\t\t// then includes the parent's IDs through this generation count.\n\t\t\treturn;\n\t\t}\n\t\tthis.backfillToNextStridePosition(token.localGenCount, state.currentStride);\n\t}\n\n\t/**\n\t * Adds IDs through the next position in this shard's stride after the given generation count.\n\t */\n\tprivate backfillToNextStridePosition(targetGenCount: number, stride: number): void {\n\t\tif (targetGenCount <= this.localGenCount) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = Math.ceil((targetGenCount - this.localGenCount + 1) / stride) * stride;\n\t\tconst nextGenCount = this.localGenCount + count;\n\t\tif (!Number.isSafeInteger(nextGenCount)) {\n\t\t\tthrow new TypeError(\"Shard progress exceeds the supported ID space.\");\n\t\t}\n\t\tthis.normalizer.addLocalRange(this.localGenCount + 1, count);\n\t\tthis.localGenCount = nextGenCount;\n\t}\n\n\tprivate synchronizeChild(syncToken: ShardToken): boolean {\n\t\tconst childDisposed = syncToken.disposed;\n\t\tif (this.writeVersion < SerializationVersion.V3) {\n\t\t\tthrow new Error(\n\t\t\t\t`Sharding requires document version ${SerializationVersion.V3} or higher, but this document is version ${this.writeVersion}`,\n\t\t\t);\n\t\t}\n\t\tif (this.shardingState === undefined) {\n\t\t\tthrow new Error(\"Must be in sharding mode.\");\n\t\t}\n\n\t\tconst childShardId = syncToken.shardId;\n\t\tconst { activeChildIds, originalStride } = this.shardingState;\n\n\t\t// Verify this child belongs to us\n\t\tif (!activeChildIds.has(childShardId)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot synchronize with child with ID ${childShardId}: not in active children set`,\n\t\t\t);\n\t\t}\n\t\tvalidateShardGenerationCount(syncToken.localGenCount);\n\n\t\t// A last-child disposal realigns on the original stride. Backfill before changing\n\t\t// membership so invalid progress cannot accidentally reclaim the child.\n\t\tconst isLeaf = childDisposed && activeChildIds.size === 1;\n\t\tthis.backfillToNextStridePosition(\n\t\t\tsyncToken.localGenCount,\n\t\t\tisLeaf ? originalStride : this.shardingState.currentStride,\n\t\t);\n\n\t\t// A plain synchronization leaves the child active so it can keep generating IDs.\n\t\tif (childDisposed) {\n\t\t\tactiveChildIds.delete(childShardId);\n\t\t\tif (isLeaf) {\n\t\t\t\tthis.shardingState.currentStride = originalStride;\n\t\t\t}\n\t\t}\n\n\t\treturn isLeaf;\n\t}\n\n\tpublic disposeShard(): ShardSynchronizationToken | undefined {\n\t\tif (this.shardingState === undefined) {\n\t\t\treturn undefined;\n\t\t} else {\n\t\t\tif (this.shardingState.activeChildIds.size > 0) {\n\t\t\t\tthrow new Error(\"Cannot dispose a shard with active children.\");\n\t\t\t}\n\t\t}\n\n\t\t// A disposal token is a sync token that additionally signals reclamation of this shard's ID space.\n\t\tconst token = this.makeShardToken(true);\n\n\t\t// Make this compressor unusable by replacing all methods with throwing stubs\n\t\t// This is a one-time mutation that avoids runtime checks in every method\n\t\tmakeCompressorUnusable(this);\n\n\t\treturn token;\n\t}\n\n\tpublic getShardSyncToken(): ShardSynchronizationToken | undefined {\n\t\tif (this.shardingState === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn this.makeShardToken(false);\n\t}\n\n\t/**\n\t * Builds a token describing this shard's current progress.\n\t * @param disposed - Whether the token also signals disposal (reclamation of this shard's ID space).\n\t */\n\tprivate makeShardToken(disposed: boolean): ShardSynchronizationToken {\n\t\tassert(this.shardingState !== undefined, 0xd55 /* Compressor is not sharded. */);\n\n\t\t// Root cannot produce a token (shardId is undefined for root)\n\t\tif (this.shardingState.shardId === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Cannot get a token for a root compressor - only shards can be disposed\",\n\t\t\t);\n\t\t}\n\n\t\tconst token: ShardToken = {\n\t\t\tlocalGenCount: this.localGenCount,\n\t\t\tshardId: this.shardingState.shardId,\n\t\t\tdisposed,\n\t\t};\n\n\t\treturn token as unknown as ShardSynchronizationToken;\n\t}\n\n\tprivate generateNextLocalId(): LocalCompressedId {\n\t\t// Must tell the normalizer that we generated a local ID\n\t\tthis.normalizer.addLocalRange(this.localGenCount, 1);\n\t\treturn localIdFromGenCount(this.localGenCount);\n\t}\n\n\tpublic takeNextCreationRange(): IdCreationRange {\n\t\t// Child (non-root) shards must not submit their own creation ranges. All shards in a shard tree share a\n\t\t// single session, and only the root shard is responsible for finalizing that session's IDs with the server.\n\t\t// A child's generated IDs are reconciled with the root via shard synchronization tokens (see\n\t\t// synchronizeWithShard / disposeShard), not by independently sending ranges, which would overlap and\n\t\t// conflict with the root's ranges for the shared session.\n\t\tif (this.shardingState?.shardId !== undefined) {\n\t\t\tthrow new Error(\"Cannot take a creation range from a non-root shard.\");\n\t\t}\n\t\tassert(\n\t\t\t!this.ongoingGhostSession,\n\t\t\t0x8a6 /* IdCompressor should not be operated normally when in a ghost session */,\n\t\t);\n\t\tconst count = this.localGenCount - (this.nextRangeBaseGenCount - 1);\n\t\tif (count === 0) {\n\t\t\treturn {\n\t\t\t\tsessionId: this.localSessionId,\n\t\t\t};\n\t\t}\n\t\tconst range: IdCreationRange = {\n\t\t\tsessionId: this.localSessionId,\n\t\t\tids: {\n\t\t\t\tfirstGenCount: this.nextRangeBaseGenCount,\n\t\t\t\tcount,\n\t\t\t\trequestedClusterSize: this.nextRequestedClusterSize,\n\t\t\t\tlocalIdRanges: this.normalizer.getRangesBetween(\n\t\t\t\t\tthis.nextRangeBaseGenCount,\n\t\t\t\t\tthis.localGenCount,\n\t\t\t\t),\n\t\t\t},\n\t\t};\n\t\treturn this.updateToRange(range);\n\t}\n\n\tpublic takeUnfinalizedCreationRange(): IdCreationRange {\n\t\tthis.resetUnfinalizedCreationRange();\n\t\treturn this.takeNextCreationRange();\n\t}\n\n\tpublic resetUnfinalizedCreationRange(): void {\n\t\tassert(\n\t\t\t!this.ongoingGhostSession,\n\t\t\t0xcec /* IdCompressor should not be operated normally when in a ghost session */,\n\t\t);\n\n\t\tconst lastLocalCluster = this.localSession.getLastCluster();\n\t\tthis.nextRangeBaseGenCount =\n\t\t\tlastLocalCluster === undefined\n\t\t\t\t? 1\n\t\t\t\t: genCountFromLocalId(\n\t\t\t\t\t\t(lastLocalCluster.baseLocalId - lastLocalCluster.count) as LocalCompressedId,\n\t\t\t\t\t);\n\t}\n\n\tprivate updateToRange(range: IdCreationRange): IdCreationRange {\n\t\tthis.nextRangeBaseGenCount = this.localGenCount + 1;\n\t\treturn IdCompressor.assertValidRange(range);\n\t}\n\n\tprivate static assertValidRange(range: IdCreationRange): IdCreationRange {\n\t\tif (range.ids === undefined) {\n\t\t\treturn range;\n\t\t}\n\t\tconst { count, requestedClusterSize } = range.ids;\n\t\tassert(count > 0, 0x755 /* Malformed ID Range. */);\n\t\tassert(requestedClusterSize > 0, 0x876 /* Clusters must have a positive capacity. */);\n\t\tassert(\n\t\t\trequestedClusterSize <= IdCompressor.maxClusterSize,\n\t\t\t0x877 /* Clusters must not exceed max cluster size. */,\n\t\t);\n\t\treturn range;\n\t}\n\n\tpublic finalizeCreationRange(range: IdCreationRange): void {\n\t\tassert(\n\t\t\t!this.ongoingGhostSession,\n\t\t\t0x8a7 /* IdCompressor should not be operated normally when in a ghost session */,\n\t\t);\n\t\t// Check if the range has IDs\n\t\tif (range.ids === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tIdCompressor.assertValidRange(range);\n\t\tconst { sessionId, ids } = range;\n\t\tconst { count, firstGenCount, requestedClusterSize } = ids;\n\t\tconst session = this.sessions.getOrCreate(sessionId);\n\t\tconst isLocal = session === this.localSession;\n\t\tconst rangeBaseLocal = localIdFromGenCount(firstGenCount);\n\t\tlet lastCluster = session.getLastCluster();\n\t\tif (lastCluster === undefined) {\n\t\t\t// This is the first cluster in the session space\n\t\t\tif (rangeBaseLocal !== -1) {\n\t\t\t\tthrow rangeFinalizationError(-1, rangeBaseLocal);\n\t\t\t}\n\t\t\tlastCluster = this.addEmptyCluster(session, requestedClusterSize + count);\n\t\t\tif (isLocal) {\n\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\teventName: \"RuntimeIdCompressor:FirstCluster\",\n\t\t\t\t\tsessionId: this.localSessionId,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tconst remainingCapacity = lastCluster.capacity - lastCluster.count;\n\t\tif (lastCluster.baseLocalId - lastCluster.count !== rangeBaseLocal) {\n\t\t\tthrow rangeFinalizationError(\n\t\t\t\tlastCluster.baseLocalId - lastCluster.count,\n\t\t\t\trangeBaseLocal,\n\t\t\t);\n\t\t}\n\n\t\tif (remainingCapacity >= count) {\n\t\t\t// The current range fits in the existing cluster\n\t\t\tlastCluster.count += count;\n\t\t} else {\n\t\t\tconst overflow = count - remainingCapacity;\n\t\t\tconst newClaimedFinalCount = overflow + requestedClusterSize;\n\t\t\tif (lastCluster === this.finalSpace.getLastCluster()) {\n\t\t\t\t// The last cluster in the sessions chain is the last cluster globally, so it can be expanded.\n\t\t\t\tlastCluster.capacity += newClaimedFinalCount;\n\t\t\t\tlastCluster.count += count;\n\t\t\t\tassert(\n\t\t\t\t\t!this.sessions.clusterCollides(lastCluster),\n\t\t\t\t\t0x756 /* Cluster collision detected. */,\n\t\t\t\t);\n\t\t\t\tif (isLocal) {\n\t\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"RuntimeIdCompressor:ClusterExpansion\",\n\t\t\t\t\t\tsessionId: this.localSessionId,\n\t\t\t\t\t\tpreviousCapacity: lastCluster.capacity - newClaimedFinalCount,\n\t\t\t\t\t\tnewCapacity: lastCluster.capacity,\n\t\t\t\t\t\toverflow,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// The last cluster in the sessions chain is *not* the last cluster globally. Fill and overflow to new.\n\t\t\t\tlastCluster.count = lastCluster.capacity;\n\t\t\t\tconst newCluster = this.addEmptyCluster(session, newClaimedFinalCount);\n\t\t\t\tnewCluster.count += overflow;\n\t\t\t\tif (isLocal) {\n\t\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"RuntimeIdCompressor:NewCluster\",\n\t\t\t\t\t\tsessionId: this.localSessionId,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (isLocal) {\n\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\teventName: \"RuntimeIdCompressor:IdCompressorStatus\",\n\t\t\t\teagerFinalIdCount: this.telemetryEagerFinalIdCount,\n\t\t\t\tlocalIdCount: this.telemetryLocalIdCount,\n\t\t\t\tsessionId: this.localSessionId,\n\t\t\t});\n\t\t\tthis.telemetryEagerFinalIdCount = 0;\n\t\t\tthis.telemetryLocalIdCount = 0;\n\t\t}\n\n\t\tassert(!session.isEmpty(), 0x757 /* Empty sessions should not be created. */);\n\t\tthis.eventEmitter.emit(\"rangeFinalized\", range);\n\t}\n\n\tprivate addEmptyCluster(session: Session, capacity: number): IdCluster {\n\t\tassert(\n\t\t\t!this.ongoingGhostSession?.cluster,\n\t\t\t0x8a8 /* IdCompressor should not be operated normally when in a ghost session */,\n\t\t);\n\t\tconst newCluster = session.addNewCluster(\n\t\t\tthis.finalSpace.getAllocatedIdLimit(),\n\t\t\tcapacity,\n\t\t\t0,\n\t\t);\n\t\tassert(\n\t\t\t!this.sessions.clusterCollides(newCluster),\n\t\t\t0x758 /* Cluster collision detected. */,\n\t\t);\n\t\tthis.finalSpace.addCluster(newCluster);\n\t\treturn newCluster;\n\t}\n\n\tpublic normalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId {\n\t\tif (isFinalId(id)) {\n\t\t\treturn id;\n\t\t} else {\n\t\t\tconst local = id as unknown as LocalCompressedId;\n\t\t\tif (!this.normalizer.contains(local)) {\n\t\t\t\tthrow new Error(\"Invalid ID to normalize.\");\n\t\t\t}\n\t\t\tconst finalForm = this.localSession.tryConvertToFinal(local, true);\n\t\t\treturn finalForm === undefined\n\t\t\t\t? (local as unknown as OpSpaceCompressedId)\n\t\t\t\t: (finalForm as OpSpaceCompressedId);\n\t\t}\n\t}\n\n\tpublic tryNormalizeToSessionSpaceWithoutSession(\n\t\tid: OpSpaceCompressedId,\n\t): SessionSpaceCompressedId | undefined {\n\t\tif (isFinalId(id)) {\n\t\t\tconst containingCluster = this.localSession.getClusterByAllocatedFinal(id);\n\t\t\tif (containingCluster === undefined) {\n\t\t\t\t// Does not exist in local cluster chain\n\t\t\t\tif (id >= this.finalSpace.getFinalizedIdLimit()) {\n\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t}\n\t\t\t\treturn id as unknown as SessionSpaceCompressedId;\n\t\t\t} else {\n\t\t\t\tconst alignedLocal = getAlignedLocal(containingCluster, id);\n\t\t\t\tif (this.normalizer.contains(alignedLocal)) {\n\t\t\t\t\treturn alignedLocal;\n\t\t\t\t} else {\n\t\t\t\t\tif (genCountFromLocalId(alignedLocal) > this.localGenCount) {\n\t\t\t\t\t\t// The ID is not valid in this compressor. It is either from a future version of this compressor, or another compressor.\n\t\t\t\t\t\t// Since IDs from other compressors often are valid in this one, but uncompress incorrectly,\n\t\t\t\t\t\t// we cannot rely on this function (tryNormalizeToSessionSpaceWithoutSession) to validate that the IDs are from the same compressor.\n\t\t\t\t\t\t// Since such validation can not be robust, this \"try\" function is explicitly documented not to be allowed to be used for this case.\n\t\t\t\t\t\t// Therefore, as documented in the API docs for this function, calls can not rely on a specific output in this case,\n\t\t\t\t\t\t// and therefore the document behavior of throwing makes the most sense (helps catch bugs).\n\t\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t\t}\n\t\t\t\t\treturn id as unknown as SessionSpaceCompressedId;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tpublic normalizeToSessionSpace(\n\t\tid: OpSpaceCompressedId,\n\t\toriginSessionId: SessionId,\n\t): SessionSpaceCompressedId {\n\t\tconst normalizedWithoutSession = this.tryNormalizeToSessionSpaceWithoutSession(id);\n\t\tif (normalizedWithoutSession === undefined) {\n\t\t\tconst localToNormalize = id as unknown as LocalCompressedId;\n\t\t\tif (originSessionId === this.localSessionId) {\n\t\t\t\tif (this.normalizer.contains(localToNormalize)) {\n\t\t\t\t\treturn localToNormalize;\n\t\t\t\t} else {\n\t\t\t\t\t// We never generated this local ID, so fail\n\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// LocalId from a remote session\n\t\t\t\tconst remoteSession = this.sessions.get(originSessionId);\n\t\t\t\tif (remoteSession === undefined) {\n\t\t\t\t\tthrow new Error(\"No IDs have ever been finalized by the supplied session.\");\n\t\t\t\t}\n\t\t\t\tconst correspondingFinal = remoteSession.tryConvertToFinal(localToNormalize, false);\n\t\t\t\tif (correspondingFinal === undefined) {\n\t\t\t\t\tthrow new Error(\"Unknown op space ID.\");\n\t\t\t\t}\n\t\t\t\treturn correspondingFinal as unknown as SessionSpaceCompressedId;\n\t\t\t}\n\t\t} else {\n\t\t\treturn normalizedWithoutSession;\n\t\t}\n\t}\n\n\tpublic decompress(id: SessionSpaceCompressedId): StableId {\n\t\tif (isFinalId(id)) {\n\t\t\tconst containingCluster = Session.getContainingCluster(id, this.finalSpace.clusters);\n\t\t\tif (containingCluster === undefined) {\n\t\t\t\tthrow new Error(\"Unknown ID\");\n\t\t\t}\n\t\t\tconst alignedLocal = getAlignedLocal(containingCluster, id);\n\t\t\tconst alignedGenCount = genCountFromLocalId(alignedLocal);\n\t\t\tconst lastFinalizedGenCount = genCountFromLocalId(lastFinalizedLocal(containingCluster));\n\t\t\tif (alignedGenCount > lastFinalizedGenCount) {\n\t\t\t\t// should be an eager final id generated by the local session\n\t\t\t\tif (containingCluster.session === this.localSession) {\n\t\t\t\t\tassert(!this.normalizer.contains(alignedLocal), 0x759 /* Normalizer out of sync. */);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(\"Unknown ID\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn stableIdFromNumericUuid(\n\t\t\t\toffsetNumericUuid(containingCluster.session.sessionUuid, alignedGenCount - 1),\n\t\t\t);\n\t\t} else {\n\t\t\tconst localToDecompress = id as unknown as LocalCompressedId;\n\t\t\tif (!this.normalizer.contains(localToDecompress)) {\n\t\t\t\tthrow new Error(\"Unknown ID\");\n\t\t\t}\n\t\t\treturn stableIdFromNumericUuid(\n\t\t\t\toffsetNumericUuid(\n\t\t\t\t\tthis.localSession.sessionUuid,\n\t\t\t\t\tgenCountFromLocalId(localToDecompress) - 1,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic recompress(uncompressed: StableId): SessionSpaceCompressedId {\n\t\tconst recompressed = this.tryRecompress(uncompressed);\n\t\tif (recompressed === undefined) {\n\t\t\tthrow new Error(\"Could not recompress.\");\n\t\t}\n\t\treturn recompressed;\n\t}\n\n\tpublic tryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined {\n\t\tconst match = this.sessions.getContainingCluster(uncompressed);\n\t\tif (match === undefined) {\n\t\t\tconst numericUncompressed = numericUuidFromStableId(uncompressed);\n\t\t\tconst offset = subtractNumericUuids(numericUncompressed, this.localSession.sessionUuid);\n\t\t\tif (offset < Number.MAX_SAFE_INTEGER) {\n\t\t\t\tconst genCountEquivalent = Number(offset) + 1;\n\t\t\t\tconst localEquivalent = localIdFromGenCount(genCountEquivalent);\n\t\t\t\tif (this.normalizer.contains(localEquivalent)) {\n\t\t\t\t\treturn localEquivalent;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn undefined;\n\t\t} else {\n\t\t\tconst [containingCluster, alignedLocal] = match;\n\t\t\tif (containingCluster.session === this.localSession) {\n\t\t\t\t// Local session\n\t\t\t\tif (this.normalizer.contains(alignedLocal)) {\n\t\t\t\t\treturn alignedLocal;\n\t\t\t\t} else {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tgenCountFromLocalId(alignedLocal) <= this.localGenCount,\n\t\t\t\t\t\t0x75a /* Clusters out of sync. */,\n\t\t\t\t\t);\n\t\t\t\t\t// Id is an eager final\n\t\t\t\t\treturn getAlignedFinal(containingCluster, alignedLocal) as\n\t\t\t\t\t\t| SessionSpaceCompressedId\n\t\t\t\t\t\t| undefined;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Not the local session\n\t\t\t\treturn genCountFromLocalId(alignedLocal) >= lastFinalizedLocal(containingCluster)\n\t\t\t\t\t? (getAlignedFinal(containingCluster, alignedLocal) as\n\t\t\t\t\t\t\t| SessionSpaceCompressedId\n\t\t\t\t\t\t\t| undefined)\n\t\t\t\t\t: undefined;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic serialize(withSession: true): SerializedIdCompressorWithOngoingSession;\n\tpublic serialize(withSession: false): SerializedIdCompressorWithNoSession;\n\tpublic serialize(hasLocalState: boolean): SerializedIdCompressor {\n\t\tassert(\n\t\t\t!this.ongoingGhostSession,\n\t\t\t0x8a9 /* IdCompressor should not be operated normally when in a ghost session */,\n\t\t);\n\t\tconst { normalizer, finalSpace, sessions, localGenCount, logger, nextRangeBaseGenCount } =\n\t\t\tthis;\n\t\tconst sessionIndexMap = new Map<Session, number>();\n\t\tlet sessionIndex = 0;\n\t\tfor (const session of sessions.sessions()) {\n\t\t\t// Filter empty sessions to prevent them accumulating in the serialized state\n\t\t\tif (!session.isEmpty() || hasLocalState) {\n\t\t\t\tsessionIndexMap.set(session, sessionIndex);\n\t\t\t\tsessionIndex++;\n\t\t\t}\n\t\t}\n\t\tconst sizeOfUuid = 2;\n\t\tconst shardingStateSize =\n\t\t\thasLocalState && this.writeVersion >= SerializationVersion.V3\n\t\t\t\t? this.shardingState === undefined\n\t\t\t\t\t? 1 // Boolean: no sharding state\n\t\t\t\t\t: 1 + // Boolean: has sharding state\n\t\t\t\t\t\t2 + // Numbers: currentStride, originalStride (Float64)\n\t\t\t\t\t\t1 + // Number: activeChildIds count (Float64)\n\t\t\t\t\t\tthis.shardingState.activeChildIds.size * sizeOfUuid + // UUIDs: each is 128-bit\n\t\t\t\t\t\t1 + // Boolean: hasShardId\n\t\t\t\t\t\t(this.shardingState.shardId === undefined ? 0 : sizeOfUuid) // UUID: 128-bit if present\n\t\t\t\t: 0;\n\t\tconst localStateSize = hasLocalState\n\t\t\t? 1 + // generated ID count\n\t\t\t\t1 + // next range base genCount\n\t\t\t\t1 + // count of normalizer pairs\n\t\t\t\tnormalizer.idRanges.size * 2 + // pairs\n\t\t\t\tshardingStateSize // sharding state if present\n\t\t\t: 0;\n\t\t// Layout size, in 8 byte increments\n\t\tconst totalSize =\n\t\t\t1 + // version\n\t\t\t1 + // hasLocalState\n\t\t\t1 + // session count\n\t\t\t1 + // cluster count\n\t\t\tsessionIndexMap.size * sizeOfUuid + // session IDs\n\t\t\tfinalSpace.clusters.length * 3 + // clusters: (sessionIndex, capacity, count)[]\n\t\t\tlocalStateSize; // local state, if present\n\n\t\tconst serializedFloat = new Float64Array(totalSize);\n\t\tconst serializedUint = new BigUint64Array(serializedFloat.buffer);\n\t\tlet index = 0;\n\t\tindex = writeNumber(serializedFloat, index, this.writeVersion);\n\t\tindex = writeBoolean(serializedFloat, index, hasLocalState);\n\t\tindex = writeNumber(serializedFloat, index, sessionIndexMap.size);\n\t\tindex = writeNumber(serializedFloat, index, finalSpace.clusters.length);\n\n\t\tfor (const [session] of sessionIndexMap.entries()) {\n\t\t\tindex = writeNumericUuid(serializedUint, index, session.sessionUuid);\n\t\t}\n\n\t\tfor (const cluster of finalSpace.clusters) {\n\t\t\tindex = writeNumber(\n\t\t\t\tserializedFloat,\n\t\t\t\tindex,\n\t\t\t\tsessionIndexMap.get(cluster.session) as number,\n\t\t\t);\n\t\t\tindex = writeNumber(serializedFloat, index, cluster.capacity);\n\t\t\tindex = writeNumber(serializedFloat, index, cluster.count);\n\t\t}\n\n\t\tif (hasLocalState) {\n\t\t\tindex = writeNumber(serializedFloat, index, localGenCount);\n\t\t\tindex = writeNumber(serializedFloat, index, nextRangeBaseGenCount);\n\t\t\tindex = writeNumber(serializedFloat, index, normalizer.idRanges.size);\n\t\t\tfor (const [leadingGenCount, count] of normalizer.idRanges.entries()) {\n\t\t\t\tindex = writeNumber(serializedFloat, index, leadingGenCount);\n\t\t\t\tindex = writeNumber(serializedFloat, index, count);\n\t\t\t}\n\n\t\t\t// Write sharding state (version 3+)\n\t\t\tif (this.writeVersion >= SerializationVersion.V3) {\n\t\t\t\tindex = writeBoolean(serializedFloat, index, this.shardingState !== undefined);\n\t\t\t\tif (this.shardingState !== undefined) {\n\t\t\t\t\tindex = writeNumber(serializedFloat, index, this.shardingState.currentStride);\n\t\t\t\t\tindex = writeNumber(serializedFloat, index, this.shardingState.originalStride);\n\n\t\t\t\t\t// Write activeChildIds Set as count + array of NumericUuids\n\t\t\t\t\tindex = writeNumber(serializedFloat, index, this.shardingState.activeChildIds.size);\n\t\t\t\t\tfor (const childId of this.shardingState.activeChildIds) {\n\t\t\t\t\t\tindex = writeNumericUuid(serializedUint, index, numericUuidFromStableId(childId));\n\t\t\t\t\t}\n\n\t\t\t\t\t// Write shardId (optional)\n\t\t\t\t\tindex = writeBoolean(\n\t\t\t\t\t\tserializedFloat,\n\t\t\t\t\t\tindex,\n\t\t\t\t\t\tthis.shardingState.shardId !== undefined,\n\t\t\t\t\t);\n\t\t\t\t\tif (this.shardingState.shardId !== undefined) {\n\t\t\t\t\t\tindex = writeNumericUuid(\n\t\t\t\t\t\t\tserializedUint,\n\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\tnumericUuidFromStableId(this.shardingState.shardId),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tassert(index === totalSize, 0x75b /* Serialized size was incorrectly calculated. */);\n\t\tlogger?.sendTelemetryEvent({\n\t\t\teventName: \"RuntimeIdCompressor:SerializedIdCompressorSize\",\n\t\t\tsize: serializedFloat.byteLength,\n\t\t\tclusterCount: finalSpace.clusters.length,\n\t\t\tsessionCount: sessionIndexMap.size,\n\t\t});\n\n\t\treturn bufferToString(serializedFloat.buffer, \"base64\") as SerializedIdCompressor;\n\t}\n\n\tpublic static deserialize(\n\t\tparams:\n\t\t\t| {\n\t\t\t\t\tserialized: SerializedIdCompressorWithOngoingSession;\n\t\t\t\t\trequestedWriteVersion: SerializationVersion;\n\t\t\t\t\tlogger?: TelemetryLoggerExt | undefined;\n\t\t\t\t\tnewSessionId?: never;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tserialized: SerializedIdCompressorWithNoSession;\n\t\t\t\t\tnewSessionId: SessionId;\n\t\t\t\t\trequestedWriteVersion: SerializationVersion;\n\t\t\t\t\tlogger?: TelemetryLoggerExt | undefined;\n\t\t\t },\n\t): IdCompressor {\n\t\tconst { serialized, newSessionId: sessionId, logger, requestedWriteVersion } = params;\n\t\tconst buffer = stringToBuffer(serialized, \"base64\");\n\t\tconst index: Index = {\n\t\t\tindex: 0,\n\t\t\tbufferFloat: new Float64Array(buffer),\n\t\t\tbufferUint: new BigUint64Array(buffer),\n\t\t};\n\t\tconst serializedVersion = readNumber(index) as SerializationVersion;\n\t\t// If requested version is < the serialized version, we must write the version serialized\n\t\t// to avoid losing data.\n\t\tconst writeVersion = Math.max(\n\t\t\trequestedWriteVersion,\n\t\t\tserializedVersion,\n\t\t) as SerializationVersion;\n\n\t\tswitch (serializedVersion) {\n\t\t\tcase 2:\n\t\t\tcase 3: {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tif (serializedVersion === 1) {\n\t\t\t\t\tthrow new Error(\"IdCompressor version 1.0 is no longer supported.\");\n\t\t\t\t}\n\t\t\t\tthrow new Error(\"Unknown IdCompressor serialized version.\");\n\t\t\t}\n\t\t}\n\n\t\tconst hasLocalState = readBoolean(index);\n\t\tconst sessionCount = readNumber(index);\n\t\tconst clusterCount = readNumber(index);\n\n\t\t// Sessions\n\t\tlet sessionOffset = 0;\n\t\tconst sessions: [NumericUuid, Session][] = [];\n\t\tif (hasLocalState) {\n\t\t\tassert(\n\t\t\t\tsessionId === undefined,\n\t\t\t\t0x75e /* Local state should not exist in serialized form. */,\n\t\t\t);\n\t\t} else {\n\t\t\t// If !hasLocalState, there won't be a serialized local session ID so insert one at the beginning\n\t\t\tassert(sessionId !== undefined, 0x75d /* Local session ID is undefined. */);\n\t\t\tconst localSessionNumeric = numericUuidFromStableId(sessionId);\n\t\t\tsessions.push([localSessionNumeric, new Session(localSessionNumeric)]);\n\t\t\tsessionOffset = 1;\n\t\t}\n\n\t\tfor (let i = 0; i < sessionCount; i++) {\n\t\t\tconst numeric = readNumericUuid(index);\n\t\t\tsessions.push([numeric, new Session(numeric)]);\n\t\t}\n\n\t\tconst compressor = new IdCompressor(new Sessions(sessions), logger, writeVersion);\n\n\t\t// Clusters\n\t\tlet baseFinalId = 0;\n\t\tfor (let i = 0; i < clusterCount; i++) {\n\t\t\tconst sessionIndex = readNumber(index);\n\t\t\tconst sessionArray = sessions[sessionIndex + sessionOffset];\n\t\t\tassert(\n\t\t\t\tsessionArray !== undefined,\n\t\t\t\t0x9d8 /* sessionArray is undefined in IdCompressor.deserialize2_0 */,\n\t\t\t);\n\t\t\tconst session = sessionArray[1];\n\t\t\tconst capacity = readNumber(index);\n\t\t\tconst count = readNumber(index);\n\t\t\tconst cluster = session.addNewCluster(baseFinalId as FinalCompressedId, capacity, count);\n\t\t\tcompressor.finalSpace.addCluster(cluster);\n\t\t\tbaseFinalId += capacity;\n\t\t}\n\n\t\t// Local state\n\t\tif (hasLocalState) {\n\t\t\tcompressor.localGenCount = readNumber(index);\n\t\t\tcompressor.nextRangeBaseGenCount = readNumber(index);\n\t\t\tconst normalizerCount = readNumber(index);\n\t\t\tfor (let i = 0; i < normalizerCount; i++) {\n\t\t\t\tcompressor.normalizer.addLocalRange(readNumber(index), readNumber(index));\n\t\t\t}\n\n\t\t\t// Sharding state (version 3+)\n\t\t\tif (serializedVersion >= 3) {\n\t\t\t\tconst hasShardingState = readBoolean(index);\n\t\t\t\tif (hasShardingState) {\n\t\t\t\t\tconst currentStride = readNumber(index);\n\t\t\t\t\tconst originalStride = readNumber(index);\n\n\t\t\t\t\t// Read activeChildIds Set\n\t\t\t\t\tconst activeChildCount = readNumber(index);\n\t\t\t\t\tconst activeChildIds = new Set<SessionId>();\n\t\t\t\t\tfor (let i = 0; i < activeChildCount; i++) {\n\t\t\t\t\t\tconst childIdNumeric = readNumericUuid(index);\n\t\t\t\t\t\t// Safe cast: these were serialized as SessionIds\n\t\t\t\t\t\tactiveChildIds.add(stableIdFromNumericUuid(childIdNumeric) as SessionId);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Read shardId (optional)\n\t\t\t\t\tconst hasShardId = readBoolean(index);\n\t\t\t\t\tconst shardId: SessionId | undefined = hasShardId\n\t\t\t\t\t\t? (stableIdFromNumericUuid(readNumericUuid(index)) as SessionId)\n\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\t// Build sharding state object, conditionally including shardId\n\t\t\t\t\tcompressor.shardingState = {\n\t\t\t\t\t\tcurrentStride,\n\t\t\t\t\t\toriginalStride,\n\t\t\t\t\t\tactiveChildIds,\n\t\t\t\t\t\t...(shardId !== undefined && { shardId }),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tassert(\n\t\t\tindex.index === index.bufferFloat.length,\n\t\t\t0x75f /* Failed to read entire serialized compressor. */,\n\t\t);\n\t\treturn compressor;\n\t}\n\n\tpublic equals(other: IdCompressor, includeLocalState: boolean): boolean {\n\t\tif (\n\t\t\tincludeLocalState &&\n\t\t\t(this.localSessionId !== other.localSessionId ||\n\t\t\t\t!this.localSession.equals(other.localSession) ||\n\t\t\t\t!this.normalizer.equals(other.normalizer) ||\n\t\t\t\tthis.nextRangeBaseGenCount !== other.nextRangeBaseGenCount ||\n\t\t\t\tthis.localGenCount !== other.localGenCount)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\t// Shard ownership affects future local ID allocation, even when the generated IDs match.\n\t\t// It is not part of finalized state, so ignore it when comparing only that state.\n\t\tif (includeLocalState) {\n\t\t\tconst state = this.shardingState;\n\t\t\tconst otherState = other.shardingState;\n\t\t\tif (state === undefined || otherState === undefined) {\n\t\t\t\t// Two unsharded compressors match here; a sharded and an unsharded compressor do not.\n\t\t\t\tif (state !== otherState) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tstate.currentStride !== otherState.currentStride ||\n\t\t\t\t\tstate.originalStride !== otherState.originalStride ||\n\t\t\t\t\tstate.shardId !== otherState.shardId ||\n\t\t\t\t\tstate.activeChildIds.size !== otherState.activeChildIds.size\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\t// Child ownership is an unordered set. Equal sizes and membership imply equal sets,\n\t\t\t\t// regardless of insertion order or whether the state was deserialized.\n\t\t\t\tfor (const childId of state.activeChildIds) {\n\t\t\t\t\tif (!otherState.activeChildIds.has(childId)) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn (\n\t\t\tthis.sessions.equals(other.sessions, includeLocalState) &&\n\t\t\tthis.finalSpace.equals(other.finalSpace)\n\t\t);\n\t}\n}\n\n/**\n * Create a new {@link IIdCompressor}.\n * @param writeVersion - The version the compressor will write when serializing. Use SerializationVersion.V2 for base format, or SerializationVersion.V3 for sharding support.\n * @param logger - Optional telemetry logger.\n * @internal\n */\nexport function createIdCompressor(\n\twriteVersion: SerializationVersion,\n\tlogger?: ITelemetryBaseLogger,\n): IIdCompressor & IIdCompressorCore;\n/**\n * Create a new {@link IIdCompressor}.\n * @param sessionId - The seed ID for the compressor.\n * @param writeVersion - The version the compressor will write when serializing. Use SerializationVersion.V2 for base format, or SerializationVersion.V3 for sharding support.\n * @param logger - Optional telemetry logger.\n * @internal\n */\nexport function createIdCompressor(\n\tsessionId: SessionId,\n\twriteVersion: SerializationVersion,\n\tlogger?: ITelemetryBaseLogger,\n): IIdCompressor & IIdCompressorCore;\nexport function createIdCompressor(\n\tsessionIdOrDocumentVersion: SessionId | SerializationVersion,\n\twriteVersionOrLogger?: SerializationVersion | ITelemetryBaseLogger,\n\tloggerOrUndefined?: ITelemetryBaseLogger,\n): IIdCompressor & IIdCompressorCore {\n\tlet localSessionId: SessionId;\n\tlet writeVersion: SerializationVersion;\n\tlet logger: ITelemetryBaseLogger | undefined;\n\n\tif (typeof sessionIdOrDocumentVersion === \"string\") {\n\t\t// Called with sessionId, writeVersion, logger?\n\t\tlocalSessionId = sessionIdOrDocumentVersion;\n\t\twriteVersion = writeVersionOrLogger as SerializationVersion;\n\t\tlogger = loggerOrUndefined;\n\t} else {\n\t\t// Called with writeVersion, logger?\n\t\tlocalSessionId = createSessionId();\n\t\twriteVersion = sessionIdOrDocumentVersion;\n\t\tlogger = writeVersionOrLogger as ITelemetryBaseLogger | undefined;\n\t}\n\n\tconst compressor = new IdCompressor(\n\t\tlocalSessionId,\n\t\tlogger === undefined ? undefined : createChildLogger({ logger }),\n\t\twriteVersion,\n\t);\n\treturn compressor;\n}\n\n/**\n * Deserializes the supplied state into an ID compressor.\n * @param serialized - The serialized compressor state with an ongoing session.\n * @param writeVersion - The version the compressor will write when serializing. This determines what features are available (e.g., V3 enables sharding support).\n * @param logger - Optional telemetry logger.\n * @internal\n */\nexport function deserializeIdCompressor(\n\tserialized: SerializedIdCompressorWithOngoingSession,\n\twriteVersion: SerializationVersion,\n\tlogger?: ITelemetryLoggerExt,\n): IIdCompressor & IIdCompressorCore;\n/**\n * Deserializes the supplied state into an ID compressor.\n * @param serialized - The serialized compressor state without a session.\n * @param newSessionId - The session ID to use for the deserialized compressor.\n * @param writeVersion - The version the compressor will write when serializing. This determines what features are available (e.g., V3 enables sharding support).\n * @param logger - Optional telemetry logger.\n * @internal\n */\nexport function deserializeIdCompressor(\n\tserialized: SerializedIdCompressorWithNoSession,\n\tnewSessionId: SessionId,\n\twriteVersion: SerializationVersion,\n\tlogger?: ITelemetryLoggerExt,\n): IIdCompressor & IIdCompressorCore;\nexport function deserializeIdCompressor(\n\tserialized: SerializedIdCompressor | SerializedIdCompressorWithNoSession,\n\tsessionIdOrDocumentVersion: SessionId | SerializationVersion,\n\twriteVersionOrLogger?: SerializationVersion | ITelemetryLoggerExt,\n\tloggerOrUndefined?: ITelemetryLoggerExt,\n): IIdCompressor & IIdCompressorCore {\n\tif (typeof sessionIdOrDocumentVersion === \"string\") {\n\t\t// Called with (serialized, sessionId, writeVersion, logger?)\n\t\treturn IdCompressor.deserialize({\n\t\t\tserialized: serialized as SerializedIdCompressorWithNoSession,\n\t\t\tlogger: extractTelemetryLoggerExt<{ PossiblyUndefined: true }>(loggerOrUndefined),\n\t\t\tnewSessionId: sessionIdOrDocumentVersion,\n\t\t\trequestedWriteVersion: writeVersionOrLogger as SerializationVersion,\n\t\t});\n\t}\n\n\tassert(\n\t\tloggerOrUndefined === undefined,\n\t\t0xc2d /* logger would be in sessionIdOrLogger in this codepath */,\n\t);\n\t// Called with (serialized, writeVersion, logger?)\n\treturn IdCompressor.deserialize({\n\t\tserialized: serialized as SerializedIdCompressorWithOngoingSession,\n\t\tlogger: extractTelemetryLoggerExt<{ PossiblyUndefined: true }>(\n\t\t\twriteVersionOrLogger as ITelemetryLoggerExt | undefined,\n\t\t),\n\t\trequestedWriteVersion: sessionIdOrDocumentVersion,\n\t});\n}\n\n/**\n * Throws an error indicating the compressor has been disposed.\n */\nconst throwDisposed = (): never => {\n\tthrow new Error(\n\t\t\"This compressor has been disposed via disposeShard() and can no longer be used.\",\n\t);\n};\n\n/**\n * Makes an IdCompressor instance unusable by replacing all its methods with functions that throw.\n * This is called once when disposeShard() is invoked to make the compressor permanently unusable.\n * @param compressor - The compressor instance to make unusable\n */\nfunction makeCompressorUnusable(compressor: IdCompressor): void {\n\t// Get all method names from the prototype (where class methods live)\n\tconst proto = Object.getPrototypeOf(compressor) as object;\n\tfor (const key of Reflect.ownKeys(proto)) {\n\t\tif (key !== \"constructor\" && typeof Reflect.get(proto, key) === \"function\") {\n\t\t\t// Shadow the method only on this instance so other compressors remain usable.\n\t\t\t// Omitting `enumerable` keeps new overrides non-enumerable, like class methods.\n\t\t\t// Reflection supports string and symbol keys without adding an index signature.\n\t\t\tObject.defineProperty(compressor, key, {\n\t\t\t\tvalue: throwDisposed,\n\t\t\t\tconfigurable: true,\n\t\t\t\twritable: true,\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Serializes an ID compressor.\n * @param compressor - The compressor to serialize.\n * @param withSession - If true, the serialized state will include local session\n * state (for stashing). If false, only finalized state is included (for summaries).\n * @internal\n */\nexport function serializeIdCompressor(\n\tcompressor: IIdCompressor,\n\twithSession: true,\n): SerializedIdCompressorWithOngoingSession;\n/**\n * Serializes an ID compressor.\n * @param compressor - The compressor to serialize.\n * @param withSession - If true, the serialized state will include local session\n * state (for stashing). If false, only finalized state is included (for summaries).\n * @internal\n */\nexport function serializeIdCompressor(\n\tcompressor: IIdCompressor,\n\twithSession: false,\n): SerializedIdCompressorWithNoSession;\nexport function serializeIdCompressor(\n\tcompressor: IIdCompressor,\n\twithSession: boolean,\n): SerializedIdCompressorWithOngoingSession | SerializedIdCompressorWithNoSession {\n\tconst core = toIdCompressorWithCore(compressor);\n\treturn withSession ? core.serialize(true) : core.serialize(false);\n}\n\n/**\n * Casts an {@link IIdCompressor} to include {@link IIdCompressorCore}.\n *\n * @remarks\n * Compressors returned by `createIdCompressor` and `deserializeIdCompressor`\n * always implement both {@link IIdCompressor} and {@link IIdCompressorCore}, but their\n * public return type is narrowed to {@link IIdCompressor}. Internal consumers that\n * need access to core compressor operations (serialization, range management, etc.)\n * use this function to recover the {@link IIdCompressorCore} surface.\n *\n * @param compressor - A compressor created by `createIdCompressor` or\n * `deserializeIdCompressor`.\n * @returns The same compressor, typed to include {@link IIdCompressorCore}.\n * @internal\n */\nexport function toIdCompressorWithCore(\n\tcompressor: IIdCompressor,\n): IIdCompressor & IIdCompressorCore {\n\tassert(\n\t\t\"serialize\" in compressor,\n\t\t0xced /* Expected compressor to implement IIdCompressorCore */,\n\t);\n\treturn compressor as IIdCompressor & IIdCompressorCore;\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -6,7 +6,8 @@
6
6
  * Exports for `id-compressor`
7
7
  */
8
8
  export { createIdCompressor, deserializeIdCompressor, serializeIdCompressor, toIdCompressorWithCore, } from "./idCompressor.js";
9
+ export { SerializationVersion } from "./types/index.js";
9
10
  export { type FinalCompressedId, isFinalId } from "./identifiers.js";
10
11
  export { createSessionId, assertIsStableId, generateStableId, isStableId, } from "./utilities.js";
11
- export type { IIdCompressorCore, IIdCompressor, SerializedIdCompressor, SerializedIdCompressorWithOngoingSession, SerializedIdCompressorWithNoSession, SessionSpaceCompressedId, OpSpaceCompressedId, SessionId, StableId, IdCreationRange, } from "./types/index.js";
12
+ export type { IdCreationRange, IIdCompressor, IIdCompressorCore, IdCompressorEvents, OpSpaceCompressedId, ParentShardSynchronizationToken, SerializedIdCompressor, SerializedIdCompressorWithNoSession, SerializedIdCompressorWithOngoingSession, SerializedIdCompressorShard, SessionId, SessionSpaceCompressedId, ShardSynchronizationToken, ShardToken, StableId, } from "./types/index.js";
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AAEH,OAAO,EACN,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,iBAAiB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACN,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,GACV,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACX,iBAAiB,EACjB,aAAa,EACb,sBAAsB,EACtB,wCAAwC,EACxC,mCAAmC,EACnC,wBAAwB,EACxB,mBAAmB,EACnB,SAAS,EACT,QAAQ,EACR,eAAe,GACf,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AAEH,OAAO,EACN,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,KAAK,iBAAiB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACN,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,GACV,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACX,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,+BAA+B,EAC/B,sBAAsB,EACtB,mCAAmC,EACnC,wCAAwC,EACxC,2BAA2B,EAC3B,SAAS,EACT,wBAAwB,EACxB,yBAAyB,EACzB,UAAU,EACV,QAAQ,GACR,MAAM,kBAAkB,CAAC"}
package/lib/index.js CHANGED
@@ -6,6 +6,7 @@
6
6
  * Exports for `id-compressor`
7
7
  */
8
8
  export { createIdCompressor, deserializeIdCompressor, serializeIdCompressor, toIdCompressorWithCore, } from "./idCompressor.js";
9
+ export { SerializationVersion } from "./types/index.js";
9
10
  export { isFinalId } from "./identifiers.js";
10
11
  export { createSessionId, assertIsStableId, generateStableId, isStableId, } from "./utilities.js";
11
12
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AAEH,OAAO,EACN,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA0B,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACN,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,GACV,MAAM,gBAAgB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Exports for `id-compressor`\n */\n\nexport {\n\tcreateIdCompressor,\n\tdeserializeIdCompressor,\n\tserializeIdCompressor,\n\ttoIdCompressorWithCore,\n} from \"./idCompressor.js\";\nexport { type FinalCompressedId, isFinalId } from \"./identifiers.js\";\nexport {\n\tcreateSessionId,\n\tassertIsStableId,\n\tgenerateStableId,\n\tisStableId,\n} from \"./utilities.js\";\nexport type {\n\tIIdCompressorCore,\n\tIIdCompressor,\n\tSerializedIdCompressor,\n\tSerializedIdCompressorWithOngoingSession,\n\tSerializedIdCompressorWithNoSession,\n\tSessionSpaceCompressedId,\n\tOpSpaceCompressedId,\n\tSessionId,\n\tStableId,\n\tIdCreationRange,\n} from \"./types/index.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AAEH,OAAO,EACN,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAA0B,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACN,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,GACV,MAAM,gBAAgB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Exports for `id-compressor`\n */\n\nexport {\n\tcreateIdCompressor,\n\tdeserializeIdCompressor,\n\tserializeIdCompressor,\n\ttoIdCompressorWithCore,\n} from \"./idCompressor.js\";\nexport { SerializationVersion } from \"./types/index.js\";\nexport { type FinalCompressedId, isFinalId } from \"./identifiers.js\";\nexport {\n\tcreateSessionId,\n\tassertIsStableId,\n\tgenerateStableId,\n\tisStableId,\n} from \"./utilities.js\";\nexport type {\n\tIdCreationRange,\n\tIIdCompressor,\n\tIIdCompressorCore,\n\tIdCompressorEvents,\n\tOpSpaceCompressedId,\n\tParentShardSynchronizationToken,\n\tSerializedIdCompressor,\n\tSerializedIdCompressorWithNoSession,\n\tSerializedIdCompressorWithOngoingSession,\n\tSerializedIdCompressorShard,\n\tSessionId,\n\tSessionSpaceCompressedId,\n\tShardSynchronizationToken,\n\tShardToken,\n\tStableId,\n} from \"./types/index.js\";\n"]}
package/lib/legacy.d.ts CHANGED
@@ -14,17 +14,6 @@ export {
14
14
  OpSpaceCompressedId,
15
15
  SessionId,
16
16
  SessionSpaceCompressedId,
17
- StableId,
18
- // #endregion
19
-
20
- // #region @legacyBeta APIs
21
- IdCreationRange,
22
- SerializedIdCompressor,
23
- SerializedIdCompressorWithNoSession,
24
- SerializedIdCompressorWithOngoingSession,
25
- createIdCompressor,
26
- createSessionId,
27
- deserializeIdCompressor,
28
- serializeIdCompressor
17
+ StableId
29
18
  // #endregion
30
19
  } from "./index.js";
@@ -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/id-compressor";
8
- export declare const pkgVersion = "3.2.0";
8
+ export declare const pkgVersion = "3.4.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -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/id-compressor";
8
- export const pkgVersion = "3.2.0";
8
+ export const pkgVersion = "3.4.0";
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,+BAA+B,CAAC;AACvD,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,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/id-compressor\";\nexport const pkgVersion = \"3.2.0\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,+BAA+B,CAAC;AACvD,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,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/id-compressor\";\nexport const pkgVersion = \"3.4.0\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"idCompressor.perf.spec.js","sourceRoot":"","sources":["../../src/test/idCompressor.perf.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EACN,iBAAiB,EACjB,0BAA0B,EAC1B,WAAW,GACX,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAQlD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EACN,MAAM,EACN,iBAAiB,EACjB,uBAAuB,EACvB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,UAAU,GACV,MAAM,gCAAgC,CAA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,YAAY,EAAE,uBAAuB;yBACrC,CAAC,CAAC;oBACJ,CAAC,CAAC,CAAC;gBACJ,CAAC;aACD,CAAC;SACF,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { take } from \"@fluid-private/stochastic-test-utils\";\nimport {\n\tbenchmarkDuration,\n\tbenchmarkDurationBatchless,\n\tbenchmarkIt,\n} from \"@fluid-tools/benchmark\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { IdCompressor } from \"../idCompressor.js\";\nimport type {\n\tIdCreationRange,\n\tOpSpaceCompressedId,\n\tSerializedIdCompressorWithNoSession,\n\tSessionId,\n\tSessionSpaceCompressedId,\n} from \"../index.js\";\nimport { createSessionId } from \"../utilities.js\";\n\nimport {\n\tClient,\n\tDestinationClient,\n\tIdCompressorTestNetwork,\n\tbuildHugeCompressor,\n\tmakeOpGenerator,\n\tperformFuzzActions,\n\tsessionIds,\n} from \"./idCompressorTestUtilities.js\";\nimport {\n\ttype FinalCompressedId,\n\ttype LocalCompressedId,\n\tfail,\n\tisFinalId,\n\tisLocalId,\n} from \"./testCommon.js\";\n\nconst initialClusterCapacity = 512;\n\ndescribe(\"IdCompressor Perf\", () => {\n\tconst localClient = Client.Client1;\n\tconst remoteClient = Client.Client2;\n\n\tfunction setupCompressors(\n\t\tclusterSize: number,\n\t\tlocalClientCanEdit: boolean,\n\t\tsynchronizeAtEnd: boolean,\n\t): { network: IdCompressorTestNetwork; perfCompressor: IdCompressor } {\n\t\tconst perfNetwork = new IdCompressorTestNetwork(clusterSize);\n\t\tconst maxClusterSize = clusterSize * 2;\n\t\tconst generator = take(\n\t\t\t1000,\n\t\t\tmakeOpGenerator({\n\t\t\t\tvalidateInterval: 2000,\n\t\t\t\tmaxClusterSize,\n\t\t\t\toutsideAllocationFraction: 0.9,\n\t\t\t}),\n\t\t);\n\t\tperformFuzzActions(\n\t\t\tgenerator,\n\t\t\tperfNetwork,\n\t\t\tMath.E,\n\t\t\tlocalClientCanEdit ? undefined : localClient,\n\t\t\tsynchronizeAtEnd,\n\t\t);\n\t\tconst perfCompressor = perfNetwork.getCompressorUnsafeNoProxy(localClient);\n\t\treturn { network: perfNetwork, perfCompressor };\n\t}\n\n\tfunction getIdMadeBy(\n\t\tclient: Client,\n\t\teagerFinal: false,\n\t\tnetwork: IdCompressorTestNetwork,\n\t): LocalCompressedId;\n\tfunction getIdMadeBy(\n\t\tclient: Client,\n\t\teagerFinal: true,\n\t\tnetwork: IdCompressorTestNetwork,\n\t): FinalCompressedId & SessionSpaceCompressedId;\n\tfunction getIdMadeBy(\n\t\tclient: Client,\n\t\teagerFinal: boolean,\n\t\tnetwork: IdCompressorTestNetwork,\n\t): SessionSpaceCompressedId;\n\tfunction getIdMadeBy(\n\t\tclient: Client,\n\t\teagerFinal: boolean,\n\t\tnetwork: IdCompressorTestNetwork,\n\t): SessionSpaceCompressedId {\n\t\tconst log = network.getIdLog(client);\n\t\tfor (let i = log.length - 1; i > 0; i--) {\n\t\t\tconst { id, originatingClient } = log[i];\n\t\t\tif (\n\t\t\t\toriginatingClient === client &&\n\t\t\t\t((eagerFinal && isFinalId(id)) || (!eagerFinal && isLocalId(id)))\n\t\t\t) {\n\t\t\t\tassert(eagerFinal === isFinalId(id), \"Not local/final as requested.\");\n\t\t\t\treturn id;\n\t\t\t}\n\t\t}\n\t\tfail(\"no ID found in log\");\n\t}\n\n\tfunction benchmarkWithFlag(creator: (flag: boolean) => void): void {\n\t\tfor (const flag of [true, false]) {\n\t\t\tcreator(flag);\n\t\t}\n\t}\n\n\tbenchmarkIt({\n\t\ttitle: `allocate local ID`,\n\t\t...benchmarkDuration({\n\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\tconst { perfCompressor } = setupCompressors(initialClusterCapacity, true, true);\n\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\tperfCompressor.generateCompressedId();\n\t\t\t\t});\n\t\t\t},\n\t\t}),\n\t});\n\n\tbenchmarkIt({\n\t\ttitle: \"take an ID creation range\",\n\t\t...benchmarkDuration({\n\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\tconst { perfCompressor } = setupCompressors(initialClusterCapacity, true, true);\n\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\tperfCompressor.generateCompressedId();\n\t\t\t\t\tperfCompressor.takeNextCreationRange();\n\t\t\t\t});\n\t\t\t},\n\t\t}),\n\t});\n\n\tfor (const clusterSize of [1, 10, 500, 1000]) {\n\t\tconst numIds = 7;\n\t\tconst session1 = \"8150a099-5302-4672-b5f3-7a4492b59418\" as SessionId;\n\t\tconst session2 = \"f2ded886-92da-4248-967b-eb96ee04cf51\" as SessionId;\n\t\tbenchmarkIt({\n\t\t\ttitle: `finalize a range of IDs (cluster size = ${clusterSize})`,\n\t\t\t...benchmarkDurationBatchless({\n\t\t\t\tbenchmarkFn: (state) => {\n\t\t\t\t\tconst { perfCompressor } = setupCompressors(clusterSize, false, true);\n\t\t\t\t\tlet session: SessionId = session1;\n\t\t\t\t\tlet nextFirstFinalizedGenCount1 = 1;\n\t\t\t\t\tlet nextFirstFinalizedGenCount2 = 1;\n\t\t\t\t\tlet running: boolean;\n\t\t\t\t\tdo {\n\t\t\t\t\t\t// Create a range with as minimal overhead as possible\n\t\t\t\t\t\tconst isFirstClient = session === session1;\n\t\t\t\t\t\tconst firstGenCount = isFirstClient\n\t\t\t\t\t\t\t? nextFirstFinalizedGenCount1\n\t\t\t\t\t\t\t: nextFirstFinalizedGenCount2;\n\t\t\t\t\t\tconst range: IdCreationRange = {\n\t\t\t\t\t\t\tsessionId: session,\n\t\t\t\t\t\t\tids: {\n\t\t\t\t\t\t\t\tfirstGenCount,\n\t\t\t\t\t\t\t\tcount: numIds,\n\t\t\t\t\t\t\t\trequestedClusterSize: initialClusterCapacity,\n\t\t\t\t\t\t\t\tlocalIdRanges: [], // no need to populate, as session is remote and compressor would ignore in production\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\trunning = state.time(() => {\n\t\t\t\t\t\t\tperfCompressor.finalizeCreationRange(range);\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst lastGenCount = firstGenCount + numIds;\n\t\t\t\t\t\tif (isFirstClient) {\n\t\t\t\t\t\t\tnextFirstFinalizedGenCount1 = lastGenCount;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnextFirstFinalizedGenCount2 = lastGenCount;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Alternate clients to sidestep optimization that packs them all into last cluster\n\t\t\t\t\t\tsession = isFirstClient ? session1 : session2;\n\t\t\t\t\t} while (running);\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t}\n\n\tbenchmarkWithFlag((isLocal) => {\n\t\tconst remoteSessionId = sessionIds.get(remoteClient);\n\t\tbenchmarkIt({\n\t\t\ttitle: `normalize a ${\n\t\t\t\tisLocal ? \"local\" : \"final\"\n\t\t\t} ID from a remote session to session space`,\n\t\t\t...benchmarkDuration({\n\t\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\t\tconst { network, perfCompressor } = setupCompressors(\n\t\t\t\t\t\tinitialClusterCapacity,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t);\n\t\t\t\t\tconst remoteSession = getIdMadeBy(remoteClient, false, network);\n\t\t\t\t\tconst opSpaceId = (\n\t\t\t\t\t\tisLocal\n\t\t\t\t\t\t\t? remoteSession\n\t\t\t\t\t\t\t: network.getCompressor(remoteClient).normalizeToOpSpace(remoteSession)\n\t\t\t\t\t) as OpSpaceCompressedId;\n\t\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\t\tperfCompressor.normalizeToSessionSpace(opSpaceId, remoteSessionId);\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t});\n\n\tbenchmarkWithFlag((eagerFinal) => {\n\t\tbenchmarkIt({\n\t\t\ttitle: `normalize a final ID corresponding to a ${\n\t\t\t\teagerFinal ? \"eager final\" : \"local\"\n\t\t\t} ID from op space to the local session`,\n\t\t\t...benchmarkDuration({\n\t\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\t\tconst { network, perfCompressor } = setupCompressors(\n\t\t\t\t\t\tinitialClusterCapacity,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t);\n\t\t\t\t\tconst opId = perfCompressor.normalizeToOpSpace(\n\t\t\t\t\t\tgetIdMadeBy(localClient, eagerFinal, network),\n\t\t\t\t\t);\n\t\t\t\t\tassert(isFinalId(opId), \"Must be final\");\n\t\t\t\t\tconst id = opId as OpSpaceCompressedId & FinalCompressedId;\n\t\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\t\tperfCompressor.normalizeToSessionSpace(id, perfCompressor.localSessionId);\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t});\n\n\tbenchmarkWithFlag((isLocalOriginator) => {\n\t\tconst remoteSessionId = sessionIds.get(remoteClient);\n\t\tbenchmarkIt({\n\t\t\ttitle: `normalize a final ID from a ${\n\t\t\t\tisLocalOriginator ? \"local\" : \"remote\"\n\t\t\t} session to a small session space (common case)`,\n\t\t\t...benchmarkDuration({\n\t\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\t\tconst { network, perfCompressor } = setupCompressors(\n\t\t\t\t\t\tinitialClusterCapacity,\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t);\n\t\t\t\t\t// Ensure the local session has several different clusters\n\t\t\t\t\tfor (let clusterCount = 0; clusterCount < 5; clusterCount++) {\n\t\t\t\t\t\tnetwork.allocateAndSendIds(\n\t\t\t\t\t\t\tlocalClient,\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\t\t\t\t\t\t\tperfCompressor[\"nextRequestedClusterSize\"],\n\t\t\t\t\t\t);\n\t\t\t\t\t\tnetwork.allocateAndSendIds(\n\t\t\t\t\t\t\tremoteClient,\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\t\t\t\t\t\t\tperfCompressor[\"nextRequestedClusterSize\"] * 2,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tnetwork.deliverOperations(DestinationClient.All);\n\t\t\t\t\t}\n\t\t\t\t\tconst client = isLocalOriginator ? localClient : remoteClient;\n\t\t\t\t\tconst idFromSession = getIdMadeBy(client, true, network);\n\t\t\t\t\tconst opSpaceId = network.getCompressor(client).normalizeToOpSpace(idFromSession);\n\t\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\t\tperfCompressor.normalizeToSessionSpace(opSpaceId, remoteSessionId);\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t});\n\n\tbenchmarkIt({\n\t\ttitle: `normalize an unacked local ID from the local session to op space`,\n\t\t...benchmarkDuration({\n\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\tconst { network, perfCompressor } = setupCompressors(\n\t\t\t\t\tinitialClusterCapacity,\n\t\t\t\t\ttrue,\n\t\t\t\t\tfalse,\n\t\t\t\t);\n\t\t\t\t// Ensure no eager finals\n\t\t\t\tnetwork.allocateAndSendIds(\n\t\t\t\t\tlocalClient,\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\t\t\t\t\tnetwork.getCompressor(localClient)[\"nextRequestedClusterSize\"] * 2 + 1,\n\t\t\t\t);\n\t\t\t\tconst unackedLocalId = getIdMadeBy(localClient, false, network);\n\t\t\t\tassert(\n\t\t\t\t\tperfCompressor.normalizeToOpSpace(unackedLocalId) === (unackedLocalId as number),\n\t\t\t\t\t\"Local was acked.\",\n\t\t\t\t);\n\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\tperfCompressor.normalizeToOpSpace(unackedLocalId);\n\t\t\t\t});\n\t\t\t},\n\t\t}),\n\t});\n\n\tbenchmarkWithFlag((eagerFinal) => {\n\t\tbenchmarkIt({\n\t\t\ttitle: `normalize an acked ${\n\t\t\t\teagerFinal ? \"eager final\" : \"local\"\n\t\t\t} ID from the local session to op space`,\n\t\t\t...benchmarkDuration({\n\t\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\t\tconst { network, perfCompressor } = setupCompressors(\n\t\t\t\t\t\tinitialClusterCapacity,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t);\n\t\t\t\t\tconst id = getIdMadeBy(localClient, eagerFinal, network);\n\t\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\t\tperfCompressor.normalizeToOpSpace(id);\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t});\n\n\tbenchmarkWithFlag((local) => {\n\t\tbenchmarkIt({\n\t\t\ttitle: `decompress a final ID from a ${\n\t\t\t\tlocal ? \"local\" : \"remote\"\n\t\t\t} client into a stable ID`,\n\t\t\t...benchmarkDuration({\n\t\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\t\tconst { network, perfCompressor } = setupCompressors(\n\t\t\t\t\t\tinitialClusterCapacity,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t);\n\t\t\t\t\tconst finalIdToDecompress = getIdMadeBy(\n\t\t\t\t\t\tlocal ? localClient : remoteClient,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tnetwork,\n\t\t\t\t\t);\n\t\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\t\tperfCompressor.decompress(finalIdToDecompress);\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t});\n\n\tbenchmarkIt({\n\t\ttitle: `decompress a local ID into a stable ID`,\n\t\t...benchmarkDuration({\n\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\tconst { network, perfCompressor } = setupCompressors(\n\t\t\t\t\tinitialClusterCapacity,\n\t\t\t\t\ttrue,\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t\tconst localIdToDecompress = getIdMadeBy(localClient, false, network);\n\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\tperfCompressor.decompress(localIdToDecompress);\n\t\t\t\t});\n\t\t\t},\n\t\t}),\n\t});\n\n\tbenchmarkWithFlag((eagerFinal) => {\n\t\tbenchmarkIt({\n\t\t\ttitle: `recompress a stable ID to a ${eagerFinal ? \"local\" : \"final\"} ID`,\n\t\t\t...benchmarkDuration({\n\t\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\t\tconst { network, perfCompressor } = setupCompressors(\n\t\t\t\t\t\tinitialClusterCapacity,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t);\n\t\t\t\t\tconst stableToCompress = perfCompressor.decompress(\n\t\t\t\t\t\tgetIdMadeBy(localClient, eagerFinal, network),\n\t\t\t\t\t);\n\t\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\t\tperfCompressor.recompress(stableToCompress);\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t});\n\n\tbenchmarkWithFlag((manySessions) => {\n\t\tbenchmarkIt({\n\t\t\ttitle: `serialize an IdCompressor (${manySessions ? \"many sessions\" : \"many clusters\"})`,\n\t\t\t...benchmarkDuration({\n\t\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\t\tconst perfCompressor = manySessions\n\t\t\t\t\t\t? buildHugeCompressor(undefined, initialClusterCapacity)\n\t\t\t\t\t\t: setupCompressors(initialClusterCapacity, false, true).perfCompressor;\n\t\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\t\tperfCompressor.serialize(false);\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t});\n\n\tbenchmarkWithFlag((manySessions) => {\n\t\tconst overrideRemoteSessionId = createSessionId();\n\t\tbenchmarkIt({\n\t\t\ttitle: `deserialize an IdCompressor (${\n\t\t\t\tmanySessions ? \"many sessions\" : \"many clusters\"\n\t\t\t})`,\n\t\t\t...benchmarkDuration({\n\t\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\t\tconst perfCompressor = manySessions\n\t\t\t\t\t\t? buildHugeCompressor(undefined, initialClusterCapacity)\n\t\t\t\t\t\t: setupCompressors(initialClusterCapacity, false, true).perfCompressor;\n\t\t\t\t\tconst serialized: SerializedIdCompressorWithNoSession =\n\t\t\t\t\t\tperfCompressor.serialize(false);\n\t\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\t\tIdCompressor.deserialize({\n\t\t\t\t\t\t\tserialized,\n\t\t\t\t\t\t\tnewSessionId: overrideRemoteSessionId,\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t});\n});\n"]}
1
+ {"version":3,"file":"idCompressor.perf.spec.js","sourceRoot":"","sources":["../../src/test/idCompressor.perf.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EACN,iBAAiB,EACjB,0BAA0B,EAC1B,WAAW,GACX,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAQlD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EACN,MAAM,EACN,iBAAiB,EACjB,uBAAuB,EACvB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,UAAU,GACV,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAGN,IAAI,EACJ,SAAS,EACT,SAAS,GACT,MAAM,iBAAiB,CAAC;AAEzB,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAEnC,QAA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D,CAAC;SACF,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { take } from \"@fluid-private/stochastic-test-utils\";\nimport {\n\tbenchmarkDuration,\n\tbenchmarkDurationBatchless,\n\tbenchmarkIt,\n} from \"@fluid-tools/benchmark\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { IdCompressor } from \"../idCompressor.js\";\nimport type {\n\tIdCreationRange,\n\tOpSpaceCompressedId,\n\tSerializedIdCompressorWithNoSession,\n\tSessionId,\n\tSessionSpaceCompressedId,\n} from \"../index.js\";\nimport { SerializationVersion } from \"../types/index.js\";\nimport { createSessionId } from \"../utilities.js\";\n\nimport {\n\tClient,\n\tDestinationClient,\n\tIdCompressorTestNetwork,\n\tbuildHugeCompressor,\n\tmakeOpGenerator,\n\tperformFuzzActions,\n\tsessionIds,\n} from \"./idCompressorTestUtilities.js\";\nimport {\n\ttype FinalCompressedId,\n\ttype LocalCompressedId,\n\tfail,\n\tisFinalId,\n\tisLocalId,\n} from \"./testCommon.js\";\n\nconst initialClusterCapacity = 512;\n\ndescribe(\"IdCompressor Perf\", () => {\n\tconst localClient = Client.Client1;\n\tconst remoteClient = Client.Client2;\n\n\tfunction setupCompressors(\n\t\tclusterSize: number,\n\t\tlocalClientCanEdit: boolean,\n\t\tsynchronizeAtEnd: boolean,\n\t): { network: IdCompressorTestNetwork; perfCompressor: IdCompressor } {\n\t\tconst perfNetwork = new IdCompressorTestNetwork(clusterSize);\n\t\tconst maxClusterSize = clusterSize * 2;\n\t\tconst generator = take(\n\t\t\t1000,\n\t\t\tmakeOpGenerator({\n\t\t\t\tvalidateInterval: 2000,\n\t\t\t\tmaxClusterSize,\n\t\t\t\toutsideAllocationFraction: 0.9,\n\t\t\t}),\n\t\t);\n\t\tperformFuzzActions(\n\t\t\tgenerator,\n\t\t\tperfNetwork,\n\t\t\tMath.E,\n\t\t\tlocalClientCanEdit ? undefined : localClient,\n\t\t\tsynchronizeAtEnd,\n\t\t);\n\t\tconst perfCompressor = perfNetwork.getCompressorUnsafeNoProxy(localClient);\n\t\treturn { network: perfNetwork, perfCompressor };\n\t}\n\n\tfunction getIdMadeBy(\n\t\tclient: Client,\n\t\teagerFinal: false,\n\t\tnetwork: IdCompressorTestNetwork,\n\t): LocalCompressedId;\n\tfunction getIdMadeBy(\n\t\tclient: Client,\n\t\teagerFinal: true,\n\t\tnetwork: IdCompressorTestNetwork,\n\t): FinalCompressedId & SessionSpaceCompressedId;\n\tfunction getIdMadeBy(\n\t\tclient: Client,\n\t\teagerFinal: boolean,\n\t\tnetwork: IdCompressorTestNetwork,\n\t): SessionSpaceCompressedId;\n\tfunction getIdMadeBy(\n\t\tclient: Client,\n\t\teagerFinal: boolean,\n\t\tnetwork: IdCompressorTestNetwork,\n\t): SessionSpaceCompressedId {\n\t\tconst log = network.getIdLog(client);\n\t\tfor (let i = log.length - 1; i > 0; i--) {\n\t\t\tconst { id, originatingClient } = log[i];\n\t\t\tif (\n\t\t\t\toriginatingClient === client &&\n\t\t\t\t((eagerFinal && isFinalId(id)) || (!eagerFinal && isLocalId(id)))\n\t\t\t) {\n\t\t\t\tassert(eagerFinal === isFinalId(id), \"Not local/final as requested.\");\n\t\t\t\treturn id;\n\t\t\t}\n\t\t}\n\t\tfail(\"no ID found in log\");\n\t}\n\n\tfunction benchmarkWithFlag(creator: (flag: boolean) => void): void {\n\t\tfor (const flag of [true, false]) {\n\t\t\tcreator(flag);\n\t\t}\n\t}\n\n\tbenchmarkIt({\n\t\ttitle: `allocate local ID`,\n\t\t...benchmarkDuration({\n\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\tconst { perfCompressor } = setupCompressors(initialClusterCapacity, true, true);\n\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\tperfCompressor.generateCompressedId();\n\t\t\t\t});\n\t\t\t},\n\t\t}),\n\t});\n\n\tbenchmarkIt({\n\t\ttitle: \"take an ID creation range\",\n\t\t...benchmarkDuration({\n\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\tconst { perfCompressor } = setupCompressors(initialClusterCapacity, true, true);\n\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\tperfCompressor.generateCompressedId();\n\t\t\t\t\tperfCompressor.takeNextCreationRange();\n\t\t\t\t});\n\t\t\t},\n\t\t}),\n\t});\n\n\tfor (const clusterSize of [1, 10, 500, 1000]) {\n\t\tconst numIds = 7;\n\t\tconst session1 = \"8150a099-5302-4672-b5f3-7a4492b59418\" as SessionId;\n\t\tconst session2 = \"f2ded886-92da-4248-967b-eb96ee04cf51\" as SessionId;\n\t\tbenchmarkIt({\n\t\t\ttitle: `finalize a range of IDs (cluster size = ${clusterSize})`,\n\t\t\t...benchmarkDurationBatchless({\n\t\t\t\tbenchmarkFn: (state) => {\n\t\t\t\t\tconst { perfCompressor } = setupCompressors(clusterSize, false, true);\n\t\t\t\t\tlet session: SessionId = session1;\n\t\t\t\t\tlet nextFirstFinalizedGenCount1 = 1;\n\t\t\t\t\tlet nextFirstFinalizedGenCount2 = 1;\n\t\t\t\t\tlet running: boolean;\n\t\t\t\t\tdo {\n\t\t\t\t\t\t// Create a range with as minimal overhead as possible\n\t\t\t\t\t\tconst isFirstClient = session === session1;\n\t\t\t\t\t\tconst firstGenCount = isFirstClient\n\t\t\t\t\t\t\t? nextFirstFinalizedGenCount1\n\t\t\t\t\t\t\t: nextFirstFinalizedGenCount2;\n\t\t\t\t\t\tconst range: IdCreationRange = {\n\t\t\t\t\t\t\tsessionId: session,\n\t\t\t\t\t\t\tids: {\n\t\t\t\t\t\t\t\tfirstGenCount,\n\t\t\t\t\t\t\t\tcount: numIds,\n\t\t\t\t\t\t\t\trequestedClusterSize: initialClusterCapacity,\n\t\t\t\t\t\t\t\tlocalIdRanges: [], // no need to populate, as session is remote and compressor would ignore in production\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\trunning = state.time(() => {\n\t\t\t\t\t\t\tperfCompressor.finalizeCreationRange(range);\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst lastGenCount = firstGenCount + numIds;\n\t\t\t\t\t\tif (isFirstClient) {\n\t\t\t\t\t\t\tnextFirstFinalizedGenCount1 = lastGenCount;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnextFirstFinalizedGenCount2 = lastGenCount;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Alternate clients to sidestep optimization that packs them all into last cluster\n\t\t\t\t\t\tsession = isFirstClient ? session1 : session2;\n\t\t\t\t\t} while (running);\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t}\n\n\tbenchmarkWithFlag((isLocal) => {\n\t\tconst remoteSessionId = sessionIds.get(remoteClient);\n\t\tbenchmarkIt({\n\t\t\ttitle: `normalize a ${\n\t\t\t\tisLocal ? \"local\" : \"final\"\n\t\t\t} ID from a remote session to session space`,\n\t\t\t...benchmarkDuration({\n\t\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\t\tconst { network, perfCompressor } = setupCompressors(\n\t\t\t\t\t\tinitialClusterCapacity,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t);\n\t\t\t\t\tconst remoteSession = getIdMadeBy(remoteClient, false, network);\n\t\t\t\t\tconst opSpaceId = (\n\t\t\t\t\t\tisLocal\n\t\t\t\t\t\t\t? remoteSession\n\t\t\t\t\t\t\t: network.getCompressor(remoteClient).normalizeToOpSpace(remoteSession)\n\t\t\t\t\t) as OpSpaceCompressedId;\n\t\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\t\tperfCompressor.normalizeToSessionSpace(opSpaceId, remoteSessionId);\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t});\n\n\tbenchmarkWithFlag((eagerFinal) => {\n\t\tbenchmarkIt({\n\t\t\ttitle: `normalize a final ID corresponding to a ${\n\t\t\t\teagerFinal ? \"eager final\" : \"local\"\n\t\t\t} ID from op space to the local session`,\n\t\t\t...benchmarkDuration({\n\t\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\t\tconst { network, perfCompressor } = setupCompressors(\n\t\t\t\t\t\tinitialClusterCapacity,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t);\n\t\t\t\t\tconst opId = perfCompressor.normalizeToOpSpace(\n\t\t\t\t\t\tgetIdMadeBy(localClient, eagerFinal, network),\n\t\t\t\t\t);\n\t\t\t\t\tassert(isFinalId(opId), \"Must be final\");\n\t\t\t\t\tconst id = opId as OpSpaceCompressedId & FinalCompressedId;\n\t\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\t\tperfCompressor.normalizeToSessionSpace(id, perfCompressor.localSessionId);\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t});\n\n\tbenchmarkWithFlag((isLocalOriginator) => {\n\t\tconst remoteSessionId = sessionIds.get(remoteClient);\n\t\tbenchmarkIt({\n\t\t\ttitle: `normalize a final ID from a ${\n\t\t\t\tisLocalOriginator ? \"local\" : \"remote\"\n\t\t\t} session to a small session space (common case)`,\n\t\t\t...benchmarkDuration({\n\t\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\t\tconst { network, perfCompressor } = setupCompressors(\n\t\t\t\t\t\tinitialClusterCapacity,\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t);\n\t\t\t\t\t// Ensure the local session has several different clusters\n\t\t\t\t\tfor (let clusterCount = 0; clusterCount < 5; clusterCount++) {\n\t\t\t\t\t\tnetwork.allocateAndSendIds(\n\t\t\t\t\t\t\tlocalClient,\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\t\t\t\t\t\t\tperfCompressor[\"nextRequestedClusterSize\"],\n\t\t\t\t\t\t);\n\t\t\t\t\t\tnetwork.allocateAndSendIds(\n\t\t\t\t\t\t\tremoteClient,\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\t\t\t\t\t\t\tperfCompressor[\"nextRequestedClusterSize\"] * 2,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tnetwork.deliverOperations(DestinationClient.All);\n\t\t\t\t\t}\n\t\t\t\t\tconst client = isLocalOriginator ? localClient : remoteClient;\n\t\t\t\t\tconst idFromSession = getIdMadeBy(client, true, network);\n\t\t\t\t\tconst opSpaceId = network.getCompressor(client).normalizeToOpSpace(idFromSession);\n\t\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\t\tperfCompressor.normalizeToSessionSpace(opSpaceId, remoteSessionId);\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t});\n\n\tbenchmarkIt({\n\t\ttitle: `normalize an unacked local ID from the local session to op space`,\n\t\t...benchmarkDuration({\n\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\tconst { network, perfCompressor } = setupCompressors(\n\t\t\t\t\tinitialClusterCapacity,\n\t\t\t\t\ttrue,\n\t\t\t\t\tfalse,\n\t\t\t\t);\n\t\t\t\t// Ensure no eager finals\n\t\t\t\tnetwork.allocateAndSendIds(\n\t\t\t\t\tlocalClient,\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\t\t\t\t\tnetwork.getCompressor(localClient)[\"nextRequestedClusterSize\"] * 2 + 1,\n\t\t\t\t);\n\t\t\t\tconst unackedLocalId = getIdMadeBy(localClient, false, network);\n\t\t\t\tassert(\n\t\t\t\t\tperfCompressor.normalizeToOpSpace(unackedLocalId) === (unackedLocalId as number),\n\t\t\t\t\t\"Local was acked.\",\n\t\t\t\t);\n\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\tperfCompressor.normalizeToOpSpace(unackedLocalId);\n\t\t\t\t});\n\t\t\t},\n\t\t}),\n\t});\n\n\tbenchmarkWithFlag((eagerFinal) => {\n\t\tbenchmarkIt({\n\t\t\ttitle: `normalize an acked ${\n\t\t\t\teagerFinal ? \"eager final\" : \"local\"\n\t\t\t} ID from the local session to op space`,\n\t\t\t...benchmarkDuration({\n\t\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\t\tconst { network, perfCompressor } = setupCompressors(\n\t\t\t\t\t\tinitialClusterCapacity,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t);\n\t\t\t\t\tconst id = getIdMadeBy(localClient, eagerFinal, network);\n\t\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\t\tperfCompressor.normalizeToOpSpace(id);\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t});\n\n\tbenchmarkWithFlag((local) => {\n\t\tbenchmarkIt({\n\t\t\ttitle: `decompress a final ID from a ${\n\t\t\t\tlocal ? \"local\" : \"remote\"\n\t\t\t} client into a stable ID`,\n\t\t\t...benchmarkDuration({\n\t\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\t\tconst { network, perfCompressor } = setupCompressors(\n\t\t\t\t\t\tinitialClusterCapacity,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t);\n\t\t\t\t\tconst finalIdToDecompress = getIdMadeBy(\n\t\t\t\t\t\tlocal ? localClient : remoteClient,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tnetwork,\n\t\t\t\t\t);\n\t\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\t\tperfCompressor.decompress(finalIdToDecompress);\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t});\n\n\tbenchmarkIt({\n\t\ttitle: `decompress a local ID into a stable ID`,\n\t\t...benchmarkDuration({\n\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\tconst { network, perfCompressor } = setupCompressors(\n\t\t\t\t\tinitialClusterCapacity,\n\t\t\t\t\ttrue,\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t\tconst localIdToDecompress = getIdMadeBy(localClient, false, network);\n\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\tperfCompressor.decompress(localIdToDecompress);\n\t\t\t\t});\n\t\t\t},\n\t\t}),\n\t});\n\n\tbenchmarkWithFlag((eagerFinal) => {\n\t\tbenchmarkIt({\n\t\t\ttitle: `recompress a stable ID to a ${eagerFinal ? \"local\" : \"final\"} ID`,\n\t\t\t...benchmarkDuration({\n\t\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\t\tconst { network, perfCompressor } = setupCompressors(\n\t\t\t\t\t\tinitialClusterCapacity,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t);\n\t\t\t\t\tconst stableToCompress = perfCompressor.decompress(\n\t\t\t\t\t\tgetIdMadeBy(localClient, eagerFinal, network),\n\t\t\t\t\t);\n\t\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\t\tperfCompressor.recompress(stableToCompress);\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t});\n\n\tbenchmarkWithFlag((manySessions) => {\n\t\tbenchmarkIt({\n\t\t\ttitle: `serialize an IdCompressor (${manySessions ? \"many sessions\" : \"many clusters\"})`,\n\t\t\t...benchmarkDuration({\n\t\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\t\tconst perfCompressor = manySessions\n\t\t\t\t\t\t? buildHugeCompressor(undefined, initialClusterCapacity)\n\t\t\t\t\t\t: setupCompressors(initialClusterCapacity, false, true).perfCompressor;\n\t\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\t\tperfCompressor.serialize(false);\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t});\n\n\tbenchmarkWithFlag((manySessions) => {\n\t\tconst overrideRemoteSessionId = createSessionId();\n\t\tbenchmarkIt({\n\t\t\ttitle: `deserialize an IdCompressor (${\n\t\t\t\tmanySessions ? \"many sessions\" : \"many clusters\"\n\t\t\t})`,\n\t\t\t...benchmarkDuration({\n\t\t\t\tbenchmarkFnCustom: async (state) => {\n\t\t\t\t\tconst perfCompressor = manySessions\n\t\t\t\t\t\t? buildHugeCompressor(undefined, initialClusterCapacity)\n\t\t\t\t\t\t: setupCompressors(initialClusterCapacity, false, true).perfCompressor;\n\t\t\t\t\tconst serialized: SerializedIdCompressorWithNoSession =\n\t\t\t\t\t\tperfCompressor.serialize(false);\n\t\t\t\t\tstate.timeAllBatches(() => {\n\t\t\t\t\t\tIdCompressor.deserialize({\n\t\t\t\t\t\t\tserialized,\n\t\t\t\t\t\t\tnewSessionId: overrideRemoteSessionId,\n\t\t\t\t\t\t\trequestedWriteVersion: SerializationVersion.V3,\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t});\n});\n"]}