wic
wic copied to clipboard
About performance
Hello, if I receive 8K data, the WIC does at least 16300 memcpy operations, resulting in a drastic drop in performance.
According to the test, on the 9th generation Inter CPU, it will not exceed 200Mbps/s
https://github.com/cjhdev/wic/blob/54d124005c25ca376aa4e85c45f87b6c3bb95797/src/wic.c#L603
https://github.com/cjhdev/wic/blob/54d124005c25ca376aa4e85c45f87b6c3bb95797/src/wic.c#L1136
https://github.com/cjhdev/wic/blob/54d124005c25ca376aa4e85c45f87b6c3bb95797/src/wic.c#L1146
Thanks for the benchmark.
Yes I can believe the stream abstraction slows things down with its bounds checking and copying. It doesn't need to call memcpy for single bytes but looks like I did it for consistency. A small refactor could bypass memcpy for single bytes.
I wasn't concerned with throughput when I worked on this.
I suspect a significant speed up would only happen by refactoring wic_parse and parse_data to deal in larger chunks of the message. Could reduce the number of function calls in the loop, check the bounds once, etc.