This is an archive of the discontinued LLVM Phabricator instance.

[Support] Improve Windows performance of buffered raw_ostream
ClosedPublic

Authored by andrewng on Mar 31 2023, 10:15 AM.

Details

Summary

The "preferred" buffer size for raw_ostream is set to BUFSIZ which on
Windows is only 512. This results in more calls to write and this
overhead can have a significant negative impact on performance,
especially when Anti-Virus is also involved.

Therefore increase the "preferred" buffer size to 16KB for Windows.

One example of where this helps is the LLD --Map option which dumps out
the symbol map for a link. In a link of UE4, this change has been seen
to improve the performance of the symbol map writing by more than a
factor of 6.

Diff Detail

Event Timeline

andrewng created this revision.Mar 31 2023, 10:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 31 2023, 10:15 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
andrewng requested review of this revision.Mar 31 2023, 10:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 31 2023, 10:15 AM
mstorsjo accepted this revision.Apr 3 2023, 5:58 AM

LGTM, I think this is fine (but wait a little while if someone else wants to comment too).

This revision is now accepted and ready to land.Apr 3 2023, 5:58 AM
aganea accepted this revision.Apr 3 2023, 6:17 AM

Sounds good!
I'm just curious, have you tried experimenting with different sizes? Would it make sense to set a higher value for the mapfile using .SetBufferSize()?

Sounds good!
I'm just curious, have you tried experimenting with different sizes? Would it make sense to set a higher value for the mapfile using .SetBufferSize()?

Yes, I did experiment with different sizes on a variety of PCs and the 16KB size was the "sweet" spot for these systems. On one, there were very minor gains from going larger but I decided it was not worthwhile, at least for the "preferred" size. A larger buffer could be set for LLD symbol map generation but the best part of the gains are already realized with the 16KB buffer size for my test systems.

This revision was landed with ongoing or failed builds.Apr 5 2023, 3:05 AM
This revision was automatically updated to reflect the committed changes.