Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang makes a lot of system calls for output files #9746

Closed
sunfishcode opened this issue Mar 2, 2011 · 9 comments
Closed

clang makes a lot of system calls for output files #9746

sunfishcode opened this issue Mar 2, 2011 · 9 comments
Labels
bugzilla Issues migrated from bugzilla clang Clang issues not falling into any other category slow-compile

Comments

@sunfishcode
Copy link
Member

Bugzilla Link 9374
Resolution FIXED
Resolved on Jul 27, 2011 19:48
Version unspecified
OS All
CC @akyrtzi,@efriedma-quic,@tkremenek

Extended Description

Running clang -c testcase.c gets the following in a system call trace (which I've manually filtered):

[pid 17523] stat("testcase.o", {st_mode=S_IFREG|0600, st_size=1120, ...}) = 0
[pid 17523] stat("testcase.o", {st_mode=S_IFREG|0600, st_size=1120, ...}) = 0
[pid 17523] access("testcase.o", W_OK) = 0
[pid 17523] stat("testcase.o", {st_mode=S_IFREG|0600, st_size=1120, ...}) = 0
[pid 17523] open("testcase.o-rM0aoW", O_RDWR|O_CREAT|O_EXCL, 0600) = 3
[pid 17523] close(3) = 0
[pid 17523] open("testcase.o-rM0aoW", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
[pid 17523] close(3) = 0
[pid 17523] open("testcase.o-rM0aoW", O_WRONLY|O_CREAT|O_TRUNC, 0664) = 3
[pid 17523] fstat(3, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
[pid 17523] close(3) = 0
[pid 17523] rename("testcase.o-rM0aoW", "testcase.o") = 0

This is pretty excessive. A fair amount of it appears to have come from r114187, which was apparently intended for AST/PCH files, but was implemented to apply to all output files.

@sunfishcode
Copy link
Member Author

As an aside, some of this is coming from the only use of canWrite() in the tree.

@tkremenek
Copy link
Contributor

cloned to rdar://problem/9082880

@sunfishcode
Copy link
Member Author

For reference, some background for r114187 is here, though the proposed solution is not what was ultimately implemented:
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2010-September/011002.html

@lattner
Copy link
Collaborator

lattner commented May 22, 2011

Bob, can someone take a look at this?

@llvmbot
Copy link
Collaborator

llvmbot commented May 23, 2011

I pointed Eli at this earlier but we weren't sure what to do about it. I think the next step is to talk with Argyrios to better understand the issues. We'll do that this week.

@akyrtzi
Copy link
Contributor

akyrtzi commented May 25, 2011

Would it be ok if we managed to reduce the number of system calls to the absolute minimum necessary to

  1. create the temporary file
  2. rename the temporary over the output file

?

@sunfishcode
Copy link
Member Author

One option would be to put the responsibility for doing the temporary file plus rename in the client which needs this. For example, in place of having the client doing the equivalent of "clang ... -o out.o", the client could wrap this in some simple logic which does the equivalent of "clang ... -o out.o.blahblah && mv out.o.blahblah out.o". That way, the client would be in control of its own safety, and all other clients would be spared the overhead.

@akyrtzi
Copy link
Contributor

akyrtzi commented May 25, 2011

How about temp file + rename only when writing PCH files ?

@akyrtzi
Copy link
Contributor

akyrtzi commented Jul 28, 2011

After changes to trunk, for writing PCH:
10 119 open:entry clang test.pch-0fa1da06
12 121 close:entry clang test.pch-0fa1da06
12 365 rename:entry clang test.pch-0fa1da06 test.pch

for other output files:
4 119 open:entry clang test.o
4 121 close:entry clang test.o

llvm r136310 +
clang r136315.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang Clang issues not falling into any other category slow-compile
Projects
None yet
Development

No branches or pull requests

5 participants