KestrelHttpServer icon indicating copy to clipboard operation
KestrelHttpServer copied to clipboard

Properly return pooled blocks in SocketInput

Open halter73 opened this issue 10 years ago • 8 comments

When I was investigating #579, I discovered that all of the blocks getting finalized in the app I was using repro the issue were last leased by SocketInput.IncomingStart.

It appears that the last incoming block will never be returned even if it is fully consumed.

halter73 avatar Jan 14 '16 23:01 halter73

This seems like a really simple fix, yes? If so, I'd like to see this done in RC2.

DamianEdwards avatar Jan 22 '16 18:01 DamianEdwards

If it's not a straightforward quick fix, let's move it to backlog

muratg avatar Jan 22 '16 18:01 muratg

Measurement across 1M non keep-alive requests; majority of the highlighted byte[] is the blocks not being returned early enough from the SocketInput

non-keepalive-connections

benaadams avatar Feb 13 '16 03:02 benaadams

@sivagms - This might be the issue that Martin was trying to fix today due to the incorrect finalization. Do you want to take a look since you know the fix he was talking about?

sajayantony avatar Feb 13 '16 04:02 sajayantony

@SajayAntony I assumed it was in this fix? https://github.com/aspnet/KestrelHttpServer/pull/623 (though haven't measured)

benaadams avatar Feb 13 '16 04:02 benaadams

btw.. @halter73 ryan has moved these benchmark and loadtest apps here

@benaadams :tired_face: I hadn't seen that PR and I've just joined this party :)

sajayantony avatar Feb 13 '16 04:02 sajayantony

@halter73 added PR for how I generated this https://github.com/aspnet/Performance/pull/48

benaadams avatar Feb 13 '16 04:02 benaadams

I noticed this as well last Friday. Under load, with a significant number of new connections being made, the finalizer queue falls behind and the memory blocks waiting in the queue can quickly exceed 1 GB. A simple fix for this would be to return the block held by SocketInput on connection close.

martinpf avatar Feb 16 '16 19:02 martinpf