cuteant / SpanNetty

Port of Netty(v4.1.51.Final) for .NET
MIT License
301 stars 47 forks source link

Why use IPromise and not ValueTask for Write/Close/etc ? #48

Closed maksimkim closed 3 years ago

maksimkim commented 3 years ago

I wonder what was the reason to change channel api write methods from Task to IPromise? If it's to have less allocations ValueTask seems better alternative given it's part of CLR today and can simplify usage with await. And it even allow to avoid allocations in most cases: https://tooslowexception.com/implementing-custom-ivaluetasksource-async-without-allocations/ I actually opened corresponding PR in original repo: https://github.com/Azure/DotNetty/pull/375 Are there any benefits of IPromise?

cuteant commented 3 years ago

I like this PR: Azure/DotNetty#375,I didn't notice that before.:sweat_smile:

There is no performance benefit associated with using IPromise......

Netty's thread pool determines that IPromise cannot be completely removed, especially Codes.Http2 is a bit complicated for the use of IPromise.

To be honest, I like Orleans scheduler for single-threaded processing, it's friendly to developers

PS. My English is not good.:sleeping:

cuteant commented 3 years ago

Codes.Http2 is developed based on your http2 branch,Thanks!:raised_hands:

maksimkim commented 3 years ago

@cuteant will you consider accepting PR to SpanNetty to replace IPromise with ValueTask if I create one?

By the way, DotNetty also provides single threaded execution semantic with System.Threading.Task through custom TaskScheduler.

cuteant commented 3 years ago

@maksimkim ,:clap::clap::clap:All right!