Closed mitiko closed 3 years ago
It's working... I did have to use Memory<T>
instead of Span<T>
of course because of async. And I also made it ReadOnlyMemory<T>
since the input buffer is immutable anyway.
I'm currently making some performance tests to see if anything is faster: | enwik5 m=12 r=8 | Memory | |
---|---|---|---|
Compression | 04:24.486 | 64MB | |
Compression Old | 03:56.809 | 64MB | |
Decompression | 00:00.092 | ||
Decompression Old | 00:00.069 |
enwik4 m=8 r=7 | Memory | |
---|---|---|
Compression | 00:02.410 | 32MB |
Compression Old | 00:06.050 | 40MB |
Decompression | 00:00.016 | |
Decompression Old | 00:00.023 |
I took the mean of 3 runs for each measurement.
I didn't dive deep for the memory measurements, just whatever top
is saying as a percentage of my RAM. I'll improve perf measurements later on.
Weirdly, for enwik5, the new version keeps memory at 32MB, until the very end when it goes to 64, while the old one is steady at 40MB and goes to 64 at the end as well. I guess this is from parsing when we allocate 4*buffer.Length
bytes for the int array and it doesn't matter we've saved some 8MB memory.
Don't copy the whole byte array every time we move from one transform to another. Use
Span<T>
to only pass a reference to the data, a managed pointer.