-
Notifications
You must be signed in to change notification settings - Fork 13.2k
clang makes a lot of system calls for output files #9746
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
Comments
As an aside, some of this is coming from the only use of canWrite() in the tree. |
cloned to rdar://problem/9082880 |
For reference, some background for r114187 is here, though the proposed solution is not what was ultimately implemented: |
Bob, can someone take a look at this? |
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. |
Would it be ok if we managed to reduce the number of system calls to the absolute minimum necessary to
? |
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. |
How about temp file + rename only when writing PCH files ? |
After changes to trunk, for writing PCH: for other output files: llvm r136310 + |
…truction from bounds-attributed pointers (llvm#9746) (llvm#10027) For a `__sized_by(n)` pointer `p`, constructing a std::span the way below is safe. `std::span<char>{(char *)p, n}` cherry-picked from downstream (rdar://141103910)
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.
The text was updated successfully, but these errors were encountered: