Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-54232

Use install rather than cp to copy files in buildsystem

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Do
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Build
    • None
    • Server Development Platform

      One of the weird things I learned while working on ninja is that install is significantly faster than cp. I don't know why this is, but it is reproducible across many systems and filesystems, etc. For example, this is running on a virtual workstation (c5.4xl ubuntu 18.04 xfs):

      ubuntu@ip-10-122-10-16:~$ dd if=/dev/zero of=src bs=1M count=100; sync;                          
      100+0 records in
      100+0 records out
      104857600 bytes (105 MB, 100 MiB) copied, 0.189798 s, 552 MB/s
      ubuntu@ip-10-122-10-16:~$ for i in `seq 10`; do time install src dest; done; sync;
      
      real    0m0.061s
      user    0m0.000s
      sys     0m0.061s
      
      real    0m0.064s
      user    0m0.000s
      sys     0m0.064s
      
      real    0m0.061s
      user    0m0.000s
      sys     0m0.061s
      
      real    0m0.061s
      user    0m0.000s
      sys     0m0.061s
      
      real    0m0.061s
      user    0m0.000s
      sys     0m0.061s
      
      real    0m0.061s
      user    0m0.000s
      sys     0m0.061s
      
      real    0m0.061s
      user    0m0.000s
      sys     0m0.061s
      
      real    0m0.061s
      user    0m0.000s
      sys     0m0.061s
      
      real    0m0.061s
      user    0m0.000s
      sys     0m0.061s
      
      real    0m0.060s
      user    0m0.000s
      sys     0m0.061s
      ubuntu@ip-10-122-10-16:~$ for i in `seq 10`; do time cp src dest; done; sync;
      
      real    0m0.234s
      user    0m0.000s
      sys     0m0.071s
      
      real    0m0.226s
      user    0m0.004s
      sys     0m0.067s
      
      real    0m0.220s
      user    0m0.000s
      sys     0m0.073s
      
      real    0m0.211s
      user    0m0.000s
      sys     0m0.070s
      
      real    0m0.223s
      user    0m0.000s
      sys     0m0.075s
      
      real    0m0.335s
      user    0m0.000s
      sys     0m0.075s
      
      real    0m0.400s
      user    0m0.000s
      sys     0m0.073s
      
      real    0m0.400s
      user    0m0.004s
      sys     0m0.066s
      
      real    0m0.398s
      user    0m0.000s
      sys     0m0.073s
      
      real    0m0.399s
      user    0m0.000s
      sys     0m0.070s
      

      I have tried on my laptop (WSL2 + Arch ext4 on nvme) and the results were similar. Including the weirdness of later runs of cp being slower than earlier runs. �

            Assignee:
            backlog-server-devplatform [DO NOT ASSIGN] Backlog - Server Development Platform Team (SDP) (Inactive)
            Reporter:
            mathias@mongodb.com Mathias Stearn
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: