brantburnett/Snappier

A couple of questions

dodexahedron opened this issue · 1 comments

  1. Is this license compatible with the MIT license? My not-a-lawyer interpretation of it is that it probably is, but I'm considering using this in something MIT-licensed, so I wanted to make sure.

The next couple are just passing thoughts I had:

  1. I noticed at least one 256-bit buffer when I took a quick scan over the code. Is there anything to be gained by use of Vector256 and/or available intrinsics in .net core 3.0+?
  2. Related to 2, there's an implementation of CRC32 in there. Is it worth considering the Sse42.Crc32 intrinsic also available in .net core 3.0+?
  1. I am not a lawyer, so please don't take this as legal advice. However, my understanding is that if you're taking it as a transitive NuGet dependency of another open source package, you're fine. If you want to copy the source code you'd need to retain the license and copyright notices. If you want to distribute an app you'd need to include open source license notices with the app.
  2. Generally we are using vector intrinsic for performance. Can you point me to the particular spot you noticed and I'll check more closely?
  3. The CRC32 implementation is using that intrinsic.
    else if (Sse42.IsSupported)
    {
    // Process in 8-byte chunks first if 64-bit
    if (Sse42.X64.IsSupported)
    {
    if (source.Length >= 8)
    {
    // work with a ulong local during the loop to reduce typecasts
    ulong crcLocalLong = crcLocal;
    while (source.Length >= 8)
    {
    crcLocalLong = Sse42.X64.Crc32(crcLocalLong, MemoryMarshal.Read<ulong>(source));
    source = source.Slice(8);
    }
    crcLocal = (uint) crcLocalLong;
    }
    }
    // Process in 4-byte chunks
    while (source.Length >= 4)
    {
    crcLocal = Sse42.Crc32(crcLocal, MemoryMarshal.Read<uint>(source));
    source = source.Slice(4);
    }
    // Process the remainder
    int j = 0;
    while (j < source.Length)
    {
    crcLocal = Sse42.Crc32(crcLocal, source[j++]);
    }
    return crcLocal ^ uint.MaxValue;
    }