Delete image_buffer linearization optimization

It helps at small image sizes, but it doesn't help at all for larger
images. The extra code is probably not worth it. Numbers below, old is
with the optimization, new is without.

name                             old speed      new speed      delta

wuffs_gif_decode_1k_bw/clang      307MB/s ± 2%   286MB/s ± 0%  -6.84%  (p=0.000 n=48+42)
wuffs_gif_decode_1k_color/clang   137MB/s ± 1%   134MB/s ± 0%  -2.36%  (p=0.000 n=46+44)
wuffs_gif_decode_10k/clang        125MB/s ± 2%   125MB/s ± 0%    ~     (p=0.617 n=46+45)
wuffs_gif_decode_100k/clang       119MB/s ± 1%   119MB/s ± 0%    ~     (p=0.827 n=47+43)
wuffs_gif_decode_1000k/clang      121MB/s ± 1%   121MB/s ± 1%  +0.31%  (p=0.022 n=49+46)

wuffs_gif_decode_1k_bw/gcc        320MB/s ± 1%   304MB/s ± 1%  -4.77%  (p=0.000 n=48+46)
wuffs_gif_decode_1k_color/gcc     156MB/s ± 1%   153MB/s ± 1%  -2.08%  (p=0.000 n=46+49)
wuffs_gif_decode_10k/gcc          141MB/s ± 1%   141MB/s ± 0%  -0.06%  (p=0.012 n=44+46)
wuffs_gif_decode_100k/gcc         126MB/s ± 1%   127MB/s ± 0%  +0.76%  (p=0.000 n=45+42)
wuffs_gif_decode_1000k/gcc        129MB/s ± 1%   130MB/s ± 1%  +0.89%  (p=0.000 n=46+44)
This commit is contained in:
Nigel Tao committed 2018-05-29 08:15:19 +10:00
1 parent 3c3e6fc2fa
commit c723329263
2 files changed
-116

No files matched your search

-51
View File
@@ -525,57 +525,6 @@ pri func decoder.copy_to_image_buffer?(ib ptr base.image_buffer)() {
var tab table base.u8 = in.ib.plane(p:0)
// As an optimization, linearize tab's rows into one big slice, in order to
// make fewer copy_from_slice calls.
//
// TODO: measure this optimization and delete it if it doesn't help.
if (not this.interlace) and (tab.width() == tab.stride()) and (this.dst_x0 == 0) and
((this.dst_x1 as base.u64) == tab.width()) and
((this.dst_y1 as base.u64) <= tab.height()) {
if this.uncompressed_ri > this.uncompressed_wi {
return error "internal error: inconsistent ri/wi"
}
src = this.uncompressed[this.uncompressed_ri:this.uncompressed_wi]
if this.dst_y >= this.dst_y1 {
return error "too much pixel data"
}
var i base.u64
dst = tab.linearize()
i = ((this.dst_y1 as base.u64) * (this.dst_x1 as base.u64))
if i < dst.length() {
dst = dst[:i]
}
i = ((this.dst_y as base.u64) * (this.dst_x1 as base.u64)) + (this.dst_x as base.u64)
if i < dst.length() {
dst = dst[i:]
n = (dst.copy_from_slice(s:src) & 0xFFFFFFFF) as base.u32
new_ri = this.uncompressed_ri ~sat+ n
this.uncompressed_ri = new_ri.min(x:4096)
i ~sat+= n as base.u64
if tab.width() <= 0 {
return error "too much pixel data"
}
this.dst_x = ((i % tab.width()) & 0xFFFFFFFF) as base.u32
this.dst_y = ((i / tab.width()) & 0xFFFFFFFF) as base.u32
}
if this.uncompressed_ri == this.uncompressed_wi {
this.uncompressed_ri = 0
this.uncompressed_wi = 0
} else if this.uncompressed_ri > this.uncompressed_wi {
return error "internal error: inconsistent ri/wi"
}
return
}
while this.uncompressed_wi > this.uncompressed_ri {
assert this.uncompressed_ri < this.uncompressed_wi via "a < b: b > a"()
src = this.uncompressed[this.uncompressed_ri:this.uncompressed_wi]