Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions BitFaster.Caching.Benchmarks/DataStructureBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using System;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;

namespace BitFaster.Caching.Benchmarks
{
Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching.Benchmarks/DisposerBench.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static void Dispose(T value)
}

public static class Disposer2<T>
{
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Dispose(T value)
{
Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching.Benchmarks/Lfu/CmSketchNoPin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void Clear()
size = 0;
}

// [MemberNotNull(nameof(table))]
// [MemberNotNull(nameof(table))]
private void EnsureCapacity(long maximumSize)
{
int maximum = (int)Math.Min(maximumSize, int.MaxValue >> 1);
Expand Down
12 changes: 6 additions & 6 deletions BitFaster.Caching.Benchmarks/Lfu/LfuJustGetOrAdd.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using BenchmarkDotNet.Attributes;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using Benchly;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Jobs;
using BitFaster.Caching.Lfu;
using BitFaster.Caching.Scheduler;
using Benchly;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;

namespace BitFaster.Caching.Benchmarks
{
Expand Down Expand Up @@ -40,7 +40,7 @@ public void GlobalSetup()
[GlobalCleanup]
public void GlobalCleanup()
{
background.Dispose();
background.Dispose();
}

[Benchmark(Baseline = true)]
Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching.Benchmarks/Lfu/SketchFrequency.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public int FrequencyFlat()
{
int count = 0;
for (int i = 0; i < iterations; i++)
count += flatStd.EstimateFrequency(i) > flatStd.EstimateFrequency(i + 1) ? 1: 0;
count += flatStd.EstimateFrequency(i) > flatStd.EstimateFrequency(i + 1) ? 1 : 0;

return count;
}
Expand Down
4 changes: 2 additions & 2 deletions BitFaster.Caching.Benchmarks/Lru/LruCycleBench.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace BitFaster.Caching.Benchmarks.Lru
[DisassemblyDiagnoser(printSource: true, maxDepth: 5)]
[SimpleJob(RuntimeMoniker.Net48)]
#endif
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net60)]
[MemoryDiagnoser(displayGenColumns: false)]
[HideColumns("Job", "Median", "RatioSD", "Alloc Ratio")]
public class LruCycleBench
Expand All @@ -52,7 +52,7 @@ private void OnItemRemoved(object sender, ItemRemovedEventArgs<int, int> e)
field = e.Key;
}

[Benchmark(Baseline =true)]
[Benchmark(Baseline = true)]
public void FastConcurrentLru()
{
Func<int, int> func = x => x;
Expand Down
16 changes: 8 additions & 8 deletions BitFaster.Caching.Benchmarks/Lru/LruJustGetOrAdd.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using Benchly;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Benchly;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Jobs;
using BitFaster.Caching.Lfu;
using BitFaster.Caching.Lru;
using BitFaster.Caching.Scheduler;
using Microsoft.Extensions.Caching.Memory;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Runtime.CompilerServices;

namespace BitFaster.Caching.Benchmarks
{
Expand Down Expand Up @@ -39,7 +39,7 @@ namespace BitFaster.Caching.Benchmarks
// [HardwareCounters(HardwareCounter.LlcMisses, HardwareCounter.CacheMisses)] // Requires Admin https://adamsitnik.com/Hardware-Counters-Diagnoser/
// [ThreadingDiagnoser] // Requires .NET Core
[HideColumns("Job", "Median", "RatioSD", "Alloc Ratio")]
[ColumnChart(Title= "Lookup Latency ({JOB})", Output = OutputMode.PerJob, Colors = "darkslategray,royalblue,royalblue,royalblue,royalblue,royalblue,royalblue,royalblue,#ffbf00,limegreen,indianred,indianred")]
[ColumnChart(Title = "Lookup Latency ({JOB})", Output = OutputMode.PerJob, Colors = "darkslategray,royalblue,royalblue,royalblue,royalblue,royalblue,royalblue,royalblue,#ffbf00,limegreen,indianred,indianred")]
public class LruJustGetOrAdd
{
private static readonly ConcurrentDictionary<int, int> dictionary = new ConcurrentDictionary<int, int>(8, 9, EqualityComparer<int>.Default);
Expand All @@ -60,7 +60,7 @@ public class LruJustGetOrAdd
private static readonly int key = 1;
private static System.Runtime.Caching.MemoryCache memoryCache = System.Runtime.Caching.MemoryCache.Default;

Microsoft.Extensions.Caching.Memory.MemoryCache exMemoryCache
Microsoft.Extensions.Caching.Memory.MemoryCache exMemoryCache
= new Microsoft.Extensions.Caching.Memory.MemoryCache(new MemoryCacheOptionsAccessor());

[GlobalSetup]
Expand All @@ -73,7 +73,7 @@ public void GlobalSetup()
[GlobalCleanup]
public void GlobalCleanup()
{
background.Dispose();
background.Dispose();
}

[Benchmark(Baseline = true)]
Expand Down
16 changes: 8 additions & 8 deletions BitFaster.Caching.Benchmarks/Lru/LruJustGetOrAddGuid.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using Benchly;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
using Benchly;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Jobs;
using BitFaster.Caching.Lfu;
using BitFaster.Caching.Lru;
using BitFaster.Caching.Scheduler;
using Microsoft.Extensions.Caching.Memory;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;

namespace BitFaster.Caching.Benchmarks
{
Expand All @@ -23,7 +23,7 @@ namespace BitFaster.Caching.Benchmarks
// [HardwareCounters(HardwareCounter.LlcMisses, HardwareCounter.CacheMisses)] // Requires Admin https://adamsitnik.com/Hardware-Counters-Diagnoser/
// [ThreadingDiagnoser] // Requires .NET Core
[HideColumns("Job", "Median", "RatioSD", "Alloc Ratio")]
[ColumnChart(Title= "Guid Lookup Latency ({JOB})", Output = OutputMode.PerJob, Colors = "darkslategray,royalblue,royalblue,#ffbf00,indianred,indianred")]
[ColumnChart(Title = "Guid Lookup Latency ({JOB})", Output = OutputMode.PerJob, Colors = "darkslategray,royalblue,royalblue,#ffbf00,indianred,indianred")]
public class LruJustGetOrAddGuid
{
private static readonly ConcurrentDictionary<int, Guid> dictionary = new ConcurrentDictionary<int, Guid>(8, 9, EqualityComparer<int>.Default);
Expand All @@ -38,7 +38,7 @@ public class LruJustGetOrAddGuid
private static readonly int key = 1;
private static System.Runtime.Caching.MemoryCache memoryCache = System.Runtime.Caching.MemoryCache.Default;

Microsoft.Extensions.Caching.Memory.MemoryCache exMemoryCache
Microsoft.Extensions.Caching.Memory.MemoryCache exMemoryCache
= new Microsoft.Extensions.Caching.Memory.MemoryCache(new MemoryCacheOptionsAccessor());

private static readonly byte[] b = new byte[8];
Expand All @@ -53,7 +53,7 @@ public void GlobalSetup()
[GlobalCleanup]
public void GlobalCleanup()
{
background.Dispose();
background.Dispose();
}

[Benchmark(Baseline = true)]
Expand Down
10 changes: 5 additions & 5 deletions BitFaster.Caching.Benchmarks/Lru/LruMultiGet.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using BitFaster.Caching.Lru;
using System;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Runtime.Caching;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using BitFaster.Caching.Lru;

namespace BitFaster.Caching.Benchmarks.Lru
{
Expand Down Expand Up @@ -71,7 +71,7 @@ public void ConcurrentDictionary()
Func<int, int> func = x => x;

for (int j = 0; j < 4; j++)
{
{
for (int i = 0; i < 6; i++)
{
dictionary.GetOrAdd(i, func);
Expand Down
4 changes: 2 additions & 2 deletions BitFaster.Caching.Benchmarks/ValueFactoryBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public int Delegate()
[Benchmark()]
public int ValueFactory()
{
var valueFactory = new ValueFactoryArg<int,int, int>((k, v) => k + v, 2);
var valueFactory = new ValueFactoryArg<int, int, int>((k, v) => k + v, 2);
return Invoke<int, int, ValueFactoryArg<int, int, int>>(valueFactory, 1);
}

Expand Down Expand Up @@ -107,7 +107,7 @@ public int Delegate()
[Benchmark()]
public int ValueFactory()
{
var valueFactory = new ValueFactoryArg<int, ValueTuple<long, long, long>, int>((k, v) => k , (0, 1, 2));
var valueFactory = new ValueFactoryArg<int, ValueTuple<long, long, long>, int>((k, v) => k, (0, 1, 2));
return Invoke<int, int, ValueFactoryArg<int, ValueTuple<long, long, long>, int>>(valueFactory, 1);
}

Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching.HitRateAnalysis/Analysis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void TestKey(K key)

public static void WriteToFile(string path, IEnumerable<Analysis<K>> results)
{
using (var writer = new StreamWriter(path))
using (var writer = new StreamWriter(path))
using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
{
csv.WriteRecords(results);
Expand Down
44 changes: 22 additions & 22 deletions BitFaster.Caching.HitRateAnalysis/Arc/ArcDataFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,28 @@ public async Task DownloadIfNotExistsAsync()

public IEnumerable<long> EnumerateFileData()
{
// File Format:
// Every line in every file has four fields.
//
// First field: starting_block
// Second field: number_of_blocks(each block is 512 bytes)
//
// Third field: ignore
// Fourth field: request_number(starts at 0)
//
//
// Example: first line in P6.lis is
// 110765 64 0 0
//
//
// 110765 starting block
//
// 64 64 blocks each of 512 bytes
// so this represents 64 requests(each of a 512 byte page) from 110765 to 110828
//
// 0 ignore
//
// 0 request number(goes from 0 to n-1)
// File Format:
// Every line in every file has four fields.
//
// First field: starting_block
// Second field: number_of_blocks(each block is 512 bytes)
//
// Third field: ignore
// Fourth field: request_number(starts at 0)
//
//
// Example: first line in P6.lis is
// 110765 64 0 0
//
//
// 110765 starting block
//
// 64 64 blocks each of 512 bytes
// so this represents 64 requests(each of a 512 byte page) from 110765 to 110828
//
// 0 ignore
//
// 0 request number(goes from 0 to n-1)

using StreamReader sr = new StreamReader(FilePath);

Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching.HitRateAnalysis/Arc/Runner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public async Task Run()
await this.config.File.DownloadIfNotExistsAsync();

Console.WriteLine("Running...");

var sw = Stopwatch.StartNew();

int count = this.config.Analysis.First().CacheSize >= 1_000_000 ? AnalyzeLarge() : AnalyzeSmall();
Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching.HitRateAnalysis/Glimpse/DataFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static IEnumerable<long> EnumerateFileData()
var line = sr.ReadLine();

if (long.TryParse(line, out var value))
{
{
yield return value;
}
}
Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching.HitRateAnalysis/PlotExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static GenericChart WithLayout(this GenericChart chart, string title)
{
var font = new FSharpOption<Font>(Font.init(Size: new FSharpOption<double>(24)));
FSharpOption<Title> t = Title.init(Text: title, X: 0.5, Font: font);
FSharpOption <Color> plotBGColor = new FSharpOption<Color>(Color.fromKeyword(ColorKeyword.WhiteSmoke));
FSharpOption<Color> plotBGColor = new FSharpOption<Color>(Color.fromKeyword(ColorKeyword.WhiteSmoke));
Layout layout = Layout.init<IConvertible>(PaperBGColor: plotBGColor, PlotBGColor: plotBGColor, Title: t);
return chart.WithLayout(layout);
}
Expand Down
20 changes: 10 additions & 10 deletions BitFaster.Caching.HitRateAnalysis/Wikibench/WikiBenchFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ public IEnumerable<Uri> EnumerateUris()
if (parsed != null)
{
if (Uri.TryCreate(parsed, UriKind.Relative, out var result))
{
yield return result;
{
yield return result;
}
}
}
}
}

private static readonly string[] containsFilters =
{
private static readonly string[] containsFilters =
{
"?search = ",
"User+talk",
"User_talk",
Expand All @@ -93,12 +93,12 @@ public IEnumerable<Uri> EnumerateUris()

private static readonly string[] startswithFilters =
{
"/wiki/Special:Search",
"/w/query.php",
"/wiki/Talk:",
"/wiki/Special:Search",
"/w/query.php",
"/wiki/Talk:",
"/wiki/Special:AutoLogin",
"/Special:UserLogin",
"/w/api.php",
"/Special:UserLogin",
"/w/api.php",
"/error:"
};

Expand All @@ -113,7 +113,7 @@ private static string ParseLine(string line)
return null;
}

int start = line.IndexOf('/', 25+7);
int start = line.IndexOf('/', 25 + 7);

if (start == -1)
{
Expand Down
6 changes: 3 additions & 3 deletions BitFaster.Caching.ThroughputAnalysis/CacheFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ public ConcurrentLfuFactory(int capacity)
{
var scheduler = new BackgroundThreadScheduler();
var cache = new ConcurrentLfu<long, int>(
concurrencyLevel: threadCount,
capacity: capacity,
scheduler: scheduler,
concurrencyLevel: threadCount,
capacity: capacity,
scheduler: scheduler,
EqualityComparer<long>.Default);

return (scheduler, cache);
Expand Down
6 changes: 3 additions & 3 deletions BitFaster.Caching.ThroughputAnalysis/Exporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public Exporter(int minThreads, int maxThreads)

resultTable.Clear();
resultTable.Columns.Add("ThreadCount");
foreach (var tc in Enumerable.Range(minThreads, maxThreads - (minThreads-1)).ToArray())
foreach (var tc in Enumerable.Range(minThreads, maxThreads - (minThreads - 1)).ToArray())
{
resultTable.Columns.Add(tc.ToString());
}
Expand Down Expand Up @@ -75,7 +75,7 @@ public void ExportPlot(Mode mode, int cacheSize)
{
var columns = new List<int>();

for(int i = 1; i < resultTable.Columns.Count; i++)
for (int i = 1; i < resultTable.Columns.Count; i++)
{
columns.Add(int.Parse(resultTable.Columns[i].ColumnName));
}
Expand All @@ -92,7 +92,7 @@ public void ExportPlot(Mode mode, int cacheSize)
rowData.Add(double.Parse(row[i].ToString()) * 1_000_000);
}

// var chart = Chart.Line<int, double, string>(columns, rowData, Name: name, MarkerColor: MapColor(name));
// var chart = Chart.Line<int, double, string>(columns, rowData, Name: name, MarkerColor: MapColor(name));
var chart = Chart2D.Chart.Line<int, double, string>(columns, rowData, Name: name, MarkerColor: MapColor(name));
charts.Add(chart);

Expand Down
Loading
Loading