Skip to content

Use MemoryMappedFile API instead of p/invoke win32 calls - #7944

Merged
cartermp merged 3 commits into
dotnet:masterfrom
TIHan:bug/mmf
Dec 8, 2019
Merged

cartermp merged 3 commits into
dotnet:masterfrom
TIHan:bug/mmf

Conversation

@TIHan

@TIHan TIHan commented Dec 7, 2019

Copy link
Copy Markdown
Contributor

Saw that we were using win32 p/invoke calls to do memory mapped files. This removes that by using the built-in framework MemoryMappedFile API.

Also found this was actually brought up a while ago:
#1094
And actually done but never made it in:
#2528

@cartermp cartermp 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.

Even if perf is identical this is a nice bit of cleanup for sure. I would imagine this is good for IDE perf in the long run if the calls to ReadBytes ended up allocating on the LOH. Do you know if this helps that, or would be probably be the same?

@TIHan

TIHan commented Dec 7, 2019 •

Copy link
Copy Markdown
Contributor Author

There shouldn't be any difference in IDE perf for windows. I don't know about other platforms. In general, perf basically did not change when I tested it with benchmark dotnet.

However, the big difference is that other platforms besides windows can use a memory map file.

@KevinRansom KevinRansom 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.

Nice.

@cartermp

cartermp commented Dec 8, 2019

Copy link
Copy Markdown
Contributor

@TIHan Thanks, makes sense. Good to see some more sanity in the codebase and it's good that other this can be used on non-Windows.

@cartermp
cartermp merged commit 7b25d7f into dotnet:master Dec 8, 2019
@dsyme

dsyme commented Dec 12, 2019

Copy link
Copy Markdown
Contributor

Cool! :)

nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Feb 23, 2021
* Remove win32 mmf calls. Use .NET MemoryMappedFile API instead

* Use DangerousGetHandle as it's an implementation detail

* minor cleanup
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