diff --git a/src/Speckle.Sdk.Dependencies/Serialization/ChannelLoader.cs b/src/Speckle.Sdk.Dependencies/Serialization/ChannelLoader.cs index a05b7d7f..43f49e5d 100644 --- a/src/Speckle.Sdk.Dependencies/Serialization/ChannelLoader.cs +++ b/src/Speckle.Sdk.Dependencies/Serialization/ChannelLoader.cs @@ -5,7 +5,7 @@ namespace Speckle.Sdk.Dependencies.Serialization; public abstract class ChannelLoader(CancellationToken cancellationToken) { - private const int RECEIVE_CAPACITY = 5000; + private const int RECEIVE_CAPACITY = 10000; private const int HTTP_GET_CHUNK_SIZE = 500; private const int MAX_PARALLELISM_HTTP = 4; diff --git a/src/Speckle.Sdk.Dependencies/Serialization/ChannelSaver.cs b/src/Speckle.Sdk.Dependencies/Serialization/ChannelSaver.cs index 37d1b999..b688f3a2 100644 --- a/src/Speckle.Sdk.Dependencies/Serialization/ChannelSaver.cs +++ b/src/Speckle.Sdk.Dependencies/Serialization/ChannelSaver.cs @@ -8,7 +8,7 @@ namespace Speckle.Sdk.Dependencies.Serialization; public abstract class ChannelSaver where T : IHasByteSize { - private const int SEND_CAPACITY = 1000; + private const int SEND_CAPACITY = 10000; private const int HTTP_SEND_CHUNK_SIZE = 25_000_000; //bytes private static readonly TimeSpan HTTP_BATCH_TIMEOUT = TimeSpan.FromSeconds(2); private const int MAX_PARALLELISM_HTTP = 4; diff --git a/src/Speckle.Sdk/Api/Operations/Operations.Send.cs b/src/Speckle.Sdk/Api/Operations/Operations.Send.cs index 18ac48bb..eaad0b18 100644 --- a/src/Speckle.Sdk/Api/Operations/Operations.Send.cs +++ b/src/Speckle.Sdk/Api/Operations/Operations.Send.cs @@ -47,6 +47,11 @@ public partial class Operations receiveActivity?.SetStatus(SdkActivityStatusCode.Ok); return results; } + catch (OperationCanceledException) + { + //this is handled by the caller + throw; + } catch (Exception ex) { receiveActivity?.SetStatus(SdkActivityStatusCode.Error); diff --git a/src/Speckle.Sdk/Serialisation/V2/Send/SerializeProcess.cs b/src/Speckle.Sdk/Serialisation/V2/Send/SerializeProcess.cs index 0254921d..759ffa19 100644 --- a/src/Speckle.Sdk/Serialisation/V2/Send/SerializeProcess.cs +++ b/src/Speckle.Sdk/Serialisation/V2/Send/SerializeProcess.cs @@ -226,9 +226,17 @@ public sealed class SerializeProcess( var childClosures = _childClosurePool.Get(); foreach (var childClosure in taskClosures) { + if (_processSource.Token.IsCancellationRequested) + { + return EMPTY_CLOSURES; + } foreach (var kvp in childClosure) { childClosures[kvp.Key] = kvp.Value; + if (_processSource.Token.IsCancellationRequested) + { + return EMPTY_CLOSURES; + } } _currentClosurePool.Return(childClosure); @@ -253,13 +261,13 @@ public sealed class SerializeProcess( progress?.Report(new(ProgressEvent.FromCacheOrSerialized, _objectCount, Math.Max(_objectCount, _objectsFound))); foreach (var item in items) { + if (_processSource.Token.IsCancellationRequested) + { + return EMPTY_CLOSURES; + } + if (item.NeedsStorage) { - if (_processSource.Token.IsCancellationRequested) - { - return EMPTY_CLOSURES; - } - Interlocked.Increment(ref _objectsSerialized); await objectSaver.SaveAsync(item).ConfigureAwait(false); }