diff --git a/src/Speckle.Sdk.Dependencies/Serialization/ChannelLoader.cs b/src/Speckle.Sdk.Dependencies/Serialization/ChannelLoader.cs index e9d6e729..ccecd183 100644 --- a/src/Speckle.Sdk.Dependencies/Serialization/ChannelLoader.cs +++ b/src/Speckle.Sdk.Dependencies/Serialization/ChannelLoader.cs @@ -8,8 +8,8 @@ public abstract class ChannelLoader private const int MAX_PARALLELISM_HTTP = 4; private static readonly TimeSpan HTTP_BATCH_TIMEOUT = TimeSpan.FromSeconds(2); private static readonly int MAX_READ_CACHE_PARALLELISM = Environment.ProcessorCount; - private const int MAX_SAVE_CACHE_BATCH = 200; - private const int MAX_SAVE_CACHE_PARALLELISM = 1; + private const int MAX_SAVE_CACHE_BATCH = 500; + private const int MAX_SAVE_CACHE_PARALLELISM = 4; protected async Task GetAndCache(IEnumerable allChildrenIds, CancellationToken cancellationToken = default) => await allChildrenIds diff --git a/src/Speckle.Sdk/Serialisation/V2/Receive/ObjectLoader.cs b/src/Speckle.Sdk/Serialisation/V2/Receive/ObjectLoader.cs index 345190c5..b80a5b01 100644 --- a/src/Speckle.Sdk/Serialisation/V2/Receive/ObjectLoader.cs +++ b/src/Speckle.Sdk/Serialisation/V2/Receive/ObjectLoader.cs @@ -21,6 +21,8 @@ public sealed class ObjectLoader( private int? _allChildrenCount; private long _checkCache; private long _cached; + private long _downloaded; + private long _totalToDownload; private DeserializeProcessOptions _options = new(false); [AutoInterfaceIgnore] @@ -72,6 +74,7 @@ CancellationToken cancellationToken progress?.Report(new(ProgressEvent.CacheCheck, _checkCache, _allChildrenCount)); if (!_options.SkipCache && !sqLiteJsonCacheManager.HasObject(id)) { + Interlocked.Increment(ref _totalToDownload); return id; } @@ -86,6 +89,8 @@ public override async Task> Download(List ids) var (id, json) in serverObjectManager.DownloadObjects(ids.Select(x => x.NotNull()).ToList(), progress, default) ) { + Interlocked.Increment(ref _downloaded); + progress?.Report(new(ProgressEvent.DownloadObjects, _downloaded, _totalToDownload)); toCache.Add(new(new(id), new(json), true, null)); } diff --git a/src/Speckle.Sdk/Serialisation/V2/Send/SerializeProcess.cs b/src/Speckle.Sdk/Serialisation/V2/Send/SerializeProcess.cs index 242fc5a0..0713d9e1 100644 --- a/src/Speckle.Sdk/Serialisation/V2/Send/SerializeProcess.cs +++ b/src/Speckle.Sdk/Serialisation/V2/Send/SerializeProcess.cs @@ -77,7 +77,8 @@ public async Task Serialize(Base root, CancellationToke ); } - await Traverse(root, true, cancellationToken).ConfigureAwait(false); + await Traverse(root, cancellationToken).ConfigureAwait(false); + await Done().ConfigureAwait(true); await channelTask.ConfigureAwait(false); await findTotalObjectsTask.ConfigureAwait(false); return new(root.id.NotNull(), _objectReferences.Freeze()); @@ -93,7 +94,7 @@ private void TraverseTotal(Base obj) } } - private async Task> Traverse(Base obj, bool isEnd, CancellationToken cancellationToken) + private async Task> Traverse(Base obj, CancellationToken cancellationToken) { var tasks = new List>>(); foreach (var child in baseChildFinder.GetChildren(obj)) @@ -102,7 +103,7 @@ private async Task> Traverse(Base obj, bool isEnd, Canc var tmp = child; var t = Task .Factory.StartNew( - () => Traverse(tmp, false, cancellationToken), + () => Traverse(tmp, cancellationToken), cancellationToken, TaskCreationOptions.AttachedToParent | TaskCreationOptions.PreferFairness, _belowNormal @@ -145,12 +146,6 @@ private async Task> Traverse(Base obj, bool isEnd, Canc } } _childClosurePool.Return(childClosures); - - if (isEnd) - { - await Done().ConfigureAwait(true); - } - return currentClosures; } diff --git a/src/Speckle.Sdk/Transports/ProgressArgs.cs b/src/Speckle.Sdk/Transports/ProgressArgs.cs index f0711b22..b7660374 100644 --- a/src/Speckle.Sdk/Transports/ProgressArgs.cs +++ b/src/Speckle.Sdk/Transports/ProgressArgs.cs @@ -13,6 +13,7 @@ public enum ProgressEvent CacheCheck, DownloadBytes, + DownloadObjects, DeserializeObject, SerializeObject, // old diff --git a/tests/Speckle.Sdk.Tests.Integration/Credentials/UserServerInfoTests.cs b/tests/Speckle.Sdk.Tests.Integration/Credentials/UserServerInfoTests.cs index fe621978..43a93be8 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Credentials/UserServerInfoTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Credentials/UserServerInfoTests.cs @@ -29,17 +29,6 @@ public async Task IsFrontEnd2True() result.frontend2.Should().BeTrue(); } - [Fact] - public async Task IsFrontEnd2False() - { - ServerInfo? result = await Fixtures - .ServiceProvider.GetRequiredService() - .GetServerInfo(new("https://speckle.xyz/")); - - result.Should().NotBeNull(); - result.frontend2.Should().BeFalse(); - } - /// /// We get ServerInfo from "http://localhost:3000/graphql", /// Then we mutate the `frontend2` property of ServerInfo by trying to fetch header from "http://localhost:3000/",