Skip to content

Commit ae1d567

Browse files
committed
512
1 parent 560c6f2 commit ae1d567

File tree

5 files changed

+365
-5
lines changed

5 files changed

+365
-5
lines changed

BitFaster.Caching.Benchmarks/Lfu/SketchFrequency.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class SketchFrequency
2828
private CmSketchNoPin<int, DetectIsa> blockAvxNoPin;
2929
private CmSketchPinNoOpt<int, DetectIsa> blockAvxPinNoOpt;
3030
private CmSketchCore<int, DetectIsa> blockAvx;
31+
private CmSketchCore512<int, DetectIsa> blockAvx512;
3132

3233
[Params(512, 1024, 32_768, 524_288, 8_388_608, 134_217_728)]
3334
public int Size { get; set; }
@@ -42,6 +43,7 @@ public void Setup()
4243
blockAvxNoPin = new CmSketchNoPin<int, DetectIsa>(Size, EqualityComparer<int>.Default);
4344
blockAvxPinNoOpt = new CmSketchPinNoOpt<int, DetectIsa>(Size, EqualityComparer<int>.Default);
4445
blockAvx = new CmSketchCore<int, DetectIsa>(Size, EqualityComparer<int>.Default);
46+
blockAvx512 = new CmSketchCore512<int, DetectIsa>(Size, EqualityComparer<int>.Default);
4547
}
4648

4749
[Benchmark(Baseline = true, OperationsPerInvoke = iterations)]
@@ -103,5 +105,15 @@ public int FrequencyBlockAvxPinned()
103105

104106
return count;
105107
}
108+
109+
[Benchmark(OperationsPerInvoke = iterations)]
110+
public int FrequencyBlockAvxPinned512()
111+
{
112+
int count = 0;
113+
for (int i = 0; i < iterations; i++)
114+
count += blockAvx512.EstimateFrequency(i) > blockAvx.EstimateFrequency(i + 1) ? 1 : 0;
115+
116+
return count;
117+
}
106118
}
107119
}

BitFaster.Caching.Benchmarks/Lfu/SketchIncrement.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class SketchIncrement
2727
private CmSketchNoPin<int, DetectIsa> blockAvxNoPin;
2828
private CmSketchPinNoOpt<int, DetectIsa> blockAvxPinNoOpt;
2929
private CmSketchCore<int, DetectIsa> blockAvx;
30+
private CmSketchCore512<int, DetectIsa> blockAvx512;
3031

3132
[Params(512, 1024, 32_768, 524_288, 8_388_608, 134_217_728)]
3233
public int Size { get; set; }
@@ -41,6 +42,7 @@ public void Setup()
4142
blockAvxNoPin = new CmSketchNoPin<int, DetectIsa>(Size, EqualityComparer<int>.Default);
4243
blockAvxPinNoOpt = new CmSketchPinNoOpt<int, DetectIsa>(Size, EqualityComparer<int>.Default);
4344
blockAvx = new CmSketchCore<int, DetectIsa>(Size, EqualityComparer<int>.Default);
45+
blockAvx512 = new CmSketchCore512<int, DetectIsa>(Size, EqualityComparer<int>.Default);
4446
}
4547

4648
[Benchmark(Baseline = true, OperationsPerInvoke = iterations)]
@@ -96,5 +98,14 @@ public void IncBlockAvxPinned()
9698
blockAvx.Increment(i);
9799
}
98100
}
101+
102+
[Benchmark(OperationsPerInvoke = iterations)]
103+
public void IncBlockAvxPinned512()
104+
{
105+
for (int i = 0; i < iterations; i++)
106+
{
107+
blockAvx512.Increment(i);
108+
}
109+
}
99110
}
100111
}

BitFaster.Caching.ThroughputAnalysis/Runner.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ private static void RunTest(Mode mode, int cacheSize)
3333

3434
var cachesToTest = new List<ICacheFactory>
3535
{
36-
new ClassicLruFactory(capacity),
37-
new MemoryCacheFactory(capacity),
36+
//new ClassicLruFactory(capacity),
37+
//new MemoryCacheFactory(capacity),
3838
new FastConcurrentLruFactory(capacity),
39-
new ConcurrentLruFactory(capacity),
39+
//new ConcurrentLruFactory(capacity),
4040
new ConcurrentLfuFactory(capacity)
4141
};
4242

BitFaster.Caching/Lfu/CmSketchCore.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ private void Reset()
258258

259259
#if !NETSTANDARD2_0
260260
[MethodImpl(MethodImplOptions.AggressiveInlining)]
261-
//[MethodImpl((MethodImplOptions)512)]
261+
// [MethodImpl(MethodImplOptions.AggressiveInlining | (MethodImplOptions)512)]
262262
private unsafe int EstimateFrequencyAvx(T value)
263263
{
264264
int blockHash = Spread(comparer.GetHashCode(value));
@@ -293,7 +293,7 @@ private unsafe int EstimateFrequencyAvx(T value)
293293
}
294294

295295
[MethodImpl(MethodImplOptions.AggressiveInlining)]
296-
//[MethodImpl((MethodImplOptions)512)]
296+
// [MethodImpl(MethodImplOptions.AggressiveInlining | (MethodImplOptions)512)]
297297
private unsafe void IncrementAvx(T value)
298298
{
299299
int blockHash = Spread(comparer.GetHashCode(value));

0 commit comments

Comments
 (0)