{"push_id":1412961704,"size":1,"distinct_size":1,"ref":"refs/heads/cm-13.0-caf","head":"08ef55b33be7b4093de5ccc01f43092315d74225","before":"f94c406ecb4cdb7f13cba213ee5fa5089caf7b13","commits":[{"sha":"08ef55b33be7b4093de5ccc01f43092315d74225","author":{"name":"bladehawkz","email":"2715dd61998393f2be225fecbcd9bd5e556b4936@hotmail.com"},"message":"proc: much faster /proc/vmstat\n\nEvery current KDE system has process named ksysguardd polling files\r\nbelow once in several seconds:\r\n\r\n\t$ strace -e trace=open -p $(pidof ksysguardd)\r\n\tProcess 1812 attached\r\n\topen(\"/etc/mtab\", O_RDONLY|O_CLOEXEC)   = 8\r\n\topen(\"/etc/mtab\", O_RDONLY|O_CLOEXEC)   = 8\r\n\topen(\"/proc/net/dev\", O_RDONLY)         = 8\r\n\topen(\"/proc/net/wireless\", O_RDONLY)    = -1 ENOENT (No such file or directory)\r\n\topen(\"/proc/stat\", O_RDONLY)            = 8\r\n\topen(\"/proc/vmstat\", O_RDONLY)          = 8\r\n\r\nHell knows what it is doing but speed up reading /proc/vmstat by 33%!\r\n\r\nBenchmark is open+read+close 1.000.000 times.\r\n\r\n\t\t\tBEFORE\r\n$ perf stat -r 10 taskset -c 3 ./proc-vmstat\r\n\r\n Performance counter stats for 'taskset -c 3 ./proc-vmstat' (10 runs):\r\n\r\n      13146.768464      task-clock (msec)         #    0.960 CPUs utilized            ( +-  0.60% )\r\n                15      context-switches          #    0.001 K/sec                    ( +-  1.41% )\r\n                 1      cpu-migrations            #    0.000 K/sec                    ( +- 11.11% )\r\n               104      page-faults               #    0.008 K/sec                    ( +-  0.57% )\r\n    45,489,799,349      cycles                    #    3.460 GHz                      ( +-  0.03% )\r\n     9,970,175,743      stalled-cycles-frontend   #   21.92% frontend cycles idle     ( +-  0.10% )\r\n     2,800,298,015      stalled-cycles-backend    #   6.16% backend cycles idle       ( +-  0.32% )\r\n    79,241,190,850      instructions              #    1.74  insn per cycle\r\n                                                  #    0.13  stalled cycles per insn  ( +-  0.00% )\r\n    17,616,096,146      branches                  # 1339.956 M/sec                    ( +-  0.00% )\r\n       176,106,232      branch-misses             #    1.00% of all branches          ( +-  0.18% )\r\n\r\n      13.691078109 seconds time elapsed                                          ( +-  0.03% )\r\n      ^^^^^^^^^^^^\r\n\r\n\t\t\tAFTER\r\n$ perf stat -r 10 taskset -c 3 ./proc-vmstat\r\n\r\n Performance counter stats for 'taskset -c 3 ./proc-vmstat' (10 runs):\r\n\r\n       8688.353749      task-clock (msec)         #    0.950 CPUs utilized            ( +-  1.25% )\r\n                10      context-switches          #    0.001 K/sec                    ( +-  2.13% )\r\n                 1      cpu-migrations            #    0.000 K/sec\r\n               104      page-faults               #    0.012 K/sec                    ( +-  0.56% )\r\n    30,384,010,730      cycles                    #    3.497 GHz                      ( +-  0.07% )\r\n    12,296,259,407      stalled-cycles-frontend   #   40.47% frontend cycles idle     ( +-  0.13% )\r\n     3,370,668,651      stalled-cycles-backend    #  11.09% backend cycles idle       ( +-  0.69% )\r\n    28,969,052,879      instructions              #    0.95  insn per cycle\r\n                                                  #    0.42  stalled cycles per insn  ( +-  0.01% )\r\n     6,308,245,891      branches                  #  726.058 M/sec                    ( +-  0.00% )\r\n       214,685,502      branch-misses             #    3.40% of all branches          ( +-  0.26% )\r\n\r\n       9.146081052 seconds time elapsed                                          ( +-  0.07% )\r\n       ^^^^^^^^^^^\r\n\r\nvsnprintf() is slow because:\r\n\r\n1. format_decode() is busy looking for format specifier: 2 branches\r\n   per character (not in this case, but in others)\r\n\r\n2. approximately million branches while parsing format mini language\r\n   and everywhere\r\n\r\n3.  just look at what string() does /proc/vmstat is good case because\r\n   most of its content are strings\r\n\r\nLink: http://lkml.kernel.org/r/20160806125455.GA1187@p183.telecom.by\r\nSigned-off-by: Alexey Dobriyan <adobriyan@gmail.com>\r\nCc: Joe Perches <joe@perches.com>\r\nCc: Andi Kleen <andi@firstfloor.org>\r\nCc: Al Viro <viro@zeniv.linux.org.uk>\r\nSigned-off-by: Andrew Morton <akpm@linux-foundation.org>\r\nSigned-off-by: Linus Torvalds <torvalds@linux-foundation.org>","distinct":true,"url":"https://api.github.com/repos/bladehawkz/Bladehawkz-Kernel/commits/08ef55b33be7b4093de5ccc01f43092315d74225"}]}
{"actor":{"display_login":"bladehawkz"}}