haskell - Optimizing sum, ZipList, Vector, and unboxed types -



haskell - Optimizing sum, ZipList, Vector, and unboxed types -

i have identified next hotspot function 25% of programme execution time:

type encodelookup = [(gf256elm, [gf256elm])] -- | given coefficients of polynomial , x value, -- calculate corresponding y value. -- coefficients in ascending order [d, a1, a2, a3...] y = d + a1*x + a2*x^2 ... calc :: encodelookup -> [gf256elm] -> [gf256elm] calc xslookup poly = map f xslookup f (_, plist) = allow zl = (*) <$> ziplist (plist) <*> ziplist poly lst = getziplist zl s = sum lst in s

where gf256elm newtype wrapper around int, custom * , other operations defined (finitefields).

here related profiling info function:

individual inherited cost centre no. entries %time %alloc %time %alloc calc 544 794418 1.6 3.1 27.5 19.7 calc.f 698 3972090 0.9 0.0 25.9 16.6 calc.f.s 709 3972090 7.4 6.2 11.0 7.8 frominteger 711 3972090 0.7 0.0 0.7 0.0 + 710 11916270 2.9 1.6 2.9 1.6 calc.f.lst 708 3972090 0.0 0.0 0.0 0.0 calc.f.zl 699 3972090 6.8 8.8 14.0 8.8 * 712 11916270 7.2 0.0 7.2 0.0

my observations:

sum's slowness came lazy list thunks * calculation takes while too. can see total implementation of gf256elm here. * vector lookup of pregenerated table , bit flipping. 'ziplist` seems take important amount of time well.

my questions:

how go optimizing function? regarding sum - using deepseq on list create faster?

should using unboxed int# type gf256elm? other ways can improve speed of gf256elm's operations?

thanks!

haskell optimization lazy-evaluation

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -