[PATCH] D71323: [profile] Avoid allocating a page on the stack, NFC

Vedant Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 10 18:46:10 PST 2019


vsk created this revision.
vsk added reviewers: arphaman, davidxl, phosek.
Herald added a subscriber: dexonsmith.
Herald added a project: LLVM.

When writing out a profile, avoid allocating a page on the stack for the
purpose of writing out zeroes, as some embedded environments do not have
enough stack space to accomodate this.

Instead, use a small, fixed-size zero buffer that can be written
repeatedly.

For a synthetic file with >100,000 functions, I did not measure a
significant difference in profile write times. We are removing a
page-length zero-fill `memset()` in favor of several smaller buffered
`fwrite()` calls: in practice, I am not sure there is much of a
difference. The performance impact is only expected to affect the
continuous sync mode (%c) -- zero padding is less than 8 bytes in all
other cases.

rdar://57810014


https://reviews.llvm.org/D71323

Files:
  compiler-rt/lib/profile/InstrProfilingFile.c
  compiler-rt/lib/profile/InstrProfilingInternal.h
  compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c
  compiler-rt/lib/profile/InstrProfilingWriter.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71323.233248.patch
Type: text/x-patch
Size: 5141 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191211/d9156ad3/attachment.bin>


More information about the llvm-commits mailing list