-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[BUG] file.recurse is > 5x slower than file.managed #61998
Comments
Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. |
I am unable to recreate this.
as you can see in my test they are similar times. and both much faster than yours. which makes me think something else has to be going on here. do you have a large number of files in your salt file server? or a large number of directories? |
Yes,
It contains 31,000 files. How does it matter for file.recurse speed? |
the filesystem in salt is not exactly robust. it isn't meant to be large. if it isn't being served by salt it shouldn't be in the fileserver. a large fileserver can cause the master to slowdown as it gets requests. but also file.recurse scans the list of directories looking for the target directory. this normally is pretty fast. however with a large number of directories it can slow it down. |
Is this the cause of such issue? Lines 4477 to 4485 in 31aee29
|
that is only half of it. the other half being the transfer of the data needed. and the slowdown on the master as it indexes the filesystem. with the extra calls needed for file.recurse it will still be slower for file.recurse than file.managed. |
Is there another way to implement it? Maybe store file content inside pillars? |
pillars would be worse. pillars are not meant for anything other than secrets. the recommendation is to stop abusing it. if you need large swaths of files put somewhere use rsync state or compress it and use the archive state. |
How about avoid a doubple-loop and use a single any statement here: - if srcpath not in master_dirs and not any(
- x for x in master_dirs if x.startswith(srcpath + "/")
+ if not any(
+ x for x in master_dirs if x.startswith(srcpath + "/") or x == srcpath
): This could at least save some time when the list is big. |
can also save on the size of the loop by adding a prefix to the |
Last time I look at this, getting meta data from the master about files is not every efficient. It does cache a little bit. |
Closed by #64977 |
Description
file.recurse is > 5x times slower than file.managed even if the directory contains only one file.
Setup
Create this state file:
The directory used as source contains only one file:
Steps to Reproduce the behavior
Run the state file:
file.recurse is 6 times slower than file.managed
Expected behavior
file.recurse speed should be comparable to file.managed if the number of files involved are the same
Versions Report
This is the minion salt version:
This is the master version:
The text was updated successfully, but these errors were encountered: