Commit 437ceff2 by Jan Voung

Ignore NaCl st_blksize of 0 and buffer writes to raw_fd_ostream.

The default LLVM raw_fd_ostream buffer size is based on stat'ing the FD and then checking st_blksize. Unfortunately, in the NaCl sandboxed build of pnacl-sz, NaCl's syscall returns st_blksize of 0 which makes the writes unbuffered. There is a comment in "src/trusted/service_runtime/include/bits/stat.h": nacl_abi_blksize_t nacl_abi_st_blksize; /* not implemented */ And the " src/trusted/desc/" implementation sets this to 0. This results in half a million write syscalls to translate the GCC pexe, which roughly doubles the translation time in sandboxed mode vs unsandboxed mode. Manually set a buffer size (Linux st_blksize seems to be about 4KB for comparison). This drops the number of write syscalls to about 200 for translating the GCC pexe. BUG= https://code.google.com/p/nativeclient/issues/detail?id=4091 R=stichnot@chromium.org Review URL: https://codereview.chromium.org/969403003
parent 5bc44313
......@@ -340,6 +340,9 @@ int main(int argc, char **argv) {
std::error_code EC;
raw_fd_ostream *FdOs =
new raw_fd_ostream(OutputFilename, EC, sys::fs::F_None);
// NaCl sets st_blksize to 0, and LLVM uses that to pick the
// default preferred buffer size. Set to something non-zero.
FdOs->SetBufferSize(1 << 14);
Os.reset(FdOs);
if (EC) {
*Ls << "Failed to open output file: " << OutputFilename << ":\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment