breakwater icon indicating copy to clipboard operation
breakwater copied to clipboard

spike: Test using SIMD to parse coordinates

Open sbernauer opened this issue 2 years ago • 7 comments

Can be extended to parse rgba when we already have it in our vector. I think the swizzle (shuffle) part is costing most of the performance

sbernauer avatar Jun 18 '23 18:06 sbernauer

Also a note on types: I tried to change my solution to u16 (I'm currently using u32), but it was 20% slower. That's why I'm using u32.

fabi321 avatar Jun 18 '23 19:06 fabi321

If I follow the docs, and use cargo bench -Zbuild-std --target x86_64-unknown-linux-gnu, the time usage goes down to 21.5ms, from 50ms.

fabi321 avatar Jun 18 '23 20:06 fabi321

Ahh you're right! Have read that and had it back of my mind, but totally missed that. Thx!

sbernauer avatar Jun 18 '23 20:06 sbernauer

That kind of motivates me to continue on this and add the rgb parsing as well ^^

sbernauer avatar Jun 18 '23 20:06 sbernauer

the following test fails: assert_eq!(simd_parse_coord(b"1 2\n "), (1, 2, 3)); The problem is, that the spaces after the newline are not ignored, and lead to an invalid pattern

fabi321 avatar Jun 18 '23 21:06 fabi321

This is the reason why I use trailing_zeros to get the number of digits, as it stops at the first one, and ignores all the other clutter. This obviously only works on one number at a time.

fabi321 avatar Jun 18 '23 21:06 fabi321

Yep, I have noticed the failing tests as well. I already have an idea on how to solve this (with no performance penalty), but I did not continue any further until we solved the performance problem. The -Zbuild-std improved things quite a bit, so I might add the rgb parsing and than re-visit the performance.

sbernauer avatar Jun 19 '23 06:06 sbernauer