Re: Slow performance when overwriting disk file (was Re: Slow performance when redirecting stdout to an existing disk file)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Fri, Sep 28, 2018 at 2:37 PM Dave Ulrick <d-ulrick@xxxxxxxxxxx> wrote:
Update:

> $ time cat infile >outfile
>
> If 'infile' is on the order of 140 MB, 'time' might show something as low as:
>
> real  0m0.146s
> user  0m0.000s
> sys   0m0.109s
> CPU % 74.29
>
> or as high as:
>
> real  0m0.328s
> user  0m0.000s
> sys   0m0.109s
> CPU % 33.31
>
> If 'outfile' doesn't exist, the 'cat' runs much more quickly:
>
> real  0m0.082s
> user  0m0.000s
> sys   0m0.081s
> CPU % 99.77

When an existing file is truncated, which the shell does when you use stdout redirection, all the blocks that were in it have to be moved to the file system's free block list. Exactly what happens there may depend on what kind of file system you are using, but it is extra work that doesn't have to be done if you are creating a new file, which may explain the time difference.

--Greg
 
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux