You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At Meta internally I've been working on performance optimisations for a number of our widely deployed Rust daemons. One pattern I have repeatedly seen and optimised is:
for entry inread_dir(".")? {
entry?.metadata()?.is_dir();}
This requires an additional statx() (or equivalent) syscall. In some cases I have saved very large amounts of CPU and IO by just changing to:
for entry inread_dir(".")? {
entry?.file_type()?.is_dir();}
...which just uses the DT_* returned from readdir().
I plan to implement a lint which detects cases like this (where metadata() is called on entry only to call .is_{file,dir,symlink}().
Does this sound reasonable?
Advantage
Reduced CPU instructions
Reduced IO cost
Drawbacks
No response
Example
See above description.
The text was updated successfully, but these errors were encountered:
What it does
At Meta internally I've been working on performance optimisations for a number of our widely deployed Rust daemons. One pattern I have repeatedly seen and optimised is:
This requires an additional
statx()
(or equivalent) syscall. In some cases I have saved very large amounts of CPU and IO by just changing to:...which just uses the
DT_*
returned fromreaddir()
.I plan to implement a lint which detects cases like this (where
metadata()
is called onentry
only to call.is_{file,dir,symlink}()
.Does this sound reasonable?
Advantage
Drawbacks
No response
Example
See above description.
The text was updated successfully, but these errors were encountered: