Commit
5ff6ff1b7 ("MINOR: http-ana: automatically enable http-no-delay
for streaming events (SSE)") added detection for SSE, but as reported
in GH issue #3574, it fails when there's a parameter after the content
type because we're using an exact match. Let's instead use istmatchi()
that will check the beginning of the string (which is sufficient here).
Before:
=== gateway overhead (gateway minus loopback; negative = loopback noise) ===
emit->recv (1st token) mean +214.379ms p50 +214.379ms p95 +214.379ms p99 +214.379ms
emit->recv (tokens) mean +303.484ms p50 +307.784ms p95 +405.797ms p99 +413.876ms
TTFT (client) mean +214.775ms p50 +214.775ms p95 +214.775ms p99 +214.775ms
inter-token (client) mean -0.026ms p50 -1.069ms p95 -1.260ms p99 -1.271ms
After:
=== gateway overhead (gateway minus loopback; negative = loopback noise) ===
emit->recv (1st token) mean +0.046ms p50 +0.046ms p95 +0.046ms p99 +0.046ms
emit->recv (tokens) mean +0.214ms p50 +0.234ms p95 +0.305ms p99 +0.322ms
TTFT (client) mean +0.493ms p50 +0.493ms p95 +0.493ms p99 +0.493ms
inter-token (client) mean -0.001ms p50 +0.230ms p95 +0.283ms p99 +0.299ms
This should be backported to 3.4 since the commit above is already there.
Thanks to @glenn-jocher for reporting and diagnosinc this limitation.
struct http_hdr_ctx ctx = { .blk = NULL };
if (http_find_header(htx, ist("content-type"), &ctx, 0) &&
- isteqi(ctx.value, ist("text/event-stream"))) {
+ istmatchi(ctx.value, ist("text/event-stream"))) {
s->scf->flags |= SC_FL_SND_NEVERWAIT;
s->scb->flags |= SC_FL_SND_NEVERWAIT;
}