Skip to content

In the _isDir function, set the max_items=1 when _lsdir #946

@zhouaoe

Description

@zhouaoe

In the _isdir function, the _lsdir function is used to determine whether a directory exists, but max_items is not set. This results in a default listing of 1000 items, whereas only one item is actually needed to verify the existence of the directory.

s3fs is widely used on many object storage systems that are compatible with the S3 protocol. For example, some users use s3fs to access Aliyun OSS services; in this case, limiting max_items can bring significant performance improvements.

Of course, here we need to be mindful of the impact on dircache. The result carrying max_items is incomplete. However, when there is an especially large number of files, such as in AI training datasets, the cost of listing the directory every time to check if a directory exists becomes prohibitively expensive. It is sufficient to update the dircache only when the user explicitly performs an ls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions