diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/FileSystem/IFileSystem.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/FileSystem/IFileSystem.cs index 88bb2624..1a3a4aed 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/FileSystem/IFileSystem.cs +++ b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/FileSystem/IFileSystem.cs @@ -16,6 +16,8 @@ public interface IFileSystem : IDisposable bool CanWrite => true; + bool CanAccessInParallel => false; + IFile GetFile(FilePath path); IEnumerable GetFiles(FilePath path, string extension); diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/FileSystem/Zip/ZipFileSystem.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/FileSystem/Zip/ZipFileSystem.cs index 91acd4c2..a29cfa84 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/FileSystem/Zip/ZipFileSystem.cs +++ b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/FileSystem/Zip/ZipFileSystem.cs @@ -20,6 +20,8 @@ public sealed class ZipFileSystem : IFileSystem public string FullName => fileInfo.FullName; + public bool CanAccessInParallel => false; + public ZipFileSystem(FileInfo fileInfo) { zipArchive = new ZipArchive(fileInfo.Open(FileMode.OpenOrCreate), ZipArchiveMode.Update); diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/DownloadPipeline.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/DownloadPipeline.cs index a347cede..456303dd 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/DownloadPipeline.cs +++ b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/DownloadPipeline.cs @@ -52,6 +52,8 @@ public DownloadPipeline(ISession session, ILogger log, IFileSystem fs) BoundedCapacity = 1 }); + var maxDegreeOfParallelism = fs.CanAccessInParallel ? Environment.ProcessorCount * 2 : 1; + var downloadStep = new ActionBlock<(AssetDto, FilePath)>(async item => { var (asset, path) = item; @@ -88,9 +90,9 @@ public DownloadPipeline(ISession session, ILogger log, IFileSystem fs) } }, new ExecutionDataflowBlockOptions { - MaxDegreeOfParallelism = 8, + MaxDegreeOfParallelism = maxDegreeOfParallelism, MaxMessagesPerTask = 1, - BoundedCapacity = 16 + BoundedCapacity = maxDegreeOfParallelism * 2 }); fileNameStep.LinkTo(downloadStep, new DataflowLinkOptions diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/UploadPipeline.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/UploadPipeline.cs index 52c797ec..26604023 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/UploadPipeline.cs +++ b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/UploadPipeline.cs @@ -53,6 +53,8 @@ public UploadPipeline(ISession session, ILogger log, IFileSystem fs) BoundedCapacity = 1 }); + var maxDegreeOfParallelism = fs.CanAccessInParallel ? Environment.ProcessorCount * 2 : 1; + var uploadStep = new ActionBlock<(AssetModel, FilePath)>(async item => { var (asset, path) = item; @@ -85,9 +87,9 @@ public UploadPipeline(ISession session, ILogger log, IFileSystem fs) } }, new ExecutionDataflowBlockOptions { - MaxDegreeOfParallelism = 8, + MaxDegreeOfParallelism = maxDegreeOfParallelism, MaxMessagesPerTask = 1, - BoundedCapacity = 16 + BoundedCapacity = maxDegreeOfParallelism * 2 }); fileNameStep.LinkTo(uploadStep, new DataflowLinkOptions diff --git a/cli/Squidex.CLI/Squidex.CLI/Squidex.CLI.csproj b/cli/Squidex.CLI/Squidex.CLI/Squidex.CLI.csproj index 97c51c58..c13ce153 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Squidex.CLI.csproj +++ b/cli/Squidex.CLI/Squidex.CLI/Squidex.CLI.csproj @@ -14,7 +14,7 @@ net5.0 true sq - 7.17 + 7.18