mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Do 8- instead of 1-byte back-copies.
name old speed new speed delta puffs_flate_decode_1k/clang 191MB/s ± 1% 171MB/s ±12% ~ (p=0.095 n=5+5) puffs_flate_decode_10k/clang 277MB/s ± 1% 325MB/s ± 7% +17.47% (p=0.008 n=5+5) puffs_flate_decode_100k/clang 315MB/s ± 1% 416MB/s ± 1% +31.88% (p=0.008 n=5+5) puffs_flate_decode_1k/gcc 194MB/s ± 2% 197MB/s ± 0% +1.98% (p=0.016 n=5+4) puffs_flate_decode_10k/gcc 279MB/s ± 1% 361MB/s ± 1% +29.19% (p=0.016 n=4+5) puffs_flate_decode_100k/gcc 315MB/s ± 0% 437MB/s ± 0% +38.77% (p=0.008 n=5+5) Note that these are benchmark numbers for an 'ideal', hand-written C implementation, not for Puffs' generated C code.
This commit is contained in:
1 parent
c3aa366c66
commit
2e6b364dcc
1 file changed
+24
@@ -235,6 +235,30 @@ outer_loop:
|
||||
}
|
||||
|
||||
uint8_t* pback = pdst - distance;
|
||||
|
||||
#ifdef PUFFS_FLATE_HAVE_64_BIT_UNALIGNED_LITTLE_ENDIAN_LOADS
|
||||
// Back-copy fast path, copying 8 instead of 1 bytes at a time.
|
||||
//
|
||||
// This always copies 8*N bytes (where N is the smallest integer such that
|
||||
// 8*N >= length, i.e. we round length up to a multiple of 8), instead of
|
||||
// only length bytes, but that's OK, as subsequent iterations will fix up
|
||||
// the overrun.
|
||||
if (distance >= 8) {
|
||||
while (1) {
|
||||
*((uint64_t*)(pdst)) = *((uint64_t*)(pback));
|
||||
if (length <= 8) {
|
||||
pdst += length;
|
||||
break;
|
||||
}
|
||||
pdst += 8;
|
||||
pback += 8;
|
||||
length -= 8;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Back-copy slow path.
|
||||
for (; length >= 3; length -= 3) {
|
||||
*pdst++ = *pback++;
|
||||
*pdst++ = *pback++;
|
||||
|
||||
Reference in new issue
Block a user