nikita-volkov / ptr-poker

Pointer poking action construction and composition toolkit
http://hackage.haskell.org/package/ptr-poker
MIT License
8 stars 5 forks source link

Use SSE2 in cbits/text.c when possible #1

Closed ethercrow closed 3 years ago

ethercrow commented 3 years ago

SSE2 is available on every x86_64 CPU and has a perfect instruction for UTF16->UTF8 ASCII conversion: https://software.intel.com/sites/landingpage/IntrinsicsGuide/#expand=5608,5656,3357,300,3343,5608,3864,3555,4115&techs=SSE2&text=_mm_packus_epi16

Benchmarks before/after (on a pretty noisy machine):

Screen Shot 2021-01-01 at 8 13 25 PM
nikita-volkov commented 3 years ago

This is an impressive improvement! If you don't mind, I'll review it next week. I'm on a vacation right now.

ethercrow commented 3 years ago

No worries, enjoy your vacation! Jsonifier has already been a big win for me, especially when applied to some float-heavy payloads.

nikita-volkov commented 3 years ago

Just so you know, this PR won't affect the performance of "jsonifier", since it uses a specialised version of this algorithm, which also handles escaping.

ethercrow commented 3 years ago

So Jsonifier.writeJson should benefit from this PR, right?

nikita-volkov commented 3 years ago

Released. Thanks for you contribution and apologies for not coming back earlier.