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

Fixed LOH byte array allocations in the IDE from metadata #7971

Merged
merged 12 commits into from
Dec 16, 2019

Conversation

TIHan
Copy link
Contributor

@TIHan TIHan commented Dec 15, 2019

When doing a find all references in VS on a bool type in the VisualFSharp.sln, byte arrays are the top LOH allocations, mainly around FSharp metadata.

This PR should resolve some of it by using memory mapped files. It also unifies the memory handling of both IL and FSharp metadata with the ByteMemory type.

A ByteMemory can be backed by in-memory or memory mapped file data.

Let's see if CI passes. :)

@TIHan TIHan changed the title Fixed LOH byte array allocations in the IDE Fixed LOH byte array allocations in the IDE from metadata Dec 15, 2019
@TIHan
Copy link
Contributor Author

TIHan commented Dec 15, 2019

CI failed not as a result of this change, it's due to this commit: d68942f

@KevinRansom
Copy link
Member

Will #7970 Should fix the CI. It looks to me like the failures here are fixed by #7970

@TIHan
Copy link
Contributor Author

TIHan commented Dec 15, 2019

Great! Thank you!

@TIHan
Copy link
Contributor Author

TIHan commented Dec 15, 2019

This is ready.

Copy link
Contributor

@cartermp cartermp left a comment

Choose a reason for hiding this comment

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

I think the core implementation could be an interface like this: https://gist.github.com/cartermp/e3b3d20f587ecf4cc5e40a06653e3a54

Mostly I feel more comfortable exposing an interface instead of an abstract class in a public contract, and since it's basically just an interface anyways that would feel appropriate. The main downside is that the extension methods have to be in a module.

@TIHan
Copy link
Contributor Author

TIHan commented Dec 15, 2019

I prefer interfaces if everything was self contained in the file and nothing else would use it. Since we are using ByteMemory throughout the compiler, I don't want to use an interface because I don't want some other component to implement their own IByteMemory and use it.

Copy link
Contributor

@cartermp cartermp left a comment

Choose a reason for hiding this comment

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

src/absil/bytes.fs Outdated Show resolved Hide resolved
src/absil/bytes.fs Outdated Show resolved Hide resolved
src/absil/bytes.fs Outdated Show resolved Hide resolved
src/absil/bytes.fs Outdated Show resolved Hide resolved
Copy link
Member

@KevinRansom KevinRansom left a comment

Choose a reason for hiding this comment

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

If you take care of the Exceptions, @cartermp pointed out, this is good.

@TIHan
Copy link
Contributor Author

TIHan commented Dec 16, 2019

Gotcha, will do. Thanks for the feedback!

@TIHan TIHan mentioned this pull request Dec 16, 2019
3 tasks
@TIHan
Copy link
Contributor Author

TIHan commented Dec 16, 2019

@cartermp I think this is ready with the feedback changes.

@cartermp cartermp merged commit 1e8edef into dotnet:master Dec 16, 2019
@cartermp cartermp mentioned this pull request Dec 16, 2019
10 tasks
@cartermp cartermp mentioned this pull request Jan 17, 2020
5 tasks
nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Feb 23, 2021
* Fixed LOH byte array allocations in the IDE. Unified memory handling for IL and FSharp metadata.

* minor cleanup

* minor cleanup

* rename EmitBytes to EmitByteMemory

* Fixed ByteArrayMemory

* fixing build

* Fixing build again

* Better ReadInt32/ReadUInt16

* ILResourceLocation.Local should use a ReadOnlyByteMemory

* Able to have a ReadOnlyStream

* Using OutOfRangeException according to feedback
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