This is an archive of the discontinued LLVM Phabricator instance.

[Bitstream] Only consider flushing to file on block boundaries
ClosedPublic

Authored by sammccall on May 6 2022, 4:37 PM.

Details

Summary

The goal of flushing to disk is to keep a reasonable bound on peak memory usage.
With a a default threshold of 512MB (and most BitstreamWriters having no backing
file at all), checking after every byte whether to flush seems excessive.

This change makes clangd's unittests run 5% faster (in opt), so it's not
actually free even in the case with no backing file. Likely there are more
important workloads where it makes some difference.

Diff Detail

Event Timeline

sammccall created this revision.May 6 2022, 4:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 6 2022, 4:37 PM
sammccall requested review of this revision.May 6 2022, 4:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 6 2022, 4:37 PM

This seems safe unless the ldd/LTO/bitcode case that motivated this flushing can have huge amounts of data (comparable to buffer size) with no subblocks.
Staring at the code, that seemed unlikely but I'm not familiar with what goes into these files. @stephan.yichao.zhao @MaskRay any thoughts?

(This isn't terribly important, so if it's not obvious I can just drop it)

MaskRay accepted this revision.May 6 2022, 10:02 PM
This revision is now accepted and ready to land.May 6 2022, 10:02 PM