Skip to content

[osx] Cache the IsOSX check - #2863

Merged
rainersigwald merged 3 commits into
dotnet:masterfrom
alanmcgovern:patch-1
Jan 17, 2018
Merged

rainersigwald merged 3 commits into
dotnet:masterfrom
alanmcgovern:patch-1

Conversation

@alanmcgovern

Copy link
Copy Markdown
Contributor

This ensure we won't hit the filesystem a few million times
during project evaluation.

Fixes mono/mono#6530

Comment thread src/Shared/NativeMethodsShared.cs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be better to make a Lazy<bool> which calls this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suppose a pinvoke is faster than IO, and lazy will also prevent multiple evaluation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I just wanted a minimal patch which can be easily/safely backported to release branches. If we want a more invasive patch it might be frowned on when we go to backport it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

(also, multiple execution is not something that we need to be particularly worried about in this case, so i left it as a simple nullable bool)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, accidentally hitting the filesystem cache twice or three times in an unlucky build seems like a fine tradeoff for the contained, straightforward implementation here.

@rainersigwald rainersigwald left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM modulo bracing nit. Thanks!

Comment thread src/Shared/NativeMethodsShared.cs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, accidentally hitting the filesystem cache twice or three times in an unlucky build seems like a fine tradeoff for the contained, straightforward implementation here.

Comment thread src/Shared/NativeMethodsShared.cs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Our style would prefer braces around this line.

@AndyGerlicher AndyGerlicher left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me (once the { } are added around the if per @rainersigwald. Thanks for the contribution!

This ensure we won't hit the filesystem a few million times
during project evaluation.

Fixes mono/mono#6530
@alanmcgovern

Copy link
Copy Markdown
Contributor Author

Braces have been fixed!

Thanks

@rainersigwald
rainersigwald merged commit a80ce1f into dotnet:master Jan 17, 2018
@rainersigwald

Copy link
Copy Markdown
Member

Thanks!

radical pushed a commit to radical/msbuild that referenced this pull request Jan 17, 2018
This ensures we won't hit the filesystem a few million times
during project evaluation.

Fixes mono/mono#6530.

(cherry picked from commit a80ce1f)
akoeplinger pushed a commit to mono/msbuild that referenced this pull request Jan 17, 2018
This ensures we won't hit the filesystem a few million times
during project evaluation.

Fixes mono/mono#6530.

(cherry picked from commit a80ce1f)
@alanmcgovern

Copy link
Copy Markdown
Contributor Author

It's not thread safe but the only impact of that would be us hitting the filesystem a handful of times instead of just once. Either way we've reduced literally millions of filesystem hits to a tiny bounded number of invocations, typically just 1.

@alanmcgovern
alanmcgovern deleted the patch-1 branch January 19, 2018 04:39
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.

4 participants