-
-
Notifications
You must be signed in to change notification settings - Fork 608
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
Reduce the number of calls to the filesystem to see if a module file exists #14582
Conversation
|
Thanks for your pull request, @schveiguy! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#14582" |
| @@ -139,7 +234,6 @@ nothrow: | |||
| } | |||
| FileName.free(n2.ptr); | |||
| } | |||
| FileName.free(n.ptr); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, I moved this to a scope(exit) on line 217 because it was a memory leak if the package.d file was found.
|
Why do we need to look at all the parent paths rather than just bottom-most parent? |
|
Top-most parent might exist, even though the module isn't there. e.g. https://github.com/MartinNowak/io/tree/master/src/std/io What we really need is to determine if any parent doesn't exist. |
|
Sorry, I don't understand this without a use case. Do you want to cache calls to directory scans? |
|
So if project a has source modules in: projecta/source/foo/a and project b has source modules in: projectb/source/foo/b and you import Your proposal would have it just do: Less steps, but the stats are more (12 vs 11). Think about vibe.d, which has all its projects start with |
There are no directory scans here. |
|
@schveiguy I retriggered failing CircleCI |
| } | ||
| } | ||
| // found a parent that is cached (or reached the end of the stack). | ||
| // step 2, traverse back up the stack storing either false if the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
traverse back up
This should be
"traverse back down"
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah could be. Not really great terminology.
I guess it would be value to the reviewers of this PR documenting how much this number drop when compiling Phobos with the branch of this PR. |
|
Great work getting this merged so quickly. On Ubuntu 22.10, I just tested dmd master as echo > app.d && strace -e newfstatat dmd -c app.d -o-at it seems there's still some redundant stats of .d files happening as show in the output . In this run, Every .d under |
I think that's the part that's reading the file data, not from this PR. Was it happening before this change? The checks for the empty path also don't seem to be reasonable, but I don't know where those come from either. |
You can have gdb stop on a system call using catchpoints. For details see
According to the docs there is no way to filter on specific (string) arguments passed to the syscall, though. That would be very convenient in this case. Do you know of a way to accomplish such filtering, @ibuclaw? |
In a work project, this reduces the number of
statcalls from 127_416 to 9_909.This works by short-circuiting the stat calls if the parent directory is known not to exist.
With current dmd and this project, due to the
-Iparameters for each dependency (of which there are many), importing one module from phobos would result in 335 stat calls.