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 Mar 6, 2024
2 parents 77f701c + 3506723 commit f77097d
Show file tree
Hide file tree
Showing 121 changed files with 672 additions and 498 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Set default behavior to automatically normalize line endings.
* text=auto eol=lf
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:

jobs:
tests:
timeout-minutes: 10
timeout-minutes: 15
name: "Run Paprika tests"
runs-on: ubuntu-latest
permissions:
Expand Down
4 changes: 2 additions & 2 deletions src/Paprika.Benchmarks/MerkleBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Attributes;
using Paprika.Crypto;
using Paprika.Data;
using Paprika.Merkle;
Expand Down Expand Up @@ -52,4 +52,4 @@ public byte Storage_short_path()
// prevent not used result elimination
return result.Span[0];
}
}
}
4 changes: 2 additions & 2 deletions src/Paprika.Benchmarks/NibblePathBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Attributes;
using Paprika.Crypto;
using Paprika.Data;

Expand All @@ -24,4 +24,4 @@ public int Hash()
path.GetHashCode() ^
path.GetHashCode();
}
}
}
4 changes: 2 additions & 2 deletions src/Paprika.Benchmarks/PooledSpanDictionaryBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Attributes;
using Paprika.Chain;

namespace Paprika.Benchmarks;
Expand Down Expand Up @@ -31,4 +31,4 @@ public int Read_write_small()

return count;
}
}
}
4 changes: 2 additions & 2 deletions src/Paprika.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// See https://aka.ms/new-console-template for more information
// See https://aka.ms/new-console-template for more information

using System.Diagnostics.CodeAnalysis;
using BenchmarkDotNet.Running;
Expand All @@ -13,4 +13,4 @@ public static void Main(string[] args)
{
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
}
}
}
4 changes: 2 additions & 2 deletions src/Paprika.Benchmarks/SlottedArrayBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Buffers.Binary;
using System.Buffers.Binary;
using BenchmarkDotNet.Attributes;
using Paprika.Data;
using Paprika.Store;
Expand Down Expand Up @@ -95,4 +95,4 @@ public int Read_nonexistent_keys()

return result;
}
}
}
6 changes: 3 additions & 3 deletions src/Paprika.Benchmarks/XorBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
using BenchmarkDotNet.Attributes;
using Paprika.Utils;

Expand All @@ -18,7 +18,7 @@ public void Setup()

_keys = new ulong[Size];
random.NextBytes(MemoryMarshal.Cast<ulong, byte>(_keys));
_xor8 = new Xor8(_keys);
_xor8 = new Xor8(_keys.ToHashSet());
}

[Benchmark]
Expand All @@ -32,4 +32,4 @@ public bool MayContain()

return accumulator;
}
}
}
4 changes: 2 additions & 2 deletions src/Paprika.Cli/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics;
using System.Diagnostics;
using Paprika.Chain;
using Paprika.Merkle;
using Paprika.Store;
Expand Down Expand Up @@ -66,4 +66,4 @@ public override async Task<int> ExecuteAsync(CommandContext context, ValidateRoo

return -1;
}
}
}
4 changes: 2 additions & 2 deletions src/Paprika.Importer/PaprikaAccountValidatingVisitor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// using System.Runtime.CompilerServices;
// using System.Runtime.CompilerServices;
// using System.Text;
// using System.Threading.Channels;
// using Nethermind.Core.Crypto;
Expand Down Expand Up @@ -173,4 +173,4 @@
// public void Dispose()
// {
// }
// }
// }
4 changes: 2 additions & 2 deletions src/Paprika.Importer/PaprikaCopyingVisitor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics.Metrics;
using System.Diagnostics.Metrics;
using System.Runtime.CompilerServices;
using System.Threading.Channels;
using Nethermind.Core.Crypto;
Expand Down Expand Up @@ -243,4 +243,4 @@ public void VisitLeaf(in PathContext nodeContext, TrieNode node, TrieVisitContex
public void VisitCode(in PathContext nodeContext, Hash256 codeHash, TrieVisitContext trieVisitContext)
{
}
}
}
4 changes: 2 additions & 2 deletions src/Paprika.Importer/PaprikaRootValidatingVisitor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// using System.Diagnostics.Metrics;
// using System.Diagnostics.Metrics;
// using System.Runtime.CompilerServices;
// using System.Threading.Channels;
// using Nethermind.Core.Crypto;
Expand Down Expand Up @@ -164,4 +164,4 @@
// {
// _meter.Dispose();
// }
// }
// }
4 changes: 2 additions & 2 deletions src/Paprika.Importer/PaprikaStorageCapturingVisitor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// using System.Diagnostics.Metrics;
// using System.Diagnostics.Metrics;
// using System.Runtime.CompilerServices;
// using System.Runtime.InteropServices;
// using System.Text;
Expand Down Expand Up @@ -42,4 +42,4 @@
// }
//
// public string Payload => _sb.ToString();
// }
// }
4 changes: 2 additions & 2 deletions src/Paprika.Importer/PathContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
using Nethermind.Trie;
using Paprika.Data;

Expand Down Expand Up @@ -47,4 +47,4 @@ public PathContext Add(byte nibble)
}

public NibblePath AsNibblePath => NibblePath.FromKey(Span).SliceTo(Length);
}
}
4 changes: 2 additions & 2 deletions src/Paprika.Importer/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// See https://aka.ms/new-console-template for more information
// See https://aka.ms/new-console-template for more information

using System;
using System.Diagnostics;
Expand Down Expand Up @@ -233,4 +233,4 @@ static TrieNode MoveDownInTree(byte[] nibbles, PatriciaTree trie, ITrieNodeResol
root.ResolveNode(store, ReadFlags.HintCacheMiss);

return root;
}
}
4 changes: 2 additions & 2 deletions src/Paprika.Runner.Pareto/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Metrics;
using System.Runtime.InteropServices;
using Paprika.Chain;
Expand Down Expand Up @@ -221,4 +221,4 @@ private static int RandomPareto(Random random, int maxValue)
(int)(maxValue *
Math.Pow(u, 1.0 / alpha)); // Inverse of the CDF (Cumulative Distribution Function) for Pareto
}
}
}
4 changes: 2 additions & 2 deletions src/Paprika.Runner.Pareto/SingleAsyncGate.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Paprika.Runner.Pareto;
namespace Paprika.Runner.Pareto;

public sealed class SingleAsyncGate
{
Expand Down Expand Up @@ -50,4 +50,4 @@ public void Signal(uint value)

wait?.TrySetResult();
}
}
}
39 changes: 9 additions & 30 deletions src/Paprika.Runner/Measurement.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Concurrent;
using System.Collections.Concurrent;
using System.Diagnostics.Metrics;
using HdrHistogram;
using Spectre.Console;
Expand Down Expand Up @@ -70,40 +70,23 @@ public static IMeasurement Build(Instrument instrument)
throw new NotImplementedException($"Not implemented for type {type}");
}

private class GaugeMeasurement : Measurement
private class GaugeMeasurement(Instrument instrument) : Measurement(instrument)
{
public GaugeMeasurement(Instrument instrument) : base(instrument)
{
}

protected override long Update(double measurement) => (long)measurement;
}

// for now use the last value
private class HistogramLastMeasurement : Measurement
private class HistogramLastMeasurement(Instrument instrument) : Measurement(instrument)
{
protected override long Update(double measurement)
{
return (long)measurement;
}

public HistogramLastMeasurement(Instrument instrument) : base(instrument)
{
}
}

private class HistogramHdrMeasurement : JustInTimeRenderable, IMeasurement
private class HistogramHdrMeasurement(Instrument instrument) : JustInTimeRenderable, IMeasurement
{
private readonly Instrument _instrument;
private readonly ConcurrentQueue<long> _measurements;
private readonly LongHistogram _histogram;

public HistogramHdrMeasurement(Instrument instrument)
{
_instrument = instrument;
_measurements = new ConcurrentQueue<long>();
_histogram = new LongHistogram(1, 1, int.MaxValue, 4);
}
private readonly ConcurrentQueue<long> _measurements = new();
private readonly LongHistogram _histogram = new(1, 1, int.MaxValue, 4);

protected override IRenderable Build()
{
Expand Down Expand Up @@ -136,17 +119,13 @@ public void Update(double measurement, ReadOnlySpan<KeyValuePair<string, object?
MarkAsDirty();
}

public override string ToString() => $"{nameof(Instrument)}: {_instrument.Name}, Histogram";
public override string ToString() => $"{nameof(Instrument)}: {instrument.Name}, Histogram";
}

private class CounterMeasurement : Measurement
private class CounterMeasurement(Instrument instrument) : Measurement(instrument)
{
private long _sum;

protected override long Update(double measurement) => Interlocked.Add(ref _sum, (long)measurement);

public CounterMeasurement(Instrument instrument) : base(instrument)
{
}
}
}
}
4 changes: 2 additions & 2 deletions src/Paprika.Runner/MetricsReporter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics.Metrics;
using System.Diagnostics.Metrics;
using System.Runtime.InteropServices;
using Spectre.Console;
using Spectre.Console.Rendering;
Expand Down Expand Up @@ -82,4 +82,4 @@ public void Dispose()
{
_listener.Dispose();
}
}
}
4 changes: 2 additions & 2 deletions src/Paprika.Runner/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Buffers.Binary;
using System.Buffers.Binary;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
Expand Down Expand Up @@ -375,4 +375,4 @@ private static Keccak GetStorageAddress(int counter)
}

private static byte[] GetBigAccountValue(int counter) => new UInt256(1, (ulong)counter).ToBigEndian();
}
}
4 changes: 2 additions & 2 deletions src/Paprika.Runner/StatisticsForPagedDb.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Text;
using System.Text;
using HdrHistogram;
using Paprika.Store;
using Spectre.Console;
Expand Down Expand Up @@ -134,4 +134,4 @@ private static readonly (int value, string color)[] Percentiles =
new(90, "yellow"),
new(95, "red"),
};
}
}
4 changes: 2 additions & 2 deletions src/Paprika.Tests/Categories.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Paprika.Tests;
namespace Paprika.Tests;

public static class Categories
{
Expand All @@ -11,4 +11,4 @@ public static class Categories
/// The test asserts the memory using <see cref="JetBrains.dotMemoryUnit"/> capabilities.
/// </summary>
public const string Memory = nameof(Memory);
}
}
Loading

0 comments on commit f77097d

Please sign in to comment.