coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

df statx

Open OH-AU opened this issue 3 years ago • 9 comments

checked with 0.0.12 (and 0.0.8) When running df -h /my_fs instead of just checking /my_fs, df iterates through every mounted filesystem with a statx e.g. statx(AT_FDCWD, "/data/something", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_BASIC_STATS, stx_attributes=0, stx_mode=S_IFDIR|0755, stx_size=4096, ...}) = 0 This may be fine with only a few mounts, but when a system has hundreds of mounts it can take some time to return results when the system is under load and run for the first time. gnu df also had this/similar problem but was addressed a long time ago I believe. Wondering if there was a way to only iterate the mount of interest and skip the rest in this case?

OH-AU avatar Mar 01 '22 07:03 OH-AU

Maybe pull request #3161 will resolve this issue?

jfinkels avatar Mar 02 '22 02:03 jfinkels

I don't believe it does - I grabbed the latest git version - same problem, Then grabbed the updated df.rs file from the above out of tree and it also shows the same behaviour.

OH-AU avatar Mar 02 '22 05:03 OH-AU

I think this issue is not specific to df. This issue is created because when uucore::fsext::read_fs_list is invoked, it will create a mount entry for every line read from mtab file and while creation it will call set_missing_fields() which calls std::fs::metadata() for each entry read from mount_info. This will internally make a syscall statx.

Refer to this section of code -> https://github.com/uutils/coreutils/blob/main/src/uucore/src/lib/features/fsext.rs#L150-L163

crazystylus avatar Mar 04 '22 17:03 crazystylus

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 15 '25 11:03 stale[bot]

This ticket may not have seen any recent activity however it's still an issue at 0.0.30 - gnu df -h responds instantly (0m0.116s), rust df -h takes many minutes to respond on a system with 100's of mount points (~900 in this case, it's been 5 minutes and still no response.).

OH-AU avatar Mar 15 '25 12:03 OH-AU

could you please run it with samply and share the execution profile ? :) thanks

sylvestre avatar Mar 15 '25 12:03 sylvestre

df2-prof2.json.gz

OH-AU avatar Mar 15 '25 14:03 OH-AU

@OH-AU please upload it directly in the firefox profiler. the json you shared doesn't have any symbol. see: https://share.firefox.dev/41BZVHQ

sylvestre avatar Mar 15 '25 14:03 sylvestre

https://share.firefox.dev/3XXyoPR ?

OH-AU avatar Mar 15 '25 14:03 OH-AU