Skip to content

Commit 8ca47d2

Browse files
authored
Merge branch 'main' into users/alexpeck/arm64
2 parents 865156b + 25ea2bd commit 8ca47d2

35 files changed

+446
-423
lines changed

.github/workflows/benchpr.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ jobs:
3939
run: dotnet build splitasm --configuration Release
4040
- name: Benchmark
4141
run: dotnet run --project "BitFaster.Caching.Benchmarks" -f net6.0 -c Release --filter '*'
42-
- name: Plot results
43-
run: dotnet run --project "Tools\BenchPlot\Benchplot.csproj" --configuration Release "BenchmarkDotNet.Artifacts"
4442
- name: Post process disassembly
4543
run: splitasm\splitasm\bin\Release\net6.0\splitasm.exe %GITHUB_WORKSPACE%\BenchmarkDotNet.Artifacts\results
4644
shell: cmd
@@ -68,8 +66,6 @@ jobs:
6866
run: dotnet build --configuration Release --no-restore
6967
- name: Benchmark
7068
run: dotnet run --project "BitFaster.Caching.Benchmarks" -f net6.0 -c Release --filter '*'
71-
- name: Plot results
72-
run: dotnet run --project Tools/BenchPlot/BenchPlot.csproj --configuration Release "BenchmarkDotNet.Artifacts"
7369
- name: Publish Results
7470
uses: actions/upload-artifact@v3
7571
with:
@@ -94,8 +90,6 @@ jobs:
9490
run: dotnet build --configuration Release --no-restore
9591
- name: Benchmark
9692
run: dotnet run --project "BitFaster.Caching.Benchmarks" -f net6.0 -c Release --filter '*'
97-
- name: Plot results
98-
run: dotnet run --project "Tools\BenchPlot\BenchPlot.csproj" --configuration Release "BenchmarkDotNet.Artifacts"
9993
- name: Publish Results
10094
uses: actions/upload-artifact@v3
10195
with:

BitFaster.Caching.Benchmarks/BitFaster.Caching.Benchmarks.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
</PropertyGroup>
2020

2121
<ItemGroup>
22-
<PackageReference Include="Benchly" Version="0.6.1" />
23-
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
24-
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.13.12" />
22+
<PackageReference Include="Benchly" Version="0.7.0" />
23+
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
24+
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.14.0" />
2525
<PackageReference Include="MathNet.Numerics" Version="5.0.0" />
26-
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
27-
<PackageReference Include="System.Runtime.Caching" Version="8.0.0" />
26+
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.0" />
27+
<PackageReference Include="System.Runtime.Caching" Version="8.0.1" />
2828
</ItemGroup>
2929

3030
<ItemGroup>

BitFaster.Caching.Benchmarks/Lfu/LfuJustGetOrAdd.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,38 +44,38 @@ public void GlobalCleanup()
4444
}
4545

4646
[Benchmark(Baseline = true)]
47-
public void ConcurrentDictionary()
47+
public int ConcurrentDictionary()
4848
{
4949
Func<int, int> func = x => x;
50-
dictionary.GetOrAdd(1, func);
50+
return dictionary.GetOrAdd(1, func);
5151
}
5252

5353
[Benchmark()]
54-
public void ConcurrentLfuBackground()
54+
public int ConcurrentLfuBackground()
5555
{
5656
Func<int, int> func = x => x;
57-
concurrentLfu.GetOrAdd(1, func);
57+
return concurrentLfu.GetOrAdd(1, func);
5858
}
5959

6060
[Benchmark()]
61-
public void ConcurrentLfuForeround()
61+
public int ConcurrentLfuForeround()
6262
{
6363
Func<int, int> func = x => x;
64-
concurrentLfuFore.GetOrAdd(1, func);
64+
return concurrentLfuFore.GetOrAdd(1, func);
6565
}
6666

6767
[Benchmark()]
68-
public void ConcurrentLfuThreadPool()
68+
public int ConcurrentLfuThreadPool()
6969
{
7070
Func<int, int> func = x => x;
71-
concurrentLfuTp.GetOrAdd(1, func);
71+
return concurrentLfuTp.GetOrAdd(1, func);
7272
}
7373

7474
[Benchmark()]
75-
public void ConcurrentLfuNull()
75+
public int ConcurrentLfuNull()
7676
{
7777
Func<int, int> func = x => x;
78-
concurrentLfuNull.GetOrAdd(1, func);
78+
return concurrentLfuNull.GetOrAdd(1, func);
7979
}
8080
}
8181
}

BitFaster.Caching.Benchmarks/Lru/LruJustGetOrAdd.cs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ Microsoft.Extensions.Caching.Memory.MemoryCache exMemoryCache
6666
[GlobalSetup]
6767
public void GlobalSetup()
6868
{
69-
memoryCache.Set(key.ToString(), "test", new System.Runtime.Caching.CacheItemPolicy());
70-
exMemoryCache.Set(key, "test");
69+
memoryCache.Set(key.ToString(), 1, new System.Runtime.Caching.CacheItemPolicy());
70+
exMemoryCache.Set(key, 1);
7171
}
7272

7373
[GlobalCleanup]
@@ -77,85 +77,85 @@ public void GlobalCleanup()
7777
}
7878

7979
[Benchmark(Baseline = true)]
80-
public void ConcurrentDictionary()
80+
public int ConcurrentDictionary()
8181
{
8282
Func<int, int> func = x => x;
83-
dictionary.GetOrAdd(1, func);
83+
return dictionary.GetOrAdd(1, func);
8484
}
8585

8686
[Benchmark()]
87-
public void FastConcurrentLru()
87+
public int FastConcurrentLru()
8888
{
8989
Func<int, int> func = x => x;
90-
fastConcurrentLru.GetOrAdd(1, func);
90+
return fastConcurrentLru.GetOrAdd(1, func);
9191
}
9292

9393
[Benchmark()]
94-
public void ConcurrentLru()
94+
public int ConcurrentLru()
9595
{
9696
Func<int, int> func = x => x;
97-
concurrentLru.GetOrAdd(1, func);
97+
return concurrentLru.GetOrAdd(1, func);
9898
}
9999

100100
[Benchmark()]
101-
public void AtomicFastLru()
101+
public int AtomicFastLru()
102102
{
103103
Func<int, int> func = x => x;
104-
atomicFastLru.GetOrAdd(1, func);
104+
return atomicFastLru.GetOrAdd(1, func);
105105
}
106106

107107
[Benchmark()]
108-
public void FastConcurrentTLru()
108+
public int FastConcurrentTLru()
109109
{
110110
Func<int, int> func = x => x;
111-
fastConcurrentTLru.GetOrAdd(1, func);
111+
return fastConcurrentTLru.GetOrAdd(1, func);
112112
}
113113

114114
[Benchmark()]
115-
public void FastConcLruAfterAccess()
115+
public int FastConcLruAfterAccess()
116116
{
117117
Func<int, int> func = x => x;
118-
lruAfterAccess.GetOrAdd(1, func);
118+
return lruAfterAccess.GetOrAdd(1, func);
119119
}
120120

121121
[Benchmark()]
122-
public void FastConcLruAfter()
122+
public int FastConcLruAfter()
123123
{
124124
Func<int, int> func = x => x;
125-
lruAfter.GetOrAdd(1, func);
125+
return lruAfter.GetOrAdd(1, func);
126126
}
127127

128128
[Benchmark()]
129-
public void ConcurrentTLru()
129+
public int ConcurrentTLru()
130130
{
131131
Func<int, int> func = x => x;
132-
concurrentTlru.GetOrAdd(1, func);
132+
return concurrentTlru.GetOrAdd(1, func);
133133
}
134134

135135
[Benchmark()]
136-
public void ConcurrentLfu()
136+
public int ConcurrentLfu()
137137
{
138138
Func<int, int> func = x => x;
139-
concurrentLfu.GetOrAdd(1, func);
139+
return concurrentLfu.GetOrAdd(1, func);
140140
}
141141

142142
[Benchmark()]
143-
public void ClassicLru()
143+
public int ClassicLru()
144144
{
145145
Func<int, int> func = x => x;
146-
classicLru.GetOrAdd(1, func);
146+
return classicLru.GetOrAdd(1, func);
147147
}
148148

149149
[Benchmark()]
150-
public void RuntimeMemoryCacheGet()
150+
public int RuntimeMemoryCacheGet()
151151
{
152-
memoryCache.Get("1");
152+
return (int)memoryCache.Get("1");
153153
}
154154

155155
[Benchmark()]
156-
public void ExtensionsMemoryCacheGet()
156+
public int ExtensionsMemoryCacheGet()
157157
{
158-
exMemoryCache.Get(1);
158+
return (int)exMemoryCache.Get(1);
159159
}
160160

161161
public class MemoryCacheOptionsAccessor

BitFaster.Caching.HitRateAnalysis/BitFaster.Caching.HitRateAnalysis.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="ConsoleTables" Version="2.6.1" />
22-
<PackageReference Include="CsvHelper" Version="32.0.3" />
21+
<PackageReference Include="ConsoleTables" Version="2.6.2" />
22+
<PackageReference Include="CsvHelper" Version="33.0.1" />
2323
<PackageReference Include="EasyConsole" Version="1.1.0">
2424
<NoWarn>NU1701</NoWarn>
2525
</PackageReference>
26-
<PackageReference Include="GitInfo" Version="3.3.5">
26+
<PackageReference Include="GitInfo" Version="3.5.0">
2727
<PrivateAssets>all</PrivateAssets>
2828
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2929
</PackageReference>
3030
<PackageReference Include="MathNet.Numerics" Version="5.0.0" />
31-
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
32-
<PackageReference Include="Plotly.NET.CSharp" Version="0.11.1" />
33-
<PackageReference Include="Plotly.NET.ImageExport" Version="5.0.1" />
31+
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.0" />
32+
<PackageReference Include="Plotly.NET.CSharp" Version="0.13.0" />
33+
<PackageReference Include="Plotly.NET.ImageExport" Version="6.1.0" />
3434
</ItemGroup>
3535

3636
<ItemGroup>

BitFaster.Caching.HitRateAnalysis/PlotExt.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,26 @@ namespace BitFaster.Caching.HitRateAnalysis
88
{
99
public static class PlotExt
1010
{
11-
public static GenericChart.GenericChart WithAxisTitles(this GenericChart.GenericChart chart, string xTitle, string yTitle)
11+
public static GenericChart WithAxisTitles(this GenericChart chart, string xTitle, string yTitle)
1212
{
1313
var font = new FSharpOption<Font>(Font.init(Size: new FSharpOption<double>(16)));
1414
FSharpOption<string> xt = new FSharpOption<string>(xTitle);
1515
FSharpOption<string> yt = new FSharpOption<string>(yTitle);
1616
return chart.WithXAxisStyle(Title.init(xt, Font: font)).WithYAxisStyle(Title.init(yt, Font: font));
1717
}
1818

19-
public static GenericChart.GenericChart WithoutVerticalGridlines(this GenericChart.GenericChart chart)
19+
public static GenericChart WithoutVerticalGridlines(this GenericChart chart)
2020
{
2121
var gridColor = new FSharpOption<Color>(Color.fromKeyword(ColorKeyword.Gainsboro));
22-
var yaxis = LinearAxis.init<IConvertible, IConvertible, IConvertible, IConvertible, IConvertible, IConvertible>(
22+
var yaxis = LinearAxis.init<IConvertible, IConvertible, IConvertible, IConvertible, IConvertible, IConvertible, IConvertible, IConvertible>(
2323
GridColor: gridColor,
2424
ZeroLineColor: gridColor);
2525

26-
var axis = LinearAxis.init<IConvertible, IConvertible, IConvertible, IConvertible, IConvertible, IConvertible>(ShowGrid: new FSharpOption<bool>(false));
26+
var axis = LinearAxis.init<IConvertible, IConvertible, IConvertible, IConvertible, IConvertible, IConvertible, IConvertible, IConvertible>(ShowGrid: new FSharpOption<bool>(false));
2727
return chart.WithXAxis(axis).WithYAxis(yaxis);
2828
}
2929

30-
public static GenericChart.GenericChart WithLayout(this GenericChart.GenericChart chart, string title)
30+
public static GenericChart WithLayout(this GenericChart chart, string title)
3131
{
3232
var font = new FSharpOption<Font>(Font.init(Size: new FSharpOption<double>(24)));
3333
FSharpOption<Title> t = Title.init(Text: title, X: 0.5, Font: font);

BitFaster.Caching.ThroughputAnalysis/BitFaster.Caching.ThroughputAnalysis.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@
1616
</PropertyGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
20-
<PackageReference Include="ConsoleTables" Version="2.6.1" />
21-
<PackageReference Include="CsvHelper" Version="32.0.3" />
19+
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
20+
<PackageReference Include="ConsoleTables" Version="2.6.2" />
21+
<PackageReference Include="CsvHelper" Version="33.0.1" />
2222
<PackageReference Include="EasyConsole" Version="1.1.0">
2323
<NoWarn>NU1701</NoWarn>
2424
</PackageReference>
25-
<PackageReference Include="GitInfo" Version="3.3.5">
25+
<PackageReference Include="GitInfo" Version="3.5.0">
2626
<PrivateAssets>all</PrivateAssets>
2727
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2828
</PackageReference>
29-
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
30-
<PackageReference Include="Plotly.NET" Version="4.2.0" />
31-
<PackageReference Include="Plotly.NET.ImageExport" Version="5.0.1" />
29+
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.0" />
30+
<PackageReference Include="Plotly.NET" Version="5.1.0" />
31+
<PackageReference Include="Plotly.NET.ImageExport" Version="6.1.0" />
3232
</ItemGroup>
3333

3434
<ItemGroup>

BitFaster.Caching.ThroughputAnalysis/Exporter.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void ExportPlot(Mode mode, int cacheSize)
8080
columns.Add(int.Parse(resultTable.Columns[i].ColumnName));
8181
}
8282

83-
List<GenericChart.GenericChart> charts = new List<GenericChart.GenericChart>();
83+
List<GenericChart> charts = new List<GenericChart>();
8484

8585
foreach (DataRow row in resultTable.Rows)
8686
{
@@ -165,26 +165,26 @@ public Color MapColor(string name)
165165

166166
public static class PlotExt
167167
{
168-
public static GenericChart.GenericChart WithAxisTitles(this GenericChart.GenericChart chart, string xTitle, string yTitle)
168+
public static GenericChart WithAxisTitles(this GenericChart chart, string xTitle, string yTitle)
169169
{
170170
var font = new FSharpOption<Font>(Font.init(Size: new FSharpOption<double>(16)));
171171
FSharpOption<string> xt = new FSharpOption<string>(xTitle);
172172
FSharpOption<string> yt = new FSharpOption<string>(yTitle);
173173
return chart.WithXAxisStyle(Title.init(xt, Font: font)).WithYAxisStyle(Title.init(yt, Font: font));
174174
}
175175

176-
public static GenericChart.GenericChart WithoutVerticalGridlines(this GenericChart.GenericChart chart)
176+
public static GenericChart WithoutVerticalGridlines(this GenericChart chart)
177177
{
178178
var gridColor = new FSharpOption<Color>(Color.fromKeyword(ColorKeyword.Gainsboro));
179-
var yaxis = LinearAxis.init<IConvertible, IConvertible, IConvertible, IConvertible, IConvertible, IConvertible>(
179+
var yaxis = LinearAxis.init<IConvertible, IConvertible, IConvertible, IConvertible, IConvertible, IConvertible, IConvertible, IConvertible>(
180180
GridColor: gridColor,
181181
ZeroLineColor: gridColor);
182182

183-
var axis = LinearAxis.init<IConvertible, IConvertible, IConvertible, IConvertible, IConvertible, IConvertible>(ShowGrid: new FSharpOption<bool>(false));
183+
var axis = LinearAxis.init<IConvertible, IConvertible, IConvertible, IConvertible, IConvertible, IConvertible, IConvertible, IConvertible>(ShowGrid: new FSharpOption<bool>(false));
184184
return chart.WithXAxis(axis).WithYAxis(yaxis);
185185
}
186186

187-
public static GenericChart.GenericChart WithLayout(this GenericChart.GenericChart chart, string title)
187+
public static GenericChart WithLayout(this GenericChart chart, string title)
188188
{
189189
var font = new FSharpOption<Font>(Font.init(Size: new FSharpOption<double>(24)));
190190
FSharpOption<Title> t = Title.init(Text: title, X: 0.5, Font: font);

BitFaster.Caching.ThroughputAnalysis/MeasurementsStatistics.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public static MeasurementsStatistics Calculate(List<double> measurements, Outlie
4242
double variance = Variance(measurements, n, mean);
4343
double standardDeviation = Math.Sqrt(variance);
4444
double standardError = standardDeviation / Math.Sqrt(n);
45-
var confidenceInterval = new ConfidenceInterval(mean, standardError, n);
45+
var confidenceIntervalEstimator = new ConfidenceIntervalEstimator(n, mean, standardError);
46+
var confidenceInterval = confidenceIntervalEstimator.ConfidenceInterval(ConfidenceLevel.L999);
4647

4748
if (outlierMode == OutlierMode.DontRemove) // most simple scenario is done without allocations! but this is not the default case
4849
return new MeasurementsStatistics(standardError, mean, confidenceInterval);
@@ -69,7 +70,8 @@ public static MeasurementsStatistics Calculate(List<double> measurements, Outlie
6970
variance = VarianceWithoutOutliers(outlierMode, measurements, n, mean, lowerFence, upperFence);
7071
standardDeviation = Math.Sqrt(variance);
7172
standardError = standardDeviation / Math.Sqrt(n);
72-
confidenceInterval = new ConfidenceInterval(mean, standardError, n);
73+
confidenceIntervalEstimator = new ConfidenceIntervalEstimator(n, mean, standardError);
74+
confidenceInterval = confidenceIntervalEstimator.ConfidenceInterval(ConfidenceLevel.L999);
7375

7476
return new MeasurementsStatistics(standardError, mean, confidenceInterval);
7577
}

BitFaster.Caching.UnitTests.Std/BitFaster.Caching.UnitTests.Std.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
9+
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
1010
<PrivateAssets>all</PrivateAssets>
1111
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1212
</PackageReference>
13-
<PackageReference Include="FluentAssertions" Version="6.12.0" />
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
13+
<PackageReference Include="FluentAssertions" Version="6.12.2" />
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
1515
<PackageReference Include="Moq" Version="4.20.70" />
1616
<PackageReference Include="ObjectLayoutInspector" Version="0.1.4" />
17-
<PackageReference Include="xunit" Version="2.8.1" />
17+
<PackageReference Include="xunit" Version="2.9.2" />
1818
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
1919
<PrivateAssets>all</PrivateAssets>
2020
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

0 commit comments

Comments
 (0)