wic icon indicating copy to clipboard operation
wic copied to clipboard

About performance

Open caobug opened this issue 3 years ago • 1 comments
trafficstars

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

caobug avatar Mar 20 '22 19:03 caobug

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.

cjhdev avatar Mar 27 '22 11:03 cjhdev