Message228855
I also ran the benchmark without cache on disk. It looks like my hard drive is too slow to see a real speedup of scandir(). The maximum speedup is 2.7 seconds lesser when testing the "c" scandir (24.089 => 21.374 seconds): "1.1x as fast".
I modified the benchmark to flush all caches, I added the following line into do_scandir_walk():
os.system("sudo bash -c 'echo 3 > /proc/sys/vm/drop_caches'")
I also commented the first call to do_scandir_walk() ("Priming the system's cache..."), just to make the benchmark faster.
(See attached clear_system_cache.patch for all changes.)
Result of the modified benchmark without cache:
haypo@smithers$ python3 setup.py build && for scandir in generic python c; do echo; echo "=== $scandir ==="; PYTHONPATH=build/lib.linux-x86_64-3.3/ python3 benchmark.py /usr/share -c $scandir || break; done
running build
running build_py
running build_ext
=== generic ===
Using very slow generic version of scandir
Comparing against builtin version of os.walk()
Benchmarking walks on /usr/share, repeat 1/3...
Benchmarking walks on /usr/share, repeat 2/3...
Benchmarking walks on /usr/share, repeat 3/3...
os.walk took 24.324s, scandir.walk took 24.215s -- 1.0x as fast
=== python ===
Using slower ctypes version of scandir
Comparing against builtin version of os.walk()
Benchmarking walks on /usr/share, repeat 1/3...
Benchmarking walks on /usr/share, repeat 2/3...
Benchmarking walks on /usr/share, repeat 3/3...
os.walk took 24.089s, scandir.walk took 21.374s -- 1.1x as fast
=== c ===
Using fast C version of scandir
Comparing against builtin version of os.walk()
Benchmarking walks on /usr/share, repeat 1/3...
Benchmarking walks on /usr/share, repeat 2/3...
Benchmarking walks on /usr/share, repeat 3/3...
os.walk took 24.225s, scandir.walk took 21.390s -- 1.1x as fast |
|
Date |
User |
Action |
Args |
2014-10-09 10:56:59 | vstinner | set | recipients:
+ vstinner, pitrou, giampaolo.rodola, tim.golden, benhoyt, abacabadabacaba, akira, socketpair |
2014-10-09 10:56:59 | vstinner | set | messageid: <1412852219.63.0.904044249116.issue22524@psf.upfronthosting.co.za> |
2014-10-09 10:56:59 | vstinner | link | issue22524 messages |
2014-10-09 10:56:58 | vstinner | create | |
|