Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

SelfHost: Change to callback based responses for better performance #2856

Open
wants to merge 1 commit into
base: 1.x-WorkingBranch
Choose a base branch
from

Conversation

jocull
Copy link

@jocull jocull commented Jan 5, 2018

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the Nancy code style guidelines
  • I have provided test coverage for my change (where applicable)

Description

I noticed that the SelfHost was not performing well when using async methods. You can test a simple endpoint using await Task.Delay(100) and see them queue up as the engine handle blocks waiting for the task. This change converts it to complete/error callbacks so they no longer block. Hope it helps, and please let me know if I missed anything! I'm new here :)

@dnfclas
Copy link

dnfclas commented Jan 5, 2018

CLA assistant check
All CLA requirements met.

try
{
var nancyRequest = this.ConvertRequestToNancyRequest(ctx.Request);
this.engine.HandleRequest(nancyRequest, onComplete, onError);
Copy link
Member

Choose a reason for hiding this comment

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

Where is this overload defined? I think I must be blind, cause I just can't find it 😕

Copy link
Author

Choose a reason for hiding this comment

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

I’m on my phone so I can’t be sure, but I believe this is it. Note that this is on the 1.x branch since I was working against stable.

public static void HandleRequest(

@thecodejunkie
Copy link
Member

@khellang this is a PR sent tot he 1.x-WorkingBranch
@jocull 1.x has been in maintenance mode for quite some time now and I'd rather see you sent this PR against master

@khellang
Copy link
Member

khellang commented Jan 6, 2018

But that overload isn't there in 2.0. We've moved everything over to async/await and Tasks.

@jocull
Copy link
Author

jocull commented Jan 6, 2018

I can try to check this out in 2.x - it may not be an issue in the new versions, but was an issue in the current stable.

@thecodejunkie
Copy link
Member

@jocull yeah it would be great if you could check if it happens on master / latest nuget release

@jocull
Copy link
Author

jocull commented Jan 8, 2018

@thecodejunkie Alright, so here's what I turned up:

  • The latest revision master is all good, it benchmarks just fine
  • The latest on pre-release on nuget 2.0.0-clinteastwood has the same issue as 1.4.4 (didn't investigate, it just benchmarks that way)
  • And of course, the latest stable on nuget 1.4.4 also has this problem, which is patched in this PR

Along the way I noticed that 2.0.0-clinteastwood is very old, over a year, but no new pre-releases to nuget. Is there a roadmap somewhere that shows the 2.x plans?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants