Skip to content

Commit

Permalink
Merge pull request #8 from Nexus-Mods/datoms-rocksdb-rewrite
Browse files Browse the repository at this point in the history
Rewrite around datom centric code
  • Loading branch information
halgari authored Feb 14, 2024
2 parents dbcf531 + 8eb2df2 commit c7fdca6
Show file tree
Hide file tree
Showing 174 changed files with 3,062 additions and 6,459 deletions.
66 changes: 40 additions & 26 deletions NexusMods.EventSourcing.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,21 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{6ED01F9D
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing", "src\NexusMods.EventSourcing\NexusMods.EventSourcing.csproj", "{A92DED3D-BC67-4E04-9A06-9A1B302B3070}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing.Tests", "tests\NexusMods.EventSourcing.Tests\NexusMods.EventSourcing.Tests.csproj", "{30CBEB4A-E0C0-4B11-A0CF-F97BFACEEF89}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing.Abstractions", "src\NexusMods.EventSourcing.Abstractions\NexusMods.EventSourcing.Abstractions.csproj", "{6737673E-5898-42EC-B0B2-60DE2CFFF0AF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing.TestModel", "tests\NexusMods.EventSourcing.TestModel\NexusMods.EventSourcing.TestModel.csproj", "{66DCB10E-1D80-4A83-8380-B2E08BEEE7AE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{72AFE85F-8C12-436A-894E-638ED2C92A76}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing.Benchmarks", "benchmarks\NexusMods.EventSourcing.Benchmarks\NexusMods.EventSourcing.Benchmarks.csproj", "{96977D99-BF4B-4952-B594-6E44CCD826B9}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing.DatomStore", "src\NexusMods.EventSourcing.DatomStore\NexusMods.EventSourcing.DatomStore.csproj", "{F2C1FB09-D01D-4E8B-B6BE-B548AB00187B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing.TestModel", "tests\NexusMods.EventSourcing.TestModel\NexusMods.EventSourcing.TestModel.csproj", "{EC1570A4-18B9-4A76-84FF-275BAA76A357}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing.DatomStore.Tests", "tests\NexusMods.EventSourcing.DatomStore.Tests\NexusMods.EventSourcing.DatomStore.Tests.csproj", "{81CCE07D-818D-4153-8486-5D2A860C4D9D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing.SourceGenerator", "src\NexusMods.EventSourcing.SourceGenerator\NexusMods.EventSourcing.SourceGenerator.csproj", "{F2A6F6B9-5D36-4416-BDD8-C7D30EE3ED4A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing.Tests", "tests\NexusMods.EventSourcing.Tests\NexusMods.EventSourcing.Tests.csproj", "{07E2C578-8644-474D-8F07-B25CFEB28408}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing.RocksDB", "src\NexusMods.EventSourcing.RocksDB\NexusMods.EventSourcing.RocksDB.csproj", "{B8D0772A-FAD1-49AD-A85B-B2B6C5B14420}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing.Benchmarks", "benchmarks\NexusMods.EventSourcing.Benchmarks\NexusMods.EventSourcing.Benchmarks.csproj", "{930B3AB7-56EA-48D6-B603-24D79C7DD00A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -44,36 +48,46 @@ Global
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{A92DED3D-BC67-4E04-9A06-9A1B302B3070} = {0377EBE6-F147-4233-86AD-32C821B9567E}
{30CBEB4A-E0C0-4B11-A0CF-F97BFACEEF89} = {6ED01F9D-5E12-4EB2-9601-64A2ADC719DE}
{6737673E-5898-42EC-B0B2-60DE2CFFF0AF} = {0377EBE6-F147-4233-86AD-32C821B9567E}
{66DCB10E-1D80-4A83-8380-B2E08BEEE7AE} = {6ED01F9D-5E12-4EB2-9601-64A2ADC719DE}
{96977D99-BF4B-4952-B594-6E44CCD826B9} = {72AFE85F-8C12-436A-894E-638ED2C92A76}
{B8D0772A-FAD1-49AD-A85B-B2B6C5B14420} = {0377EBE6-F147-4233-86AD-32C821B9567E}
{F2C1FB09-D01D-4E8B-B6BE-B548AB00187B} = {0377EBE6-F147-4233-86AD-32C821B9567E}
{EC1570A4-18B9-4A76-84FF-275BAA76A357} = {6ED01F9D-5E12-4EB2-9601-64A2ADC719DE}
{81CCE07D-818D-4153-8486-5D2A860C4D9D} = {6ED01F9D-5E12-4EB2-9601-64A2ADC719DE}
{F2A6F6B9-5D36-4416-BDD8-C7D30EE3ED4A} = {0377EBE6-F147-4233-86AD-32C821B9567E}
{07E2C578-8644-474D-8F07-B25CFEB28408} = {6ED01F9D-5E12-4EB2-9601-64A2ADC719DE}
{930B3AB7-56EA-48D6-B603-24D79C7DD00A} = {72AFE85F-8C12-436A-894E-638ED2C92A76}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A92DED3D-BC67-4E04-9A06-9A1B302B3070}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A92DED3D-BC67-4E04-9A06-9A1B302B3070}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A92DED3D-BC67-4E04-9A06-9A1B302B3070}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A92DED3D-BC67-4E04-9A06-9A1B302B3070}.Release|Any CPU.Build.0 = Release|Any CPU
{30CBEB4A-E0C0-4B11-A0CF-F97BFACEEF89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30CBEB4A-E0C0-4B11-A0CF-F97BFACEEF89}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30CBEB4A-E0C0-4B11-A0CF-F97BFACEEF89}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30CBEB4A-E0C0-4B11-A0CF-F97BFACEEF89}.Release|Any CPU.Build.0 = Release|Any CPU
{6737673E-5898-42EC-B0B2-60DE2CFFF0AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6737673E-5898-42EC-B0B2-60DE2CFFF0AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6737673E-5898-42EC-B0B2-60DE2CFFF0AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6737673E-5898-42EC-B0B2-60DE2CFFF0AF}.Release|Any CPU.Build.0 = Release|Any CPU
{66DCB10E-1D80-4A83-8380-B2E08BEEE7AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66DCB10E-1D80-4A83-8380-B2E08BEEE7AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66DCB10E-1D80-4A83-8380-B2E08BEEE7AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66DCB10E-1D80-4A83-8380-B2E08BEEE7AE}.Release|Any CPU.Build.0 = Release|Any CPU
{96977D99-BF4B-4952-B594-6E44CCD826B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{96977D99-BF4B-4952-B594-6E44CCD826B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{96977D99-BF4B-4952-B594-6E44CCD826B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{96977D99-BF4B-4952-B594-6E44CCD826B9}.Release|Any CPU.Build.0 = Release|Any CPU
{B8D0772A-FAD1-49AD-A85B-B2B6C5B14420}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8D0772A-FAD1-49AD-A85B-B2B6C5B14420}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B8D0772A-FAD1-49AD-A85B-B2B6C5B14420}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B8D0772A-FAD1-49AD-A85B-B2B6C5B14420}.Release|Any CPU.Build.0 = Release|Any CPU
{F2C1FB09-D01D-4E8B-B6BE-B548AB00187B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2C1FB09-D01D-4E8B-B6BE-B548AB00187B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2C1FB09-D01D-4E8B-B6BE-B548AB00187B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2C1FB09-D01D-4E8B-B6BE-B548AB00187B}.Release|Any CPU.Build.0 = Release|Any CPU
{EC1570A4-18B9-4A76-84FF-275BAA76A357}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC1570A4-18B9-4A76-84FF-275BAA76A357}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC1570A4-18B9-4A76-84FF-275BAA76A357}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC1570A4-18B9-4A76-84FF-275BAA76A357}.Release|Any CPU.Build.0 = Release|Any CPU
{81CCE07D-818D-4153-8486-5D2A860C4D9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{81CCE07D-818D-4153-8486-5D2A860C4D9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{81CCE07D-818D-4153-8486-5D2A860C4D9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81CCE07D-818D-4153-8486-5D2A860C4D9D}.Release|Any CPU.Build.0 = Release|Any CPU
{F2A6F6B9-5D36-4416-BDD8-C7D30EE3ED4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2A6F6B9-5D36-4416-BDD8-C7D30EE3ED4A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2A6F6B9-5D36-4416-BDD8-C7D30EE3ED4A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2A6F6B9-5D36-4416-BDD8-C7D30EE3ED4A}.Release|Any CPU.Build.0 = Release|Any CPU
{07E2C578-8644-474D-8F07-B25CFEB28408}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{07E2C578-8644-474D-8F07-B25CFEB28408}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07E2C578-8644-474D-8F07-B25CFEB28408}.Release|Any CPU.ActiveCfg = Release|Any CPU
{07E2C578-8644-474D-8F07-B25CFEB28408}.Release|Any CPU.Build.0 = Release|Any CPU
{930B3AB7-56EA-48D6-B603-24D79C7DD00A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{930B3AB7-56EA-48D6-B603-24D79C7DD00A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{930B3AB7-56EA-48D6-B603-24D79C7DD00A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{930B3AB7-56EA-48D6-B603-24D79C7DD00A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
60 changes: 0 additions & 60 deletions benchmarks/NexusMods.EventSourcing.Benchmarks/ABenchmark.cs

This file was deleted.

This file was deleted.

29 changes: 29 additions & 0 deletions benchmarks/NexusMods.EventSourcing.Benchmarks/AppHost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using NexusMods.EventSourcing.Benchmarks.Model;
using NexusMods.EventSourcing.DatomStore;
using NexusMods.Paths;

namespace NexusMods.EventSourcing.Benchmarks;

public static class AppHost
{
public static IServiceProvider Create()
{
var builder = Host.CreateDefaultBuilder()
.ConfigureServices(services =>
{
services.AddDatomStore()
.AddEventSourcing()
.AddFileModel()
.AddSingleton(new DatomStoreSettings()
{
Path = FileSystem.Shared.GetKnownPath(KnownPath.TempDirectory).Combine(Guid.NewGuid() + ".rocksdb")
});
});

return builder.Build().Services;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System.Collections.Generic;
using System.Linq;
using BenchmarkDotNet.Attributes;
using Microsoft.Extensions.DependencyInjection;
using NexusMods.EventSourcing.Abstractions;
using NexusMods.EventSourcing.Benchmarks.Model;

namespace NexusMods.EventSourcing.Benchmarks.Benchmarks;

public class ReadTests
{
private readonly IConnection _connection;
private readonly List<EntityId> _entityIds;

public ReadTests()
{
var services = AppHost.Create();

_connection = services.GetRequiredService<IConnection>();
_entityIds = new List<EntityId>();
}

[GlobalSetup]
public void Setup()
{
var tx = _connection.BeginTransaction();
_entityIds.Clear();
for (var i = 0; i < Count; i++)
{
var id = Ids.MakeId(Ids.Partition.Entity, (ulong)i);
File.Hash.Assert(tx.TempId(), (ulong)i, tx);
File.Path.Assert(tx.TempId(), $"C:\\test_{i}.txt", tx);
File.Index.Assert(tx.TempId(), (ulong)i, tx);
_entityIds.Add(EntityId.From(id));
}
tx.Commit();
}


[Params(1, 10, 100, 1000)]
public int Count { get; set; } = 1000;

[Benchmark]
public int ReadFiles()
{
var db = _connection.Db;
var read = db.Get<Model.FileReadModel>(_entityIds).ToList();
return read.Count;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using BenchmarkDotNet.Attributes;
using Microsoft.Extensions.DependencyInjection;
using NexusMods.EventSourcing.Abstractions;
using NexusMods.EventSourcing.Benchmarks.Model;

namespace NexusMods.EventSourcing.Benchmarks.Benchmarks;

public class WriteTests
{
private readonly IConnection _connection;

public WriteTests()
{
var services = AppHost.Create();

_connection = services.GetRequiredService<IConnection>();
}


[Params(1, 10, 100, 1000)]
public int Count { get; set; } = 1000;

[Benchmark]
public void AddFiles()
{
var tx = _connection.BeginTransaction();
for (var i = 0; i < Count; i++)
{
var id = Ids.MakeId(Ids.Partition.Entity, (ulong)i);
File.Hash.Assert(tx.TempId(), (ulong)i, tx);
File.Path.Assert(tx.TempId(), $"C:\\test_{i}.txt", tx);
File.Index.Assert(tx.TempId(), (ulong)i, tx);
}
tx.Commit();
}

}

This file was deleted.

Loading

0 comments on commit c7fdca6

Please sign in to comment.