Skip to content

Consider single field StringValues #1290

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

Closed
benaadams opened this issue Mar 20, 2019 · 0 comments
Closed

Consider single field StringValues #1290

benaadams opened this issue Mar 20, 2019 · 0 comments

Comments

@benaadams
Copy link
Member

benaadams commented Mar 20, 2019

Saw this while doing some disassembling dotnet/coreclr#9039 where assigning to StringValues

G_M28429_IG07:
       48B94096F52B5C020000 mov      rcx, 0x25C2BF59640
       488B09               mov      rcx, gword ptr [rcx]
       488BD5               mov      rdx, rbp
       41B805000000         mov      r8d, 5
       E822ADF95A           call     String:Equals(ref,int):bool:this
       85C0                 test     eax, eax
       0F8427080000         je       G_M28429_IG40
       48814B2800000800     or       qword ptr [rbx+40], 0x80000
       488DBB80010000       lea      rdi, bword ptr [rbx+384]
       E89667AE5F           call     CORINFO_HELP_ASSIGN_BYREF
       E89167AE5F           call     CORINFO_HELP_ASSIGN_BYREF
       E942080000           jmp      G_M28429_IG41

It does a double reference assign + write barrier CORINFO_HELP_ASSIGN_BYREF.

Also it means data structures like FrameRequestHeaders.HeaderReferences is 688 bytes and FrameResponseHeaders.HeaderReferences is 592 bytes; so clearing needs to Memset quite a large amount of data; and Kestrel has a "faster" path where under 12 headers it does a bit count; then steps though all the headers checking if they are set and clearing them (with early bail)

The double ptr struct field also causes knock on issues like "FrameRequestHeaders:AppendNonPrimaryHeaders uses (and zeros) 888 bytes of stack" aspnet/KestrelHttpServer#1317 (issue in coreclr dotnet/coreclr#9041)

An example of how this could be done is: benaadams/extensions@0b567e9; however there are knock on issues around foreach vs for patterns and I haven't confirmed it would be a net win, so am not making a PR for this at this time.

Previous issues: #185, dotnet/aspnetcore#2367

@Tratcher Tratcher added this to the 3.0.0-preview4 milestone Mar 27, 2019
@Tratcher Tratcher added the Perf label Mar 27, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants