Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Clean naming and disable stack pathhelper #3010

Merged
merged 1 commit into from
Aug 29, 2015

Conversation

JeremyKuhne
Copy link
Member

PathHelper doesn't handle growing past MAX_PATH when using
the stackalloc version. #3009 tracks this.

@weshaggard, @stephentoub, @Priya91

PathHelper doesn't handle growing past MAX_PATH when using
the stackalloc version. #3009 tracks this.
{
newBuffer = new PathHelper(path.Length + MaxPath, maxPathLength);
}
PathHelper newBuffer = new PathHelper(path.Length + MaxPath, maxPathLength);
Copy link
Member

Choose a reason for hiding this comment

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

Do we know the perf impact of this change? Should we still use stackalloc for smaller paths?

Copy link
Member Author

Choose a reason for hiding this comment

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

I can't because the stackalloc cannot grow currently. I've opened an issue on it and will fix so we can dynamically move up to the heap.

Copy link
Member

Choose a reason for hiding this comment

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

Isn't there a known maximum amount by which it will need to grow, measured in just a few characters? If so, couldn't we just proactively make the stackalloc'd size that much larger?

Copy link
Member Author

Choose a reason for hiding this comment

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

Technically it shouldn't go beyond 520 characters (start with 260 relative and add to current directory). But there is no guarantee of that- I know of ways you can leak long paths into GetCurrentDirectory, and there might be others. There is also some hope that current directory will support > 260 in the future. I've got a lot of ideas about how to approach this issue- any pointers to perf experts would be appreciated. (One thought is a thread local string builder cache for path normalization.)

Copy link
Member

Choose a reason for hiding this comment

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

If StringBuilderCache solves the need here, I'm fine with that. We'd want to make sure, though, that this particular usage didn't end up poisoning the cache, since IIRC StringBuilderCache only puts builders back into the cache if their capacity is below a threshold.

@weshaggard
Copy link
Member

Renames look reasonable to me. I just had the one question but you have filed an issue tracking that so you could use it for thinking about the perf impact as well.

JeremyKuhne added a commit that referenced this pull request Aug 29, 2015
Clean naming and disable stack pathhelper
@JeremyKuhne JeremyKuhne merged commit 4ac67b6 into dotnet:master Aug 29, 2015
[DllImport(Libraries.CoreFile_L1, SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)]
internal unsafe static extern int GetFullPathNameW(char* path, int numBufferChars, char* buffer, IntPtr mustBeZero);
[DllImport(Libraries.CoreFile_L1, EntryPoint = "GetFullPathNameW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)]
internal unsafe static extern int GetFullPathNameUnsafe(char* path, int numBufferChars, char* buffer, IntPtr mustBeZero);
Copy link
Member

Choose a reason for hiding this comment

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

Why does this one have a different suffix? It can't be an overload of GetFullPathNamePrivate?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because it is internal and unsafe. It is used by the PathHelper class. Best I could come up with, but always open to suggestions.

Copy link
Member

Choose a reason for hiding this comment

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

There are lots of methods that use unsafe code / take ptr arguments that don't have Unsafe in the name. More importantly, though, that's not the defining characteristic with regards to these various methods: the important thing we want to highlight is that it doesn't handle long paths / doesn't provide the wrapping behavior. How about using "Core" as the suffix, to highlight that it's the core functionality, and then the other things wrap it? Ideally we'd use it consistently instead of using "Private" in some places and other suffixes in others. If we can't do that, I'd prefer something like "Native" here, since it at least that highlights that this is the Win32 P/Invoke function.

@JeremyKuhne JeremyKuhne deleted the NameCleanup branch September 28, 2015 22:17
@karelz karelz modified the milestone: 1.0.0-rtm Dec 3, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Clean naming and disable stack pathhelper

Commit migrated from dotnet/corefx@4ac67b6
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants