Skip to content

Commit

Permalink
Switch Akka.Cluster.Benchmark persistence benchmark from using SQLite…
Browse files Browse the repository at this point in the history
… to MemoryJournal to minimize external variable (#5514)
  • Loading branch information
Arkatufus authored Jan 14, 2022
1 parent 5223ed4 commit 811ab74
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class JournalWriteBenchmarks
[IterationSetup]
public void Setup()
{
var (connectionStr, config) = GenerateJournalConfig();
var config = GenerateJournalConfig();
_sys1 = ActorSystem.Create("MySys", config);
_doneActor = _sys1.ActorOf(Props.Create(() => new BenchmarkDoneActor(PersistentActors)), "done");
_persistentActors = new HashSet<IActorRef>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,31 +172,22 @@ protected override bool ReceiveCommand(object message){
public static class PersistenceInfrastructure{
public static readonly AtomicCounter DbCounter = new AtomicCounter(0);

public static (string connectionString, Config hoconConfig) GenerateJournalConfig(){
return GenerateJournalConfig(DbCounter.GetAndIncrement().ToString());
}

public static (string connectionString, Config hoconConfig) GenerateJournalConfig(string databaseId){
// need to create a unique database instance each time benchmark is run so we don't pollute
// might need to disable shared cache
var connectionString = $"Datasource=memdb-journal-{databaseId}.db;Mode=Memory;Cache=Shared";

public static Config GenerateJournalConfig(){
var config = ConfigurationFactory.ParseString(@"
akka {
persistence.journal {
plugin = ""akka.persistence.journal.sqlite""
sqlite {
class = ""Akka.Persistence.Sqlite.Journal.BatchingSqliteJournal, Akka.Persistence.Sqlite""
plugin = ""akka.persistence.journal.inmem""
# In-memory journal plugin.
akka.persistence.journal.inmem {
# Class name of the plugin.
class = ""Akka.Persistence.Journal.MemoryJournal, Akka.Persistence""
# Dispatcher for the plugin actor.
plugin-dispatcher = ""akka.actor.default-dispatcher""
table-name = event_journal
metadata-table-name = journal_metadata
auto-initialize = on
connection-string = """+ connectionString +@"""
}
}
}");

return (connectionString, config);
return config;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class RecoveryBenchmark

[Params(1, 10, 100)] public int PersistentActors;

[Params(100)] public int WriteMsgCount;
[Params(100, 1000)] public int WriteMsgCount;

private ActorSystem _sys1;

Expand All @@ -33,7 +33,7 @@ public class RecoveryBenchmark
[GlobalSetup]
public async Task GlobalSetup()
{
var (connectionStr, config) = GenerateJournalConfig();
var config = GenerateJournalConfig();
_sys1 = ActorSystem.Create("MySys", config);
_doneActor = _sys1.ActorOf(Props.Create(() => new BenchmarkDoneActor(PersistentActors)), "done");
_persistentActors = new HashSet<IActorRef>();
Expand Down

0 comments on commit 811ab74

Please sign in to comment.