Skip to content

Commit

Permalink
Misc documentation and code coverage improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
brantburnett committed Dec 23, 2024
1 parent a7de589 commit 5a3fa2a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Snappier is a pure C# port of Google's [Snappy](https://github.com/google/snappy) compression algorithm. It is designed with speed as the primary goal, rather than compression ratio, and is ideal for compressing network traffic. Please see [the Snappy README file](https://github.com/google/snappy/blob/master/README.md) for more details on Snappy.

Complete documentation is available at (https://brantburnett.github.io/Snappier/).
Complete documentation is available at https://brantburnett.github.io/Snappier/.

## Project Goals

Expand All @@ -15,7 +15,7 @@ The Snappier project aims to meet the following needs of the .NET community.
- Use .NET paradigms, including asynchronous stream support
- Full compatibility with both block and stream formats
- Near C++ level performance
- Note: This is only possible on .NET 6 and later with the aid of [Span<T>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1?view=netcore-3.1) and [System.Runtime.Intrinsics](https://fiigii.com/2019/03/03/Hardware-intrinsic-in-NET-Core-3-0-Introduction/).
- Note: This is only possible on .NET 6 and later with the aid of [Span<T>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1?view=net-9.0) and [System.Runtime.Intrinsics](https://devblogs.microsoft.com/dotnet/dotnet-8-hardware-intrinsics/)
- .NET 4.6.1 is the slowest
- Keep allocations and garbage collection to a minimum using buffer pools

Expand Down Expand Up @@ -111,5 +111,5 @@ public class Program

There are other projects available for C#/.NET which implement Snappy compression.

- [Snappy.NET](https://snappy.machinezoo.com/) - Uses P/Invoke to C++ for great performance. However, it only works on Windows, and is a bit heap allocation heavy in some cases. It also hasn't been updated since 2014 (as of 10/2020). This project may still be the best choice if your project is on the legacy .NET Framework on Windows, where Snappier is much less performant.
- [IronSnappy](https://github.com/aloneguid/IronSnappy) - Another pure C# port, based on the Golang implementation instead of the C++ implementation.
- [Snappy.NET](https://snappy.machinezoo.com/) - Uses P/Invoke to C++ for great performance. However, it only works on Windows, is a bit heap allocation heavy in some cases, and is a deprecated project. This project may still be the best choice if your project is on the legacy .NET Framework on Windows, where Snappier is much less performant.
- [IronSnappy](https://www.nuget.org/packages/IronSnappy) - Another pure C# port, based on the Golang implementation instead of the C++ implementation.
2 changes: 2 additions & 0 deletions Snappier/Internal/SnappyCompressor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Buffers;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

namespace Snappier.Internal
Expand All @@ -10,6 +11,7 @@ internal class SnappyCompressor : IDisposable
private HashTable? _workingMemory = new();

[Obsolete("Retained for benchmark comparisons to previous versions")]
[ExcludeFromCodeCoverage]
public int Compress(ReadOnlySpan<byte> input, Span<byte> output)
{
if (!TryCompress(input, output, out int bytesWritten))
Expand Down
4 changes: 2 additions & 2 deletions Snappier/Snappy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public static void Decompress(ReadOnlySequence<byte> input, IBufferWriter<byte>
}

/// <summary>
/// Decompress a block of Snappy to a new memory buffer. This must be an entire block.
/// Decompress a block of Snappy data to a new memory buffer. This must be an entire block.
/// </summary>
/// <param name="input">Data to decompress.</param>
/// <returns>An <see cref="IMemoryOwner{T}"/> with the decompressed data. The caller is responsible for disposing this object.</returns>
Expand All @@ -242,7 +242,7 @@ public static IMemoryOwner<byte> DecompressToMemory(ReadOnlySpan<byte> input)
}

/// <summary>
/// Decompress a block of Snappy to a new memory buffer. This must be an entire block.
/// Decompress a block of Snappy data to a new memory buffer. This must be an entire block.
/// </summary>
/// <param name="input">Data to decompress.</param>
/// <returns>An <see cref="IMemoryOwner{T}"/> with the decompressed data. The caller is responsible for disposing this object.</returns>
Expand Down
2 changes: 1 addition & 1 deletion index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The Snappier project aims to meet the following needs of the .NET community.
- Use .NET paradigms, including asynchronous stream support
- Full compatibility with both block and stream formats
- Near C++ level performance
- Note: This is only possible on .NET 6 and later with the aid of [Span&lt;T&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.span-1?view=netcore-3.1) and [System.Runtime.Intrinsics](https://fiigii.com/2019/03/03/Hardware-intrinsic-in-NET-Core-3-0-Introduction/).
- Note: This is only possible on .NET 6 and later with the aid of [Span&lt;T&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.span-1?view=net-9.0) and [System.Runtime.Intrinsics](https://devblogs.microsoft.com/dotnet/dotnet-8-hardware-intrinsics/)
- .NET 4.6.1 is the slowest
- Keep allocations and garbage collection to a minimum using buffer pools

Expand Down

0 comments on commit 5a3fa2a

Please sign in to comment.