Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Conversation

@benaadams
Copy link
Contributor

@benaadams benaadams commented Nov 11, 2018

Currently a lot of contention on the lock

image

Go through the lock if its not already doing work; otherwise skip the lock.

Submit work to threadpool outside the lock

After contention is much reduced

image

Also removes QUWIC allocations from the IOQueue on .NET Core 3.0

image

Resolves: https://github.com/aspnet/KestrelHttpServer/issues/3042

@benaadams benaadams force-pushed the IOQueue-lock-contention branch 2 times, most recently from 785f553 to 33ce433 Compare November 12, 2018 00:02
@benaadams benaadams closed this Nov 12, 2018
@benaadams benaadams reopened this Nov 12, 2018
@halter73
Copy link
Member

halter73 commented Nov 12, 2018

Are there any benchmarks results for this? I see how in this reduces lock contention in Schedule() when DoWork() is in progress, but it does add a Volatile.Read() in Schedule() and the Volatile.Write() in DoWork() each time DoWork() needs to be restarted.

@benaadams
Copy link
Contributor Author

Are there any benchmarks results for this?

Added a PR for 2.2 branch for easy benchmarking #3096

I see how in this reduces lock contention in Schedule() when DoWork() is in progress, but it does add a Volatile.Read() in Schedule() and the Volatile.Write() in DoWork() each time DoWork() needs to be restarted.

The Volatile.Read and Volatile.Write should be fairly free on x64 (as there are no register benefits); but does allow it to more often skip Interlocked.CompareExchange; spinning and sleeping from the lock.

Arm would have more costs from the Volatile calls

@benaadams
Copy link
Contributor Author

Actually, should be able to drop the lock entirely here

@benaadams benaadams force-pushed the IOQueue-lock-contention branch from 8c56cdc to 09626a0 Compare November 13, 2018 03:17
@benaadams benaadams changed the title Reduce lock contention in IOQueue Remove lock contention in IOQueue Nov 13, 2018
@benaadams benaadams force-pushed the IOQueue-lock-contention branch from b1df699 to 2ccbccf Compare November 13, 2018 15:36
@muratg
Copy link
Contributor

muratg commented Dec 17, 2018

Kestrel work has moved to aspnetcore repo, and this repo will be archived. If you're still interested in pursuing this PR, please move it over to aspnetcore. Thanks.

@muratg muratg closed this Dec 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants