Skip to content

Commit

Permalink
Merge branch 'main' into importer
Browse files Browse the repository at this point in the history
  • Loading branch information
Scooletz committed Jun 26, 2024
2 parents f5359ac + 77eb75f commit 22b2a9c
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 74 deletions.
2 changes: 1 addition & 1 deletion src/Paprika.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class StatisticsSettings : CommandSettings
public string Path { get; set; }

[CommandArgument(1, "<size>")]
public byte Size { get; set; }
public int Size { get; set; }

[CommandArgument(1, "<historyDepth>")]
public byte HistoryDepth { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/Paprika.Tests/Chain/BlockchainTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public async Task Account_destruction_same_block()
[Category(Categories.LongRunning)]
public async Task Account_destruction_spin()
{
using var db = PagedDb.NativeMemoryDb(8 * Mb, 2);
using var db = PagedDb.NativeMemoryDb(10 * Mb, 2);
await using var blockchain = new Blockchain(db, new ComputeMerkleBehavior());

var parent = Keccak.EmptyTreeHash;
Expand Down
2 changes: 1 addition & 1 deletion src/Paprika.Tests/Chain/RawTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public async Task Disposal()
{
var account = Values.Key1;

using var db = PagedDb.NativeMemoryDb(256 * 1024, 2);
using var db = PagedDb.NativeMemoryDb(512 * 1024, 2);
var merkle = new ComputeMerkleBehavior();

await using var blockchain = new Blockchain(db, merkle);
Expand Down
12 changes: 6 additions & 6 deletions src/Paprika.Tests/Store/AbandonedTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ public void Properly_handles_page_addresses_that_are_packed_2()

private const int HistoryDepth = 2;

[TestCase(20, 1, 10_000, false, TestName = "Accounts - 1")]
[TestCase(464, 100, 10_000, false, TestName = "Accounts - 100")]
[TestCase(24533, 4000, 200, false,
[TestCase(22, 1, 10_000, false, TestName = "Accounts - 1")]
[TestCase(466, 100, 10_000, false, TestName = "Accounts - 100")]
[TestCase(24535, 4000, 200, false,
TestName = "Accounts - 4000 to get a bit reuse",
Category = Categories.LongRunning)]
[TestCase(68419, 10_000, 50, false,
[TestCase(68421, 10_000, 50, false,
TestName = "Accounts - 10000 to breach the AbandonedPage",
Category = Categories.LongRunning)]
[TestCase(98577, 20_000, 50, true,
[TestCase(98579, 20_000, 50, true,
TestName = "Storage - 20_000 accounts with a single storage slot",
Category = Categories.LongRunning)]
public async Task Reuse_in_limited_environment(int pageCount, int accounts, int repeats, bool isStorage)
Expand Down Expand Up @@ -189,7 +189,7 @@ public async Task Work_proper_bookkeeping_when_lots_of_reads()

byte[] value = [13];

using var db = PagedDb.NativeMemoryDb((multiplier * repeats + historyDepth) * Page.PageSize);
using var db = PagedDb.NativeMemoryDb((multiplier * repeats + historyDepth * PagedDb.DbPagesPerRoot) * Page.PageSize);

var reads = new List<IReadOnlyBatch>();

Expand Down
6 changes: 5 additions & 1 deletion src/Paprika/Store/AbandonedList.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Paprika.Store;
Expand All @@ -16,7 +17,7 @@ public struct AbandonedList
/// </summary>
private const int EntriesStart = DbAddress.Size + sizeof(uint);

public const int Size = Page.PageSize - PageHeader.Size - RootPage.Payload.AbandonedStart - EntriesStart;
public const int Size = Page.PageSize;
private const int EntrySize = sizeof(uint) + DbAddress.Size;
private const int MaxCount = (Size - EntriesStart) / EntrySize;

Expand Down Expand Up @@ -254,4 +255,7 @@ public bool IsFullyEmpty
}

public DbAddress GetCurrentForTest() => Current;

public static ref AbandonedList Wrap(Page page) =>
ref Unsafe.As<byte, AbandonedList>(ref MemoryMarshal.GetReference(page.Span));
}
4 changes: 2 additions & 2 deletions src/Paprika/Store/PageManagers/NativeMemoryPageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ public sealed unsafe class NativeMemoryPageManager : PointerPageManager

public NativeMemoryPageManager(long size, byte historyDepth) : base(size)
{
_ptr = NativeMemory.AlignedAlloc((UIntPtr)size, (UIntPtr)Page.PageSize);
_ptr = NativeMemory.AlignedAlloc((UIntPtr)size, Page.PageSize);

// clear first pages to make it clean
for (var i = 0; i < historyDepth; i++)
for (var i = 0; i < historyDepth * PagedDb.DbPagesPerRoot; i++)
{
GetAt(new DbAddress((uint)i)).Clear();
}
Expand Down
Loading

0 comments on commit 22b2a9c

Please sign in to comment.