Skip to content

Commit

Permalink
Prefetching for Report in pages (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
Scooletz authored Jun 10, 2024
1 parent fd332bb commit a22ab75
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Paprika/Store/DataPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ private static bool TryGet(IReadOnlyBatchContext batch, scoped in NibblePath key

public void Report(IReporter reporter, IPageResolver resolver, int pageLevel, int trimmedNibbles)
{
resolver.Prefetch(Data.Buckets);

var slotted = new SlottedArray(Data.DataSpan);
reporter.ReportDataUsage(Header.PageType, pageLevel, trimmedNibbles, slotted);

foreach (var bucket in Data.Buckets)
{
if (!bucket.IsNull)
Expand All @@ -315,8 +320,7 @@ public void Report(IReporter reporter, IPageResolver resolver, int pageLevel, in
}
}

var slotted = new SlottedArray(Data.DataSpan);
reporter.ReportDataUsage(Header.PageType, pageLevel, trimmedNibbles, slotted);

}

public void Accept(IPageVisitor visitor, IPageResolver resolver, DbAddress addr)
Expand Down
12 changes: 12 additions & 0 deletions src/Paprika/Store/IBatchContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,17 @@ public interface IPageResolver
/// Gets the page at given address.
/// </summary>
Page GetAt(DbAddress address);

void Prefetch(DbAddress address);

void Prefetch(ReadOnlySpan<DbAddress> addresses)
{
foreach (var bucket in addresses)
{
if (!bucket.IsNull)
{
Prefetch(bucket);
}
}
}
}
2 changes: 2 additions & 0 deletions src/Paprika/Store/LeafPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ public void Report(IReporter reporter, IPageResolver resolver, int pageLevel, in

public void Accept(IPageVisitor visitor, IPageResolver resolver, DbAddress addr)
{
resolver.Prefetch(Data.Buckets);

using var scope = visitor.On(this, addr);

foreach (var bucket in Data.Buckets)
Expand Down
2 changes: 2 additions & 0 deletions src/Paprika/Store/StorageFanOutPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public void Report(IReporter reporter, IPageResolver resolver, int pageLevel, in

public void Accept(IPageVisitor visitor, IPageResolver resolver, DbAddress addr)
{
resolver.Prefetch(Data.Addresses);

using var scope = visitor.On(this, addr);

foreach (var bucket in Data.Addresses)
Expand Down

0 comments on commit a22ab75

Please sign in to comment.