stash / Feersum

A PSGI engine for Perl based on EV/libev
http://search.cpan.org/~stash/Feersum/
74 stars 15 forks source link

native interface: access specific parts of request #35

Closed vividsnow closed 3 months ago

vividsnow commented 3 years ago

Hello

This patch gives access to specific parts of feersum connection/request: method uri path query content_length remote_address remote_port headers input. Thus gives performance boost in some scenarios.

Serving native handler via unix-socket behind nginx:

sub ($r) {
    my ($method, $path) = ($r->method, $r->path);
    $r->send_response(200, [qw'content-type text/plain'], ["$method:$path"]);
}

is ~15% faster than psgi handler

sub ($env) {
    my ($method, $path) = @$env{uc'request_method', uc'path_info'};
    [200, [qw'content-type text/plain'], ["$method:$path"]]
}

p.s. there is no performance penalty comparing to current version p.p.s. tested under linux, gcc 10, perl-5.34.0, perl-5.8.9

audreyt commented 3 years ago

Hi! Thank you for the contribution. Sorry for the late reply, but I currently do not have the capacity to review & merge this pull request.

If @stash can chime in that would be great, otherwise we may have to wait until someone volunteers time to assume maintainership.

vividsnow commented 3 months ago

Hi! I'd like to help maintain Feersum if nobody is currently doing so, and move it a bit forward by adding features such as accept4, tcp defer and keepalive support. I've already worked on these features and have used them in production. my cpan

cheers

stash commented 3 months ago

Hi @vividsnow - I'm going to try check this PR over, but fair warning that I'm incredibly rusty at Perl. I would love for all of our work here to be maintained... @audreyt if you have a moment can you DM/email me your thoughts? Thank you both for carrying the torch.

Can you please reference an official source for ppport.h? 14kLoC is too large to review, so I'd like to diff against that.

stash commented 3 months ago

I'll wait until 2024-07-30T19:00:00-08:00 (7PM, Tues, June 30th, PDT, about a week from now) to hear back from @audreyt, who's been the main maintainer for years, or any of the other contributors, before taking action on adding you as co-maintainer or transferring maintainership.

If somehow I disappear again, https://www.cpan.org/modules/04pause.html outlines the steps to take over, but we'll try the direct approach first ;)

stash commented 3 months ago

Oh maybe @audreyt already has it: https://metacpan.org/dist/Feersum

vividsnow commented 3 months ago

@stash Hi, thanks for the review. I'll check your points.

ppport.h was rendered by specific version of Devel::PPPort https://metacpan.org/release/ATOOMIC/Devel-PPPort-3.62/view/PPPort.pm - I'll update it once again with current Devel::PPPort version (https://metacpan.org/pod/Devel::PPPort, which is 3.68)

stash commented 3 months ago

ppport.h was rendered by specific version of Devel::PPPort https://metacpan.org/release/ATOOMIC/Devel-PPPort-3.62/view/PPPort.pm - I'll update it once again with current Devel::PPPort version (https://metacpan.org/pod/Devel::PPPort, which is 3.68)

Looks like Devel::PPPort 3.72 ships with Perl 5.40.0, and the file checked in matches that. The CPAN one is outdated now. Looks good; just FYI.

stash commented 3 months ago

Merged. Let's wait to see if anyone else responds before releasing to CPAN. FYI looks like picohttpparser has some recent updates.

stash commented 3 months ago

Alright @vividsnow, it's time: invited you to collab on this repo and added you as comaint on PAUSE. Thank you so much for your contributions and willingness to carry this forward. Please email me (address is on CPAN) if you need anything else. I can try do some code review if you'd like, but don't wait for me!

vividsnow commented 3 months ago

Thank you for the trust, @stash. I'll do my best