Skip to content

Conversation

@TIHan
Copy link
Contributor

@TIHan TIHan commented Jun 9, 2021

loh
We allocate a lot on the LOH when serializing FSharp metadata. This PR should help.

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 like the approach, and it seems great to not constantly reallocate those large buffers.

@TIHan TIHan changed the title [WIP] Byte buffer uses ArrayPool to prevent LOH allocations Byte buffer uses ArrayPool to prevent LOH allocations Jun 9, 2021
@TIHan TIHan changed the title Byte buffer uses ArrayPool to prevent LOH allocations ByteBuffer uses ArrayPool to prevent LOH allocations Jun 10, 2021
@TIHan TIHan changed the title ByteBuffer uses ArrayPool to prevent LOH allocations ByteBuffer uses ArrayPool to prevent LOH allocations Jun 10, 2021
https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-impl/nuget/v3/index.json;
</RestoreSources>
<!-- System.* packages -->
<SystemRuntimeCompilerServicesUnsafeVersion>4.7.1</SystemRuntimeCompilerServicesUnsafeVersion>
Copy link
Contributor Author

@TIHan TIHan Jun 14, 2021

Choose a reason for hiding this comment

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

@KevinRansom you may not like this, but the changes I made with the ByteBuffer, is calling something from System.Runtime.CompilerServices.Unsafe, which has problems with binding redirects. Best way to resolve this is including the specific version.

Copy link
Contributor

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

This looks goods, I wonder why we have so many different sizes for allocation buffers, 100000, 50000, 20000 and 10000. Meaningful names might help me understand why each size was chosen, Of course it might not too.

let phase2data = (stringTab, phase1bytes)

let st2 =
{ os = ByteBuffer.Create(100000, useArrayPool = true)
Copy link
Contributor

Choose a reason for hiding this comment

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

possibly a constant for 100000, it's used several places in this code.

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 have no idea why these values were chosen. This was here before.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, just give it a name. pickle_object_buffersize or somesuch.

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 added the literals.

requiredDataFixups= requiredDataFixups
requiredStringFixups = []
codeChunks=ByteBuffer.Create 40000
codeChunks=ByteBuffer.Create(40000, useArrayPool = true)
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps constant for 40000

codedBigness 2 TableNames.TypeRef

let tablesBuf = ByteBuffer.Create 20000
use tablesBuf = ByteBuffer.Create(20000, useArrayPool = true)
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps a name and a constant for 20000


let metadata, guidStart =
let mdbuf = ByteBuffer.Create 500000
use mdbuf = ByteBuffer.Create(500000, useArrayPool = true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps a name and a constant for 50000?

@TIHan
Copy link
Contributor Author

TIHan commented Jun 15, 2021

Addresses this issue: #7982
Only took a year and a half...

@TIHan TIHan closed this Jun 15, 2021
@TIHan TIHan reopened this Jun 15, 2021
@TIHan TIHan closed this Jun 16, 2021
@TIHan TIHan reopened this Jun 16, 2021
@TIHan TIHan closed this Jun 16, 2021
@TIHan TIHan reopened this Jun 16, 2021
@TIHan TIHan closed this Jun 16, 2021
@TIHan TIHan reopened this Jun 16, 2021
@cartermp
Copy link
Contributor

note that azdo is down for us, so there's no point in trying to re-trigger CI

@TIHan TIHan merged commit f13b4ff into dotnet:main Jun 16, 2021
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