Skip to content

Commit

Permalink
Switched to using posted next events after sendfile_max_chunk.
Browse files Browse the repository at this point in the history
Previously, 1 millisecond delay was used instead.  In certain edge cases
this might result in noticeable performance degradation though, notably on
Linux with typical CONFIG_HZ=250 (so 1ms delay becomes 4ms),
sendfile_max_chunk 2m, and link speed above 2.5 Gbps.

Using posted next events removes the artificial delay and makes processing
fast in all cases.
  • Loading branch information
mdounin committed Oct 29, 2021
1 parent 7927071 commit f3fdc4c
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/http/ngx_http_write_filter_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,7 @@ ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
&& c->write->ready
&& c->sent - sent >= limit - (off_t) (2 * ngx_pagesize))
{
c->write->delayed = 1;
ngx_add_timer(c->write, 1);
ngx_post_event(c->write, &ngx_posted_next_events);
}

for (cl = r->out; cl && cl != chain; /* void */) {
Expand Down

0 comments on commit f3fdc4c

Please sign in to comment.