Skip to content

Commit

Permalink
Minor fixes:
Browse files Browse the repository at this point in the history
- Fix potential race in ExecuteFullClear and ExecuteFullEviction when joining already running operation
- Simplify clearing arr. on quicklist reset
- Update benchmark docker image
- Update TFM ifdef in TimeUtils
  • Loading branch information
neon-sunset committed Jul 9, 2023
1 parent 724d628 commit 04756b6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
**/bin
**/obj
**/BenchmarkDotNet.Artifacts
**/BenchmarkDotNet.Artifacts
**/publish
**/.idea
17 changes: 9 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0
FROM mcr.microsoft.com/dotnet/sdk:8.0.100-preview.5
WORKDIR /app
COPY src .
RUN dotnet build FastCache.Benchmarks/FastCache.Benchmarks.csproj -c release -f net7.0

ENV DOTNET_ReadyToRun=0
ENV DOTNET_TieredPGO=1
ENV DOTNET_JitVTableProfiling=1
ENV DOTNET_JitProfileCasts=1
COPY src .
COPY Directory.Build.props .
RUN dotnet publish FastCache.Benchmarks/FastCache.Benchmarks.csproj \
-c release \
-o publish \
-f net8.0

CMD dotnet run --project FastCache.Benchmarks/FastCache.Benchmarks.csproj -c release -f net7.0
# Must be run interactively
CMD ./publish/FastCache.Benchmarks
4 changes: 2 additions & 2 deletions src/FastCache.Cached/CacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ static void Inner()

await (evictionJob.ActiveFullEviction = Task.Run(Inner));

evictionJob.FullEvictionLock.Release();
evictionJob.ActiveFullEviction = null;
evictionJob.FullEvictionLock.Release();

#if FASTCACHE_DEBUG
Console.WriteLine(
Expand Down Expand Up @@ -205,8 +205,8 @@ internal static async Task ExecuteFullEviction<K, V>(bool triggeredByGC) where K

await evictionJob.ActiveFullEviction;

evictionJob.FullEvictionLock.Release();
evictionJob.ActiveFullEviction = null;
evictionJob.FullEvictionLock.Release();
}

private static void ImmediateFullEviction<K, V>() where K : notnull
Expand Down
4 changes: 1 addition & 3 deletions src/FastCache.Cached/EvictionQuickList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,7 @@ private void Reset(bool lockRequired)

if (TypeInfo.IsManaged<K>())
{
var entries = _active;
var length = Math.Min((int)AtomicCount, entries.Length);
Array.Clear(entries, 0, length);
_active.AsSpan().Clear();
}

Interlocked.Exchange(ref _count, 0);
Expand Down
2 changes: 1 addition & 1 deletion src/FastCache.Cached/Helpers/TimeUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace FastCache.Helpers;

internal static class TimeUtils
{
#if NETCOREAPP3_0_OR_GREATER
#if NET6_0_OR_GREATER
public static long Now
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down

0 comments on commit 04756b6

Please sign in to comment.