mongo-csharp-driver icon indicating copy to clipboard operation
mongo-csharp-driver copied to clipboard

CSHARP-2456: Use explicit function instead of anonymous

Open mitikov opened this issue 5 years ago • 5 comments

Anonymous function has to capture 'this' as well as parameter since it calls object instance method.

Each invocation ended allocating 32 bytes, sample print:

0000028151aca4c0 (MongoDB.Bson.IO.BsonWriter+<>c__DisplayClass44_0)
    <>4__this:0000028151ac8fd0 (MongoDB.Bson.IO.JsonWriter)
    name:000002824ee886b0 (System.String) Length=11, String="_odata_type"

Function is called super-often, memory snapshots indicate ~1M instances are leaving in the heap.

mitikov avatar Oct 15 '18 03:10 mitikov

@craiggwilson, @rstam

Hi folks, please take a look at a small performance pill.

Thanks.

mitikov avatar Oct 15 '18 03:10 mitikov

@rstam, @craiggwilson its been a month since PR creation time =/

Could you please review this tiny change?

mitikov avatar Nov 26 '18 06:11 mitikov

@vincentkam - seem you've participated in the last completed PR in the repo, could you please take a look at this one as well?

Thanks.

mitikov avatar Nov 29 '18 23:11 mitikov

Hi @mitikov, thanks for opening this pull request, and my apologies for the delay in response here. The MongoDB .NET team relies primarily on our JIRA project to track and prioritize our work.

In order to continue the conversation, can you please open a ticket at the above link so we can discuss your proposal there?

IanWhalen avatar Dec 07 '18 18:12 IanWhalen

@IanWhalen created 2456 PBI: Use less memory without scope capturing.

Thank you.

mitikov avatar Dec 14 '18 05:12 mitikov

Hi @mitikov, thanks for this pull request and our apologies for the very late feedback here. We implemented this change as part of another PR: https://github.com/mongodb/mongo-csharp-driver/pull/1265 that was changing the same code area and did see any actual performance improvements worth the changes. So we will close this PR and associated ticket.

adelinowona avatar Feb 20 '24 16:02 adelinowona

This PR was actually included as part of PR https://github.com/mongodb/mongo-csharp-driver/pull/1290

Thank you for submitting it.

rstam avatar Mar 13 '24 17:03 rstam