Skip to content
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

create_dir_all performs a quadradic number of system calls #51

Open
sunfishcode opened this issue Jul 17, 2020 · 3 comments
Open

create_dir_all performs a quadradic number of system calls #51

sunfishcode opened this issue Jul 17, 2020 · 3 comments
Labels
good first issue Good for newcomers

Comments

@sunfishcode
Copy link
Member

create_dir_all uses the algorithm from libstd for recursively creating all components. However, cap-primitives' mkdir function performs a system call per path component per call, so calling it once per path component leads to a quadratic number of system calls.

We should add a create_dir_all function in cap-primitives which, for each path component, creates a directory for that component (ignoring a io::ErrorKind::AlreadyExists error), opens the newly created directory, and then uses the resulting handle as the base for handling the next component.

Similar to open_manually, it should handle .. components by keeping a stack of handles as it goes, so that it can simply pop an entry from that stack to ascend to the parent.

And then, the cap-std and cap-async-std create_dir_all routines can use it.

@sunfishcode
Copy link
Member Author

We should also think about adding a function which creates a directory and opens it as a new Dir, for the common case where one does create_dir_all followed by open_dir. If create_dir_all opens the intermediate directories as it goes, then the final open_dir could open just the last component instead of the full path.

@MarkusTieger
Copy link

No activity in this issue since 4 years ... Is it still being worked on?

@sunfishcode
Copy link
Member Author

I'm not aware of anyone actively working on it at this time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants