This is an archive of the discontinued LLVM Phabricator instance.

[libc] Adding a version of memcpy w/ software prefetching
ClosedPublic

Authored by gchatelet on Jul 5 2023, 4:37 AM.

Details

Summary

For machines with a lot of cores, hardware prefetchers can saturate the memory bus when utilization is high.
In this case it is desirable to turn off the hardware prefetcher completely.
This has a big impact on the performance of memory functions such as memcpy that rely on the fact that the next cache line will be readily available.

This patch adds the 'LIBC_COPT_MEMCPY_X86_USE_SOFTWARE_PREFETCHING' compile time option that generates a version of memcpy with software prefetching. While not fully restoring the original performances it mitigates the impact to an acceptable level.

Diff Detail

Event Timeline

gchatelet created this revision.Jul 5 2023, 4:37 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 5 2023, 4:37 AM
gchatelet requested review of this revision.Jul 5 2023, 4:37 AM
rtenneti accepted this revision.Jul 6 2023, 10:09 AM

This change LGTM (compared it with the internal version).

This revision is now accepted and ready to land.Jul 6 2023, 10:09 AM