From 3748fcfbdb3fbff44e4f741f2063cff612a72efe Mon Sep 17 00:00:00 2001 From: Andrew El Date: Sun, 2 May 2021 13:48:34 -0400 Subject: [PATCH] Update Akka.Net version, Clean up dead code in `ByteArrayJournalSerializer`, remove perf numbers till we make new ones --- README.md | 31 +--- ...tence.Linq2Db.Benchmark.DockerTests.csproj | 2 +- ...Persistence.Linq2Db.Benchmark.Tests.csproj | 2 +- ...e.Linq2Db.Compatibility.DockerTests.csproj | 2 +- ...istence.Linq2Db.Compatibility.Tests.csproj | 2 +- ...istence.Linq2Db.Journal.Query.Tests.csproj | 8 +- ...Persistence.Sql.Linq2Db.DockerTests.csproj | 14 +- .../Akka.Persistence.Sql.Linq2Db.Tests.csproj | 14 +- .../Journal/DAO/ByteArrayJournalSerializer.cs | 174 ------------------ 9 files changed, 27 insertions(+), 222 deletions(-) diff --git a/README.md b/README.md index b408a613..033c41e3 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,13 @@ A Cross-SQL-DB Engine Akka.Persistence plugin with broad database compatibility thanks to Linq2Db. -This is a Fairly-Naive port of the amazing akka-persistence-jdbc package from Scala to C#. +This is a port of the amazing akka-persistence-jdbc package from Scala, with a few improvements based on C# as well as our choice of data library. Please read the documentation carefully. Some features may be specific to use case and have trade-offs (namely, compatibility modes) ## Status -- Usable for basic Read/Writes + - Implements the following for `Akka.Persistence.Query`: - IPersistenceIdsQuery - ICurrentPersistenceIdsQuery @@ -20,9 +20,7 @@ Please read the documentation carefully. Some features may be specific to use ca - ICurrentAllEventsQuery - Snapshot Store Support -#### This is still a WORK IN PROGRESS - -**Pull Requests are Welcome** but please note this is still considered 'work in progress' and only used if one understands the risks. While the TCK Specs pass you should still test in a 'safe' non-production environment carefully before deciding to fully deploy. +See something you want to add or improve? **Pull Requests are Welcome!** Working: @@ -102,27 +100,8 @@ Compatibility with existing Providers is partially implemented via `table-compat # Performance -Tests based on i-7 8750H, 32GB Ram, 2TB SSD, Windows 10 version Version 10.0.19041.630. -Databases running on Docker WSL2. - -All numbers are in msg/sec. - -|Test |SqlServer (normal) | SqlServer Batching | Linq2Db |vs Normal| vs Batching| -|:------------- |:------------- | :----------: | -----------: | -----------: | -----------: | -|Persist | 164|445| 265|143.29%|55.04%| -|PersistAll | 782|958| 6364|717.26%|641.03%| -|PersistAsync | 630|917| 16463|2555.40%|1902.96%| -|PersistAllAsync | 2095|908| 16168|748.50%|1738.47%| -|PersistGroup10 | 590|633| 1239|181.19%|157.21%| -|PersistGroup100 | 607|930| 5504|912.19%|573.78%| -|PersistGroup200 | 628|1353| 8498|1268.47%|587.46%| -|PersistGroup25 | 629|632| 2473|348.01%|324.30%| -|PersistGroup400 | 612|1785| 8136|1182.52%|715.83%| -|PersistGroup50 | 612|651| 4075|631.86%|591.28%| -|Recovering | 41903|45161| 43442|101.64%|109.87%| -|Recovering8 | 75466|69575| 66186|84.75%|97.63%| -|RecoveringFour | 59259|51979| 58230|98.61%|113.79%| -|RecoveringTwo | 41745|37487| 41525|98.47%|115.76%| +Updated Performance numbers pending. + ## Sql.Common Compatibility modes - Delete Compatibility mode is available. diff --git a/src/Akka.Persistence.Linq2Db.Benchmark.DockerTests/Akka.Persistence.Linq2Db.Benchmark.DockerTests.csproj b/src/Akka.Persistence.Linq2Db.Benchmark.DockerTests/Akka.Persistence.Linq2Db.Benchmark.DockerTests.csproj index 109807e6..24982456 100644 --- a/src/Akka.Persistence.Linq2Db.Benchmark.DockerTests/Akka.Persistence.Linq2Db.Benchmark.DockerTests.csproj +++ b/src/Akka.Persistence.Linq2Db.Benchmark.DockerTests/Akka.Persistence.Linq2Db.Benchmark.DockerTests.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/Akka.Persistence.Linq2Db.Benchmark.Tests/Akka.Persistence.Linq2Db.Benchmark.Tests.csproj b/src/Akka.Persistence.Linq2Db.Benchmark.Tests/Akka.Persistence.Linq2Db.Benchmark.Tests.csproj index e1e5230a..fe771662 100644 --- a/src/Akka.Persistence.Linq2Db.Benchmark.Tests/Akka.Persistence.Linq2Db.Benchmark.Tests.csproj +++ b/src/Akka.Persistence.Linq2Db.Benchmark.Tests/Akka.Persistence.Linq2Db.Benchmark.Tests.csproj @@ -16,7 +16,7 @@ - + diff --git a/src/Akka.Persistence.Linq2Db.Compatibility.DockerTests/Akka.Persistence.Linq2Db.Compatibility.DockerTests.csproj b/src/Akka.Persistence.Linq2Db.Compatibility.DockerTests/Akka.Persistence.Linq2Db.Compatibility.DockerTests.csproj index dd7da3d7..61f8693a 100644 --- a/src/Akka.Persistence.Linq2Db.Compatibility.DockerTests/Akka.Persistence.Linq2Db.Compatibility.DockerTests.csproj +++ b/src/Akka.Persistence.Linq2Db.Compatibility.DockerTests/Akka.Persistence.Linq2Db.Compatibility.DockerTests.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/Akka.Persistence.Linq2Db.Compatibility.Tests/Akka.Persistence.Linq2Db.Compatibility.Tests.csproj b/src/Akka.Persistence.Linq2Db.Compatibility.Tests/Akka.Persistence.Linq2Db.Compatibility.Tests.csproj index db27ae2f..a9124902 100644 --- a/src/Akka.Persistence.Linq2Db.Compatibility.Tests/Akka.Persistence.Linq2Db.Compatibility.Tests.csproj +++ b/src/Akka.Persistence.Linq2Db.Compatibility.Tests/Akka.Persistence.Linq2Db.Compatibility.Tests.csproj @@ -9,7 +9,7 @@ - + diff --git a/src/Akka.Persistence.Linq2Db.Journal.Query.Tests/Akka.Persistence.Linq2Db.Journal.Query.Tests.csproj b/src/Akka.Persistence.Linq2Db.Journal.Query.Tests/Akka.Persistence.Linq2Db.Journal.Query.Tests.csproj index aebaf32f..39c48968 100644 --- a/src/Akka.Persistence.Linq2Db.Journal.Query.Tests/Akka.Persistence.Linq2Db.Journal.Query.Tests.csproj +++ b/src/Akka.Persistence.Linq2Db.Journal.Query.Tests/Akka.Persistence.Linq2Db.Journal.Query.Tests.csproj @@ -8,10 +8,10 @@ - - - - + + + + diff --git a/src/Akka.Persistence.Sql.Linq2Db.DockerTests/Akka.Persistence.Sql.Linq2Db.DockerTests.csproj b/src/Akka.Persistence.Sql.Linq2Db.DockerTests/Akka.Persistence.Sql.Linq2Db.DockerTests.csproj index bff2364c..5e0ec9d1 100644 --- a/src/Akka.Persistence.Sql.Linq2Db.DockerTests/Akka.Persistence.Sql.Linq2Db.DockerTests.csproj +++ b/src/Akka.Persistence.Sql.Linq2Db.DockerTests/Akka.Persistence.Sql.Linq2Db.DockerTests.csproj @@ -12,16 +12,16 @@ - - + + - - - + + + - + - + diff --git a/src/Akka.Persistence.Sql.Linq2Db.Tests/Akka.Persistence.Sql.Linq2Db.Tests.csproj b/src/Akka.Persistence.Sql.Linq2Db.Tests/Akka.Persistence.Sql.Linq2Db.Tests.csproj index e5358b4c..7369e828 100644 --- a/src/Akka.Persistence.Sql.Linq2Db.Tests/Akka.Persistence.Sql.Linq2Db.Tests.csproj +++ b/src/Akka.Persistence.Sql.Linq2Db.Tests/Akka.Persistence.Sql.Linq2Db.Tests.csproj @@ -11,16 +11,16 @@ - - + + - - - + + + - + - + diff --git a/src/Akka.Persistence.Sql.Linq2Db/Journal/DAO/ByteArrayJournalSerializer.cs b/src/Akka.Persistence.Sql.Linq2Db/Journal/DAO/ByteArrayJournalSerializer.cs index b30f26db..9c00a2d5 100644 --- a/src/Akka.Persistence.Sql.Linq2Db/Journal/DAO/ByteArrayJournalSerializer.cs +++ b/src/Akka.Persistence.Sql.Linq2Db/Journal/DAO/ByteArrayJournalSerializer.cs @@ -28,180 +28,6 @@ public ByteArrayJournalSerializer(IProviderConfig journalCon _separator = separator; _separatorArray = new[] {_separator}; } -/* - protected Try SerializeNew(IPersistentRepresentation persistentRepr, IImmutableSet tTags, long timeStamp = 0) - { - try - { - var ser = _serializer.FindSerializerForType(persistentRepr.Payload.GetType(),_journalConfig.DefaultSerializer); - // TODO: hack. Replace when https://github.com/akkadotnet/akka.net/issues/3811 - var binary = toBinary(persistentRepr, ser, out var manifest); - return new Try(new JournalRow() - { - manifest = manifest, - message = binary, - persistenceId = persistentRepr.PersistenceId, - tags = tTags.Any()? tTags.Aggregate((tl, tr) => tl + _separator + tr) : "", - Identifier = ser.Identifier, - sequenceNumber = persistentRepr.SequenceNr, - Timestamp = persistentRepr.Timestamp==0? timeStamp: persistentRepr.Timestamp - }); - } - catch (Exception e) - { - return new Try(e); - } - } - protected Try SerializeNew2(IPersistentRepresentation persistentRepr, IImmutableSet tTags, long timeStamp = 0) - { - try - { - var ser = _serializer.FindSerializerForType(persistentRepr.Payload.GetType(),_journalConfig.DefaultSerializer); - // TODO: hack. Replace when https://github.com/akkadotnet/akka.net/issues/3811 - var (binary, manifest) = toBinary2(persistentRepr.Payload, ser); - //var binary = toBinary(persistentRepr, ser, out var manifest); - return new Try(new JournalRow() - { - manifest = manifest, - message = binary, - persistenceId = persistentRepr.PersistenceId, - tags = tTags.Any()? tTags.Aggregate((tl, tr) => tl + _separator + tr) : "", - Identifier = ser.Identifier, - sequenceNumber = persistentRepr.SequenceNr, - Timestamp = persistentRepr.Timestamp==0? timeStamp: persistentRepr.Timestamp - }); - } - catch (Exception e) - { - return new Try(e); - } - } - - - - private byte[] toBinary(IPersistentRepresentation persistentRepr, - Serializer ser, out string manifest) - { - byte[] binary; - (binary, manifest) = Akka.Serialization.Serialization.WithTransport( - _serializer.System, (persistentRepr.Payload, ser), - static state => - { - var (payload, serializer) = state; - string thisManifest = ""; - if (serializer is SerializerWithStringManifest - stringManifest) - { - thisManifest = - stringManifest.Manifest(payload); - } - else - { - if (serializer.IncludeManifest) - { - thisManifest = payload - .GetType().TypeQualifiedName(); - } - } - - return (serializer.ToBinary(payload), - thisManifest); - }); - return binary; - } - - private (byte[],string) toBinary2(object payload, - Serializer ser) - { - return Akka.Serialization.Serialization.WithTransport( - _serializer.System, (payload, ser), - static state => - { - var (payload, serializer) = state; - string thisManifest = ""; - if (serializer is SerializerWithStringManifest - stringManifest) - { - thisManifest = - stringManifest.Manifest(payload); - } - else - { - if (serializer.IncludeManifest) - { - thisManifest = payload - .GetType().TypeQualifiedName(); - } - } - - return (serializer.ToBinary(payload), - thisManifest); - }); - } - - private JournalRow toBinary3(object payload) - { - return Akka.Serialization.Serialization.WithTransport( - _serializer.System, (payload, - _serializer.FindSerializerForType( - payload.GetType(), - _journalConfig.DefaultSerializer)), - static state => - { - var (payload, serializer) = state; - if (serializer is SerializerWithStringManifest - stringManifest) - { - return new JournalRow() - { - message =serializer.ToBinary(payload), - manifest = stringManifest.Manifest(payload), - Identifier = serializer.Identifier - }; - } - if (serializer.IncludeManifest) - { - return new JournalRow() - { - message =serializer.ToBinary(payload), - manifest = payload - .GetType().TypeQualifiedName(), - Identifier = serializer.Identifier - }; - } - - return new JournalRow() - { - message =serializer.ToBinary(payload), - manifest = String.Empty, - Identifier = serializer.Identifier - }; - }); - } - - - protected Try SerializeN(IPersistentRepresentation persistentRepr, IImmutableSet tTags, long timeStamp = 0) - { - try - { - // TODO: hack. Replace when https://github.com/akkadotnet/akka.net/issues/3811 - var buildingPayload = toBinary3(persistentRepr.Payload); - //var binary = toBinary(persistentRepr, ser, out var manifest); - buildingPayload.persistenceId = persistentRepr.PersistenceId; - buildingPayload.tags = tTags.Count == 0 - ? "" - : tTags.Aggregate((tl, tr) => tl + _separator + tr); - buildingPayload.sequenceNumber = persistentRepr.SequenceNr; - buildingPayload.Timestamp = persistentRepr.Timestamp == 0 - ? timeStamp - : persistentRepr.Timestamp; - return buildingPayload; - } - catch (Exception e) - { - return new Try(e); - } - }*/ /// /// Concatenates a set of tags using a provided separator.