Skip to content

Avoid owner and group lookups in WASI filestat - #266

Merged
andreaTP merged 1 commit into
bytecodealliance:mainfrom
fahrradflucht:fix/wasi-filestat-attributes
Nov 2, 2026
Merged

andreaTP merged 1 commit into
bytecodealliance:mainfrom
fahrradflucht:fix/wasi-filestat-attributes

Conversation

@fahrradflucht

Copy link
Copy Markdown
Contributor

fd_filestat_get, path_filestat_get and fd_readdir read unix:*, which also resolves the owner and group names (getpwuid/getgrgid) on every call. None of them use those, so this only asks for the attributes writeFileStat and getFileType read.

I hit this running SQLite on Endive, which stats the database file on every read transaction. Single-threaded point reads went from 168k to 198k/s on macOS, and on its own Files.readAttributes goes from 76k to 659k calls/s on Linux.

fd_filestat_get, path_filestat_get and fd_readdir read "unix:*", which
also resolves the owner and group names. None of them use those, so
request only the attributes that writeFileStat and getFileType read.

@andreaTP andreaTP left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your interest in the project!
I'll have a look early next week.

@andreaTP

andreaTP commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Thanks, @fahrradflucht nice find!
I checked that the guest still gets identical stat results on JDK 11–25, on both the real filesystem and ZeroFs. On Fedora the gain is even bigger, about 1.5k → 390k readAttributes calls/s, because group lookups there also query systemd-userdb. LGTM.

@andreaTP
andreaTP merged commit 03bf3d8 into bytecodealliance:main Nov 2, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants