Commit 60a3e730 authored by Nils Goroll's avatar Nils Goroll

Fill the brotli input buffer

this can save calls into the brotli code.

Note: I thought we might be able to avoid the additional ring buffer
copy in the brotli encode by using a buffer of size 1 << lgblock, but the
brotli code calls RingBufferWrite() even if the input buffer holds all
of the data to be compressed.
parent 6f5607d9
......@@ -23,7 +23,21 @@ Enim per accumsan, augue id maecenas bibendum ullamcorper in fermentum, platea f
rxreq
txresp -nolen -hdr "Transfer-encoding: chunked"
chunkedlen 131072
chunkedlen 8
chunkedlen 8
chunkedlen 16
chunkedlen 32
chunkedlen 64
chunkedlen 128
chunkedlen 256
chunkedlen 512
chunkedlen 1024
chunkedlen 2048
chunkedlen 4096
chunkedlen 8192
chunkedlen 16384
chunkedlen 32768
chunkedlen 65536
chunkedlen 0
} -start
......
......@@ -386,7 +386,7 @@ vfp_br_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr,
ssize_t *lenp)
{
struct vbr *vbr;
ssize_t len, dl;
ssize_t len, l, dl;
enum vfp_status vp = VFP_ERROR;
int finished = 0;
BROTLI_BOOL done;
......@@ -407,8 +407,12 @@ vfp_br_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr,
do {
if (isInputBufEmpty(vbr)) {
len = vbr->bufsz;
vp = VFP_Suck(ctx, vbr->buf, &len);
len = 0;
do {
l = vbr->bufsz - len;
vp = VFP_Suck(ctx, vbr->buf + len, &l);
len += l;
} while (vp == VFP_OK && len < vbr->bufsz);
if (vp == VFP_ERROR)
break;
if (vp == VFP_END)
......@@ -439,7 +443,7 @@ vfp_unbr_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr,
ssize_t *lenp)
{
struct vbr *vbr;
ssize_t len, dl;
ssize_t len, l, dl;
enum vfp_status vp = VFP_ERROR;
BrotliDecoderResult result = BROTLI_DECODER_RESULT_ERROR;
const struct vfp_priv *priv;
......@@ -459,8 +463,12 @@ vfp_unbr_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr,
do {
if (isInputBufEmpty(vbr)) {
len = vbr->bufsz;
vp = VFP_Suck(ctx, vbr->buf, &len);
len = 0;
do {
l = vbr->bufsz - len;
vp = VFP_Suck(ctx, vbr->buf + len, &l);
len += l;
} while (vp == VFP_OK && len < vbr->bufsz);
if (vp == VFP_ERROR)
break;
setInputBuf(vbr, vbr->buf, len);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment