mirror of
https://github.com/haproxy/haproxy.git
synced 2026-04-15 21:59:41 -04:00
MEDIUM: stream: Try to use a small buffer for HTTP request on queuing
When a HTX stream is queued, if the request is small enough, it is moved into a small buffer. This should save memory on instances intensively using queues. Applet and connection receive function were update to block receive when a small buffer is in use.
This commit is contained in:
parent
92a24a4e87
commit
5acdda4eed
2 changed files with 14 additions and 2 deletions
|
|
@ -1190,7 +1190,7 @@ int sc_conn_recv(struct stconn *sc)
|
|||
* SE_FL_RCV_MORE on the SC if more space is needed.
|
||||
*/
|
||||
max = channel_recv_max(ic);
|
||||
if ((ic->flags & CF_WROTE_DATA) && b_is_large(sc_ib(sc)))
|
||||
if (b_is_small(sc_ib(sc)) || ((ic->flags & CF_WROTE_DATA) && b_is_large(sc_ib(sc))))
|
||||
max = 0;
|
||||
ret = CALL_MUX_WITH_RET(conn->mux, rcv_buf(sc, &ic->buf, max, cur_flags));
|
||||
|
||||
|
|
@ -1861,7 +1861,7 @@ int sc_applet_recv(struct stconn *sc)
|
|||
* SE_FL_RCV_MORE on the SC if more space is needed.
|
||||
*/
|
||||
max = channel_recv_max(ic);
|
||||
if ((ic->flags & CF_WROTE_DATA) && b_is_large(sc_ib(sc)))
|
||||
if (b_is_small(sc_ib(sc)) || ((ic->flags & CF_WROTE_DATA) && b_is_large(sc_ib(sc))))
|
||||
max = 0;
|
||||
ret = appctx_rcv_buf(sc, &ic->buf, max, flags);
|
||||
if (sc_ep_test(sc, SE_FL_WANT_ROOM)) {
|
||||
|
|
|
|||
12
src/stream.c
12
src/stream.c
|
|
@ -2511,6 +2511,18 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
|
|||
srv = objt_server(s->target);
|
||||
if (scb->state == SC_ST_ASS && srv && srv->rdr_len && (s->flags & SF_REDIRECTABLE))
|
||||
http_perform_server_redirect(s, scb);
|
||||
|
||||
if (unlikely(scb->state == SC_ST_QUE && IS_HTX_STRM(s))) {
|
||||
struct buffer sbuf = BUF_NULL;
|
||||
|
||||
if (!htx_move_to_small_buffer(&sbuf, &req->buf))
|
||||
break;
|
||||
b_free(&req->buf);
|
||||
offer_buffers(s, 1);
|
||||
req->buf = sbuf;
|
||||
DBG_TRACE_DEVEL("request moved to a small buffer", STRM_EV_STRM_PROC, s);
|
||||
}
|
||||
|
||||
} while (scb->state == SC_ST_ASS);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue