Skip to content

gh-122885: Improve os.scandir (and os.walk) performance on Windows #122886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Michael-K-Stein
Copy link

@Michael-K-Stein Michael-K-Stein commented Aug 10, 2024

Improve os.scandir (and os.walk) performance on Windows

Use native NT syscalls to implement os.scandir rather than WinAPI and POSIX functions.

@ghost
Copy link

ghost commented Aug 10, 2024

The following commit authors need to sign the Contributor License Agreement:

Click the button to sign:
CLA not signed

@bedevere-app
Copy link

bedevere-app bot commented Aug 10, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented Aug 10, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

2 similar comments
@bedevere-app
Copy link

bedevere-app bot commented Aug 10, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented Aug 10, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@Michael-K-Stein Michael-K-Stein force-pushed the feature/windows-scandir-native branch from 1dcb84b to 417df7f Compare August 10, 2024 19:19
@bedevere-app
Copy link

bedevere-app bot commented Aug 10, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@9001
Copy link

9001 commented Aug 11, 2024

when I tried this patchset just now, I'm seeing a severe performance degradation. This could of course be due to some particularities of my rig, so I'll include all the relevant details I can think of.

git-head\python.exe -m timeit -s "import os" "for _ in os.scandir('.'): pass"
1000 loops, best of 5: 200 usec per loop

pr122886\python.exe -m timeit -s "import os" "for _ in os.scandir('.'): pass"
500 loops, best of 5: 523 usec per loop

when testing a real-world application, a webserver which uses scandir:

python.exe c:\users\ed\Downloads\copyparty-sfx.py -q
oha --ipv4 --insecure -z11s --fps 4 http://127.0.0.1:3923/?ls

git-head: 680 req/s
pr122886: 595 req/s

when doing a similar test with oha against python -m http.server there was no difference between git-head and this pr, and ditto when running copyparty with --no-scandir (400 req/s).

my environment is windows 10 ltsc (version 1809, build 17763.5576), and I built cpython with VS-buildtools 2019 v16.11.37 using build.bat (no arguments)

the folder I'm listing is cpython\PCbuild after building, so 132 files and 6 dirs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants