~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to src/ioblksize.h

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* I/O block size definitions for coreutils
2
 
   Copyright (C) 1989, 1991-2011 Free Software Foundation, Inc.
 
2
   Copyright (C) 1989-2012 Free Software Foundation, Inc.
3
3
 
4
4
   This program is free software: you can redistribute it and/or modify
5
5
   it under the terms of the GNU General Public License as published by
20
20
#include "stat-size.h"
21
21
 
22
22
 
23
 
/* As of Mar 2009, 32KiB is determined to be the minimium
 
23
/* As of Jul 2011, 64KiB is determined to be the minimium
24
24
   blksize to best minimize system call overhead.
25
 
   This can be tested with this script with the results
26
 
   shown for a 1.7GHz pentium-m with 2GB of 400MHz DDR2 RAM:
 
25
   This can be tested with this script:
27
26
 
28
27
   for i in $(seq 0 10); do
29
 
     size=$((8*1024**3)) #ensure this is big enough
30
28
     bs=$((1024*2**$i))
31
29
     printf "%7s=" $bs
32
 
     dd bs=$bs if=/dev/zero of=/dev/null count=$(($size/$bs)) 2>&1 |
33
 
     sed -n 's/.* \([0-9.]* [GM]B\/s\)/\1/p'
 
30
     timeout --foreground -sINT 2 \
 
31
       dd bs=$bs if=/dev/zero of=/dev/null 2>&1 \
 
32
         | sed -n 's/.* \([0-9.]* [GM]B\/s\)/\1/p'
34
33
   done
35
34
 
36
 
      1024=734 MB/s
37
 
      2048=1.3 GB/s
38
 
      4096=2.4 GB/s
39
 
      8192=3.5 GB/s
40
 
     16384=3.9 GB/s
41
 
     32768=5.2 GB/s
42
 
     65536=5.3 GB/s
43
 
    131072=5.5 GB/s
44
 
    262144=5.7 GB/s
45
 
    524288=5.7 GB/s
46
 
   1048576=5.8 GB/s
 
35
   With the results shown for these systems:
 
36
   system-1 = 1.7GHz pentium-m with 400MHz DDR2 RAM, arch=i686
 
37
   system-2 = 2.1GHz i3-2310M with 1333MHz DDR3 RAM, arch=x86_64
 
38
   system-3 = 3.2GHz i7-970 with 1333MHz DDR3, arch=x86_64
 
39
 
 
40
   blksize  system-1   system-2   system-3
 
41
   ---------------------------------------
 
42
      1024  734 MB/s   1.7 GB/s   2.6 GB/s
 
43
      2048  1.3 GB/s   3.0 GB/s   4.4 GB/s
 
44
      4096  2.4 GB/s   5.1 GB/s   6.5 GB/s
 
45
      8192  3.5 GB/s   7.3 GB/s   8.5 GB/s
 
46
     16384  3.9 GB/s   9.4 GB/s  10.1 GB/s
 
47
     32768  5.2 GB/s   9.9 GB/s  11.1 GB/s
 
48
     65536  5.3 GB/s  11.2 GB/s  12.0 GB/s
 
49
    131072  5.5 GB/s  11.8 GB/s  12.3 GB/s
 
50
    262144  5.7 GB/s  11.6 GB/s  12.5 GB/s
 
51
    524288  5.7 GB/s  11.4 GB/s  12.5 GB/s
 
52
   1048576  5.8 GB/s  11.4 GB/s  12.6 GB/s
47
53
 
48
54
   Note that this is to minimize system call overhead.
49
55
   Other values may be appropriate to minimize file system
58
64
   In the future we could use the above method if available
59
65
   and default to io_blksize() if not.
60
66
 */
61
 
enum { IO_BUFSIZE = 32*1024 };
 
67
enum { IO_BUFSIZE = 64*1024 };
62
68
static inline size_t
63
69
io_blksize (struct stat sb)
64
70
{