[llvm-bugs] [Bug 32718] New: lld-created binaries do not end up in disk cache (?)

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 19 19:00:59 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=32718

            Bug ID: 32718
           Summary: lld-created binaries do not end up in disk cache (?)
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: richard-llvm at metafoo.co.uk
                CC: llvm-bugs at lists.llvm.org

After linking Clang with ld.bfd or ld.gold, if I run the binary, it starts
~instantly. If I instead link with ld.lld, I incur a several second startup
time the first time I run the Clang binary, and 'perf' indicates the time is
spent paging in the binary.

Here's what ld.bfd does to create its output binary (when the output file
already exists):

stat("x", {st_mode=S_IFREG|0750, st_size=1079, ...}) = 0
lstat("x", {st_mode=S_IFREG|0750, st_size=1079, ...}) = 0
unlink("x")                             = 0
open("x", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3
fcntl(3, F_GETFD)                       = 0
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
fstat(3, {st_mode=S_IFREG|0640, st_size=0, ...}) = 0
lseek(3, 0, SEEK_SET)                   = 0
read(3, "", 64)                         = 0
lseek(3, 64, SEEK_CUR)                  = 64
write(3, "\1\0\0\0\5\0\0\0\0\0\0\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0"...,
120) = 120
# ... lots more seeking, reading, and writing on fd 3
write(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
448) = 448
close(3)                                = 0
stat("x", {st_mode=S_IFREG|0640, st_size=1079, ...}) = 0
umask(0)                                = 027
umask(027)                              = 0
chmod("x", 0750)                        = 0

Here's what ld.gold does:

stat("x", {st_mode=S_IFREG|0750, st_size=1079, ...}) = 0 
unlink("x")                             = 0
open("x", O_RDWR|O_CREAT|O_TRUNC|O_CLOEXEC, 0777) = 4
fstat(4, {st_mode=S_IFREG|0750, st_size=0, ...}) = 0
fallocate(4, 0, 0, 1072)                = 0
mmap(NULL, 1072, PROT_READ|PROT_WRITE, MAP_SHARED, 4, 0) = 0x7fdfec2db000
munmap(0x7fdfec2db000, 1072)            = 0
close(4)                                = 0

Here's what ld.lld does:

access("x", F_OK)                       = 0
access("xtmp5181559f", F_OK)            = -1 ENOENT (No such file or directory)
rename("x", "xtmp5181559f")             = 0
stat("x", 0x7ffd9649e180)               = -1 ENOENT (No such file or directory)
lstat("x", 0x7ffd9649e220)              = -1 ENOENT (No such file or directory)
open("x.tmp3566de2", O_RDWR|O_CREAT|O_EXCL|O_TRUNC|O_CLOEXEC, 0777) = 3
fallocate(3, 0, 0, 4736)                = 0
mmap(NULL, 4736, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0) = 0x7fd09a5bf000
close(3)                                = 0
munmap(0x7fd09a5bf000, 4736)            = 0
rename("x.tmp3566de2", "x")             = 0


There are a few odd things here. Using temporary files (which sometimes get
left behind!) seems unnecessary and error-prone, and stat'ing a file we just
renamed seems pointless. But I suspect the slowness is caused either by the
rename or by the relative order of the close and munmap calls.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170420/22358ab7/attachment.html>


More information about the llvm-bugs mailing list