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

Canonicalize path in DiskInterface::Stat for windows #1420

Closed
wants to merge 1 commit into from

Conversation

atetubou
Copy link
Contributor

@atetubou atetubou commented Apr 9, 2018

Without canonicalization, "subdir/." and "subdir" are treated like below and test takes stat from unintended files.

Dirname("subdir/.") => "subdir"
Basename("subdir/.") => "."

Dirname("subdir") => ""
Basename("subdir") => "subdir"

This is followup of #1365

@atetubou atetubou force-pushed the fix_test branch 2 times, most recently from 7957ee6 to 9a3dd31 Compare April 9, 2018 07:16
@@ -156,24 +156,34 @@ bool DiskInterface::MakeDirs(const string& path) {
TimeStamp RealDiskInterface::Stat(const string& path, string* err) const {
METRIC_RECORD("node stat");
#ifdef _WIN32
uint64_t slash_bits = 0;
string canonicalized_path = path;
if (!CanonicalizePath(&canonicalized_path, &slash_bits, err)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stat() is called frequently, and CanonicalizePath() isn't super fast – have you measured what this does to empty build times on a large-ish project (my go-to project is Chromium; llvm is probably too small to get statistically relevant numbers) with the stat cache disabled (-d nostatcache)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took empty build time of "ninja -C out/Release -d nostatcache base" on chromium repository with this patch and ninja 1.8.2 on Windows 10 3 times.

With ninja 1.8.2
3.3424782s
3.0806936s
2.9474454s

With this patch
2.9908952s
3.1358611s
3.1082572s

This does not show visible performance change. I think stat on windows itself has much higher cost than CanonicalizePath here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, any canonicalization that is necessary should happen before a path reaches the call to stat(). In other places we expect two references to the "same" path to have exactly the same string representation, so it's important to canonicalize early.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then let me remove such tests.
#1423

@nico
Copy link
Collaborator

nico commented Apr 9, 2018

Thanks for jumping on this!

It looks like it might be slow; maybe we should revert the original patch instead?

@moroten, opinions?

@nico
Copy link
Collaborator

nico commented Apr 10, 2018

Closing for now with #1421 applied instead. It sounds like there's more to do, but maybe not this, not sure.

@nico nico closed this Apr 10, 2018
@atetubou
Copy link
Contributor Author

I think #1421 does not make appveyor happy. Depends on disk write timing, it can pass and fail.
https://ci.appveyor.com/project/atetubou/ninja/build/1.0.18

So we need to do canonicalization yet or disallow non-canonicalized path in Stat.

ikifof pushed a commit to ikifof/ninja that referenced this pull request Oct 31, 2018
ikifof pushed a commit to ikifof/ninja that referenced this pull request Nov 5, 2018
ikifof pushed a commit to ikifof/ninja that referenced this pull request Nov 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants