@fluidframework/container-runtime 2.0.0-dev-rc.3.0.0.253463 → 2.0.0-dev-rc.3.0.0.254274

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 (36) hide show
  1. package/api-report/container-runtime.api.md +1 -1
  2. package/dist/channelCollection.d.ts +1 -0
  3. package/dist/channelCollection.d.ts.map +1 -1
  4. package/dist/channelCollection.js +4 -1
  5. package/dist/channelCollection.js.map +1 -1
  6. package/dist/container-runtime-untrimmed.d.ts +2 -1
  7. package/dist/containerRuntime.d.ts.map +1 -1
  8. package/dist/containerRuntime.js +20 -12
  9. package/dist/containerRuntime.js.map +1 -1
  10. package/dist/dataStoreContext.d.ts +2 -2
  11. package/dist/dataStoreContext.d.ts.map +1 -1
  12. package/dist/dataStoreContext.js +12 -2
  13. package/dist/dataStoreContext.js.map +1 -1
  14. package/dist/packageVersion.d.ts +1 -1
  15. package/dist/packageVersion.js +1 -1
  16. package/dist/packageVersion.js.map +1 -1
  17. package/lib/channelCollection.d.ts +1 -0
  18. package/lib/channelCollection.d.ts.map +1 -1
  19. package/lib/channelCollection.js +4 -1
  20. package/lib/channelCollection.js.map +1 -1
  21. package/lib/container-runtime-untrimmed.d.ts +2 -1
  22. package/lib/containerRuntime.d.ts.map +1 -1
  23. package/lib/containerRuntime.js +20 -12
  24. package/lib/containerRuntime.js.map +1 -1
  25. package/lib/dataStoreContext.d.ts +2 -2
  26. package/lib/dataStoreContext.d.ts.map +1 -1
  27. package/lib/dataStoreContext.js +12 -2
  28. package/lib/dataStoreContext.js.map +1 -1
  29. package/lib/packageVersion.d.ts +1 -1
  30. package/lib/packageVersion.js +1 -1
  31. package/lib/packageVersion.js.map +1 -1
  32. package/package.json +24 -24
  33. package/src/channelCollection.ts +5 -1
  34. package/src/containerRuntime.ts +25 -12
  35. package/src/dataStoreContext.ts +15 -3
  36. package/src/packageVersion.ts +1 -1
@@ -270,6 +270,7 @@ export class ChannelCollection implements IFluidDataStoreChannel, IDisposable {
270
270
  >();
271
271
 
272
272
  protected readonly contexts: DataStoreContexts;
273
+ private readonly aliasedDataStores: Set<string>;
273
274
 
274
275
  constructor(
275
276
  protected readonly baseSnapshot: ISnapshotTree | undefined,
@@ -299,6 +300,7 @@ export class ChannelCollection implements IFluidDataStoreChannel, IDisposable {
299
300
  "",
300
301
  this.parentContext.IFluidHandleContext,
301
302
  );
303
+ this.aliasedDataStores = new Set(aliasMap.values());
302
304
 
303
305
  // Extract stores stored inside the snapshot
304
306
  const fluidDataStores = new Map<string, ISnapshotTree>();
@@ -523,6 +525,7 @@ export class ChannelCollection implements IFluidDataStoreChannel, IDisposable {
523
525
  this.parentContext.addedGCOutboundReference?.(this.containerRuntimeHandle, handle);
524
526
 
525
527
  this.aliasMap.set(alias, context.id);
528
+ this.aliasedDataStores.add(context.id);
526
529
  context.setInMemoryRoot();
527
530
  return true;
528
531
  }
@@ -1289,8 +1292,9 @@ export class ChannelCollection implements IFluidDataStoreChannel, IDisposable {
1289
1292
  */
1290
1293
  private async getOutboundRoutes(): Promise<string[]> {
1291
1294
  const outboundRoutes: string[] = [];
1295
+ // Getting this information is a performance optimization that reduces network calls for virtualized datastores
1292
1296
  for (const [contextId, context] of this.contexts) {
1293
- const isRootDataStore = await context.isRoot();
1297
+ const isRootDataStore = await context.isRoot(this.aliasedDataStores);
1294
1298
  if (isRootDataStore) {
1295
1299
  outboundRoutes.push(`/${contextId}`);
1296
1300
  }
@@ -882,6 +882,19 @@ export class ContainerRuntime
882
882
  }
883
883
  }
884
884
 
885
+ let desiredIdCompressorMode: IdCompressorMode;
886
+ switch (mc.config.getBoolean("Fluid.ContainerRuntime.IdCompressorEnabled")) {
887
+ case true:
888
+ desiredIdCompressorMode = "on";
889
+ break;
890
+ case false:
891
+ desiredIdCompressorMode = undefined;
892
+ break;
893
+ default:
894
+ desiredIdCompressorMode = enableRuntimeIdCompressor;
895
+ break;
896
+ }
897
+
885
898
  // Enabling the IdCompressor is a one-way operation and we only want to
886
899
  // allow new containers to turn it on.
887
900
  let idCompressorMode: IdCompressorMode;
@@ -893,23 +906,19 @@ export class ContainerRuntime
893
906
  // 3) Same logic applies for "delayed" mode
894
907
  // Maybe in the future we will need to enabled (and figure how to do it safely) "delayed" -> "on" change.
895
908
  // We could do "off" -> "on" transition too, if all clients start loading compressor (but not using it initially) and
896
- // do so for a while - this will allow clients to eventually to disregard "off" setting (when it's safe so) and start
909
+ // do so for a while - this will allow clients to eventually disregard "off" setting (when it's safe so) and start
897
910
  // using compressor in future sessions.
898
911
  // Everyting is possible, but it needs to be designed and executed carefully, when such need arises.
899
912
  idCompressorMode = metadata?.documentSchema?.runtime
900
913
  ?.idCompressorMode as IdCompressorMode;
901
- } else {
902
- switch (mc.config.getBoolean("Fluid.ContainerRuntime.IdCompressorEnabled")) {
903
- case true:
904
- idCompressorMode = "on";
905
- break;
906
- case false:
907
- idCompressorMode = undefined;
908
- break;
909
- default:
910
- idCompressorMode = enableRuntimeIdCompressor;
911
- break;
914
+
915
+ // This is the only exception to the rule above - we have proper plumbing to load ID compressor on schema change
916
+ // event. It is loaded async (relative to op processing), so this conversion is only safe for off -> delayed conversion!
917
+ if (idCompressorMode === undefined && desiredIdCompressorMode === "delayed") {
918
+ idCompressorMode = desiredIdCompressorMode;
912
919
  }
920
+ } else {
921
+ idCompressorMode = desiredIdCompressorMode;
913
922
  }
914
923
 
915
924
  const createIdCompressorFn = async () => {
@@ -2642,6 +2651,10 @@ export class ContainerRuntime
2642
2651
  // Some other client turned on the id compressor. If we have not turned it on,
2643
2652
  // put it in a pending queue and delay finalization.
2644
2653
  if (this._idCompressor === undefined) {
2654
+ assert(
2655
+ this.idCompressorMode !== undefined,
2656
+ "id compressor should be enabled",
2657
+ );
2645
2658
  this.pendingIdCompressorOps.push(range);
2646
2659
  } else {
2647
2660
  this._idCompressor.finalizeCreationRange(range);
@@ -8,11 +8,11 @@ import { AttachState, IAudience, IDeltaManager } from "@fluidframework/container
8
8
  import {
9
9
  FluidObject,
10
10
  IDisposable,
11
+ IEvent,
11
12
  IFluidHandle,
12
13
  IRequest,
13
14
  IResponse,
14
15
  ITelemetryBaseProperties,
15
- IEvent,
16
16
  } from "@fluidframework/core-interfaces";
17
17
  import { assert, LazyPromise, unreachableCase } from "@fluidframework/core-utils/internal";
18
18
  import { IDocumentStorageService } from "@fluidframework/driver-definitions/internal";
@@ -271,8 +271,20 @@ export abstract class FluidDataStoreContext
271
271
  * 2. is root as part of the base snapshot that the datastore loaded from
272
272
  * @returns whether a datastore is root
273
273
  */
274
- public async isRoot(): Promise<boolean> {
275
- return this.isInMemoryRoot() || (await this.getInitialSnapshotDetails()).isRootDataStore;
274
+ public async isRoot(aliasedDataStores?: Set<string>): Promise<boolean> {
275
+ if (this.isInMemoryRoot()) {
276
+ return true;
277
+ }
278
+
279
+ // This if is a performance optimization.
280
+ // We know that if the base snapshot is omitted, then the isRootDataStore flag is not set.
281
+ // That means we can skip the expensive call to getInitialSnapshotDetails for virtualized datastores,
282
+ // and get the information from the alias map directly.
283
+ if (aliasedDataStores !== undefined && this.baseSnapshot?.omitted === true) {
284
+ return aliasedDataStores.has(this.id);
285
+ }
286
+
287
+ return (await this.getInitialSnapshotDetails()).isRootDataStore;
276
288
  }
277
289
 
278
290
  /**
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/container-runtime";
9
- export const pkgVersion = "2.0.0-dev-rc.3.0.0.253463";
9
+ export const pkgVersion = "2.0.0-dev-rc.3.0.0.254274";