Add some debugging stats about the sent or received payloads to add debugging when things are massive (#319)
This commit is contained in:
@@ -41,7 +41,13 @@ public sealed class DeserializeProcess(
|
||||
:
|
||||
#pragma warning disable CA2000
|
||||
this(
|
||||
new ObjectLoader(sqLiteJsonCacheManager, serverObjectManager, progress, cancellationToken),
|
||||
new ObjectLoader(
|
||||
sqLiteJsonCacheManager,
|
||||
serverObjectManager,
|
||||
progress,
|
||||
loggerFactory.CreateLogger<ObjectLoader>(),
|
||||
cancellationToken
|
||||
),
|
||||
progress,
|
||||
baseDeserializer,
|
||||
loggerFactory,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Speckle.InterfaceGenerator;
|
||||
using Speckle.Sdk.Common;
|
||||
using Speckle.Sdk.Dependencies;
|
||||
@@ -16,6 +17,7 @@ public sealed class ObjectLoader(
|
||||
ISqLiteJsonCacheManager sqLiteJsonCacheManager,
|
||||
IServerObjectManager serverObjectManager,
|
||||
IProgress<ProgressArgs>? progress,
|
||||
ILogger<ObjectLoader> logger,
|
||||
CancellationToken cancellationToken
|
||||
#pragma warning disable CS9107 // Parameter is captured into the state of the enclosing type and its value is also passed to the base constructor. The value might be captured by the base class as well.
|
||||
) : ChannelLoader<BaseItem>(cancellationToken), IObjectLoader
|
||||
@@ -129,12 +131,32 @@ public sealed class ObjectLoader(
|
||||
[AutoInterfaceIgnore]
|
||||
protected override void SaveToCacheInternal(List<BaseItem> batch)
|
||||
{
|
||||
if (!_options.SkipCache)
|
||||
try
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
sqLiteJsonCacheManager.SaveObjects(batch.Select(x => (x.Id.Value, x.Json.Value)));
|
||||
Interlocked.Exchange(ref _cached, _cached + batch.Count);
|
||||
progress?.Report(new(ProgressEvent.CachedToLocal, _cached, _allChildrenCount));
|
||||
if (!_options.SkipCache)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
sqLiteJsonCacheManager.SaveObjects(batch.Select(x => (x.Id.Value, x.Json.Value)));
|
||||
Interlocked.Exchange(ref _cached, _cached + batch.Count);
|
||||
progress?.Report(new(ProgressEvent.CachedToLocal, _cached, _allChildrenCount));
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
#pragma warning disable CA1031
|
||||
catch (Exception)
|
||||
#pragma warning restore CA1031
|
||||
{
|
||||
logger.LogError(
|
||||
"Error while saving to cache, some stats of the payload: {Count} objects, {Serialized} serialized, {Cached} cached, {BatchByteSize} batch bytes",
|
||||
batch.Count,
|
||||
_allChildrenCount,
|
||||
_cached,
|
||||
batch.Sum(x => x.ByteSize)
|
||||
);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,13 @@ public sealed class ObjectSaver(
|
||||
#pragma warning restore CA1031
|
||||
{
|
||||
RecordException(e);
|
||||
logger.LogError(
|
||||
"Error while sending objects to server, some stats of the payload: {Count} objects, {Serialized} serialized, {Cached} cached, {BatchByteSize} batch bytes",
|
||||
batch.Items.Count,
|
||||
_objectsSerialized,
|
||||
_cached,
|
||||
batch.BatchByteSize
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +114,13 @@ public sealed class ObjectSaver(
|
||||
#pragma warning restore CA1031
|
||||
{
|
||||
RecordException(e);
|
||||
logger.LogError(
|
||||
"Error while saving to cache, some stats of the payload: {Count} objects, {Serialized} serialized, {Cached} cached, {BatchByteSize} batch bytes",
|
||||
batch.Count,
|
||||
_objectsSerialized,
|
||||
_cached,
|
||||
batch.Sum(x => x.ByteSize)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,6 +112,7 @@ public class ExceptionTests
|
||||
new DummySqLiteReceiveManager(new Dictionary<string, string>()),
|
||||
new ExceptionServerObjectManager(),
|
||||
null,
|
||||
new NullLogger<ObjectLoader>(),
|
||||
default
|
||||
);
|
||||
await using var process = new DeserializeProcess(
|
||||
|
||||
@@ -196,6 +196,7 @@ public class SerializationTests
|
||||
new DummySqLiteReceiveManager(closures),
|
||||
new DummyReceiveServerObjectManager(closures),
|
||||
null,
|
||||
new NullLogger<ObjectLoader>(),
|
||||
default
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user