jzebedee / deltaq

Fast and portable delta encoding for .NET in 100% safe, managed code.
Other
40 stars 13 forks source link

Massive Span<T> optimizations #8

Closed PJB3005 closed 2 years ago

PJB3005 commented 3 years ago

Basically rewrites the whole thing to use Span<T>. This does mean it doesn't support netstandard2.0 anymore but if that is a big problem there are some workarounds I can do to restore it, probably.

This is significantly faster and cuts down on the ridiculous amount of IList<T> allocations (seriously...).

Before:

image

After:

image

(test case was diffing the contents of a zip file)

Most of the remaining allocations (and a good chunk of CPU time...) are in bzip2 now. It should probably be possible to opt out of bzip2? But that's for another PR.

jzebedee commented 2 years ago

Thanks for contributing this fix (and the very entertaining code review in Discord) 😄

You're right that the IList<> usage is killer in the 1.x versions. If you're still using 1.x, there's some similar work on Span-based replacement in the span-core branch that never made it to release.

The 2.0 update (#9) includes this and should also see quite a bit better performance, both in speed and allocations.