Rasmus Villemoes
0ce657c576
linux/getsysstats.c: use sysinfo() instead of parsing /proc/meminfo
...
Profiling git's test suite, Linus noted [1] that a disproportionately
large amount of time was spent reading /proc/meminfo. This is done by
the glibc functions get_phys_pages and get_avphys_pages, but they only
need the MemTotal and MemFree fields, respectively. That same
information can be obtained with a single syscall, sysinfo, instead of
six: open, fstat, mmap, read, close, munmap. While sysinfo also
provides more than necessary, it does a lot less work than what the
kernel needs to do to provide the entire /proc/meminfo. Both strace -T
and in-app microbenchmarks shows that the sysinfo() approach is
roughly an order of magnitude faster.
sysinfo() is much older than what glibc currently requires, so I don't
think there's any reason to keep the old parsing code. Moreover, this
makes get_[av]phys_pages work even in the absence of /proc.
Linus noted that something as simple as 'bash -c "echo"' would trigger
the reading of /proc/meminfo, but gdb says that many more applications
than just bash are affected:
Starting program: /bin/bash "-c" "echo"
Breakpoint 1, __get_phys_pages () at ../sysdeps/unix/sysv/linux/getsysstats.c:283
283 ../sysdeps/unix/sysv/linux/getsysstats.c: No such file or directory.
(gdb) bt
So it seems that any application that uses qsort on a moderately sized
array will incur this cost (once), which is obviously proportionately
more expensive for lots of short-lived processes (such as the git test
suite).
[1] http://thread.gmane.org/gmane.linux.kernel/2019285
Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk >
* sysdeps/unix/sysv/linux/getsysstats.c (__get_phys_pages):
Use sysinfo system call instead of parsing /proc/meminfo.
* sysdeps/unix/sysv/linux/getsysstats.c (__get_avphys_pages):
Likewise.
2015-09-12 21:09:59 -04:00
..
2015-07-09 09:53:30 +01:00
2015-07-08 12:07:21 -03:00
2015-09-11 20:00:19 +00:00
2015-09-01 13:47:25 +00:00
2015-08-28 10:42:07 -03:00
2015-09-11 20:00:19 +00:00
2015-08-24 10:53:49 +02:00
2015-07-28 05:30:14 -04:00
2015-09-12 21:09:59 -04:00
2015-09-11 20:00:19 +00:00
2015-08-07 23:39:42 -04:00
2015-08-26 13:33:54 -04:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-09-11 20:00:19 +00:00
2015-09-04 16:03:00 -03:00
2015-09-08 21:11:03 +00:00
2015-01-02 16:29:47 +00:00
2015-09-11 20:00:19 +00:00
2015-08-24 10:53:49 +02:00
2015-06-29 14:38:46 +00:00
2015-07-21 12:11:55 -04:00
2015-08-11 09:37:38 +02:00
2015-08-20 04:29:23 -07:00
2015-08-19 04:27:04 -07:00
2015-07-09 15:25:47 -07:00
2015-06-04 18:58:36 -03:00
2015-08-25 13:45:56 -03:00
2015-08-21 09:57:15 -07:00
2015-01-02 16:29:47 +00:00
2015-08-21 09:57:15 -07:00
2015-01-02 16:29:47 +00:00
2015-08-25 13:45:56 -03:00
2015-01-02 16:29:47 +00:00
2015-09-08 21:11:03 +00:00
2015-01-08 10:49:40 -08:00
2015-01-02 16:29:47 +00:00
2015-05-26 10:10:36 -03:00
2015-05-26 10:10:36 -03:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-06 04:59:13 -08:00
2015-01-02 16:29:47 +00:00
2014-09-16 17:45:03 +00:00
2014-09-16 17:45:03 +00:00
2015-08-25 13:45:56 -03:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2014-06-20 15:41:35 +00:00
2015-01-02 16:29:47 +00:00
2015-08-21 09:57:15 -07:00
2014-06-25 20:29:45 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-06-04 18:58:36 -03:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-08-21 09:57:15 -07:00
2015-01-02 16:29:47 +00:00
2015-08-21 09:57:15 -07:00
2015-06-04 18:58:36 -03:00
2015-06-04 18:58:36 -03:00
2015-01-02 16:29:47 +00:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-08-21 09:57:15 -07:00
2015-01-02 16:29:47 +00:00
2015-06-09 19:52:01 +00:00
2015-08-21 09:57:15 -07:00
2015-07-10 13:47:09 +02:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-06-12 20:02:30 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-08-25 13:45:56 -03:00
2015-01-02 16:29:47 +00:00
2015-08-21 09:57:15 -07:00
2015-01-02 16:29:47 +00:00
2015-08-21 09:57:15 -07:00
2015-08-25 13:45:56 -03:00
2015-08-25 13:45:56 -03:00
2015-01-02 16:29:47 +00:00
2015-09-12 21:09:59 -04:00
2015-05-26 17:03:35 -03:00
2015-09-08 21:11:03 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2014-06-12 13:48:47 -07:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-08-24 10:53:49 +02:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:54:45 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-08-25 13:45:56 -03:00
2015-08-21 09:57:15 -07:00
2015-01-02 16:29:47 +00:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-01-02 16:29:47 +00:00
2015-08-25 11:37:44 -07:00
2015-01-02 16:29:47 +00:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-01-02 16:29:47 +00:00
2015-06-17 20:20:08 +00:00
2015-08-21 09:57:15 -07:00
2015-06-17 20:19:04 +00:00
2015-06-17 20:19:04 +00:00
2015-08-21 09:57:15 -07:00
2015-08-24 10:53:49 +02:00
2015-08-21 09:57:15 -07:00
2015-06-04 18:58:36 -03:00
2015-06-04 18:58:36 -03:00
2015-01-02 16:29:47 +00:00
2015-06-04 14:52:34 -03:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-06-04 18:58:36 -03:00
2015-08-11 09:37:38 +02:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-05-22 17:09:36 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-05-05 08:28:35 +02:00
2015-05-05 08:28:35 +02:00
2015-01-02 16:29:47 +00:00
2015-06-04 18:58:36 -03:00
2015-06-04 18:58:36 -03:00
2015-06-04 18:58:36 -03:00
2015-06-04 18:58:36 -03:00
2015-08-21 09:57:15 -07:00
2015-01-02 16:29:47 +00:00
2015-06-04 18:58:36 -03:00
2015-08-21 09:57:15 -07:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-06 08:23:58 -08:00
2015-03-23 16:34:48 +01:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-05-20 14:52:05 -07:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-06-04 18:58:36 -03:00
2015-06-04 18:58:36 -03:00
2015-06-04 18:58:36 -03:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-01-02 16:29:47 +00:00
2015-08-21 09:57:15 -07:00
2015-08-25 13:45:56 -03:00
2015-08-25 13:45:56 -03:00
2015-06-04 18:58:36 -03:00
2015-08-25 13:45:56 -03:00
2015-01-02 16:29:47 +00:00
2015-08-21 09:57:15 -07:00
2015-06-09 14:56:21 -03:00
2015-01-02 16:29:47 +00:00
2015-08-24 10:53:49 +02:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-08-25 13:45:56 -03:00
2015-06-04 18:58:36 -03:00
2015-08-25 13:45:56 -03:00
2015-08-25 13:45:56 -03:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-08-21 09:57:15 -07:00
2015-08-25 13:45:56 -03:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2014-09-12 12:28:47 +00:00
2015-09-08 21:11:03 +00:00
2015-08-21 09:57:15 -07:00
2015-08-24 10:53:49 +02:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-08-25 13:45:56 -03:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-06-04 18:58:36 -03:00
2015-06-04 18:58:36 -03:00
2015-01-06 08:23:58 -08:00
2015-06-04 18:58:36 -03:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-08-25 13:45:56 -03:00
2015-05-22 17:38:06 -03:00
2015-09-04 15:19:30 -03:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-01-02 16:29:47 +00:00
2015-06-09 19:52:01 +00:00
2015-06-04 18:58:36 -03:00
2015-09-12 21:09:59 -04:00
2015-01-02 16:29:47 +00:00
2015-08-21 09:57:15 -07:00
2015-05-26 10:10:36 -03:00
2014-06-25 18:09:01 +00:00
2015-09-08 21:11:03 +00:00
2015-06-04 18:58:36 -03:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-06-04 18:58:36 -03:00
2015-08-21 09:57:15 -07:00
2015-01-02 16:29:47 +00:00
2015-06-01 22:25:02 -03:00
2015-08-21 09:57:15 -07:00
2015-02-06 12:30:23 -08:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-06-24 13:56:46 -07:00
2015-02-06 12:30:23 -08:00
2015-02-06 12:30:23 -08:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-01-02 16:29:47 +00:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-01-02 16:29:47 +00:00
2015-06-04 18:58:36 -03:00
2015-06-04 18:58:36 -03:00
2015-06-04 18:58:36 -03:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-08-21 09:57:15 -07:00
2015-08-19 04:41:06 -07:00