Use SSE2 in is_valid_ascii() where available.
authorJohn Naylor <john.naylor@postgresql.org>
Fri, 26 Aug 2022 08:01:24 +0000 (15:01 +0700)
committerJohn Naylor <john.naylor@postgresql.org>
Fri, 26 Aug 2022 08:48:49 +0000 (15:48 +0700)
commit121d2d3d70ecdb2113b340c5f3b99a61341291af
tree2fb2e21869ca777cb79a3a9282f0e5096ca409f6
parentab9717847a2b0c32b93121f873f4dff331e26eb0
Use SSE2 in is_valid_ascii() where available.

Per flame graph from Jelte Fennema, COPY FROM ... USING BINARY shows
input validation taking at least 5% of the profile, so it's worth trying
to be more efficient here. With this change, validation of pure ASCII is
nearly 40% faster on contemporary Intel hardware. To make this change
legible and easier to adopt to additional architectures, use helper
functions to abstract the platform details away.

Reviewed by Nathan Bossart

Discussion: https://www.postgresql.org/message-id/CAFBsxsG%3Dk8t%3DC457FXnoBXb%3D8iA4OaZkbFogFMachWif7mNnww%40mail.gmail.com
src/common/wchar.c
src/include/mb/pg_wchar.h
src/include/port/simd.h