To include linux proposed A set of patches with optimized implementation of the Memchr () function used for Search for a symbol in an array. Unlike the old version, in which a pile comparison was used, the proposed implementation was built taking into account the full use of 64- and 32-bit CPU registers. Instead of bytes, comparison is carried out using machine words, which allows you to compare at least 4 bytes at a time.
When searching in large lines, the new version turned out to be faster than the old one about 4 times (for example, for lines of 1000 characters). For lines of small size, the effectiveness of the new implementation is not so significant, but still higher compared to the original option. In the Linux nucleus, the size of processed in Memchr () lines reaches 512 bytes. The increase in performance for 512 byte lines, in a situation where the desired symbol is at the end of the line, is 20%.