Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvfp-brotli
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvfp-brotli
Commits
24b971bf
Commit
24b971bf
authored
Feb 15, 2019
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the in statistic -- input bytes processed by the de-/compressor.
parent
8a5c0740
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
4 deletions
+44
-4
brotli.vsc
src/brotli.vsc
+6
-0
stats.vtc
src/tests/stats.vtc
+16
-0
vfp_brotli.c
src/vfp_brotli.c
+22
-4
No files found.
src/brotli.vsc
View file @
24b971bf
...
...
@@ -18,4 +18,10 @@
Total number of bytes output by the de-/compressor
.. varnish_vsc:: in
:type: counter
:oneliner: Input bytes
Total number of input bytes processed by the de-/compressor
.. varnish_vsc_end:: brotli
src/tests/stats.vtc
View file @
24b971bf
...
...
@@ -36,8 +36,10 @@ client c1 -run
varnish v1 -vsc BROTLI.*
varnish v1 -expect BROTLI.br.ops == 10
varnish v1 -expect BROTLI.br.in > 0
varnish v1 -expect BROTLI.br.out > 0
varnish v1 -expect BROTLI.unbr.ops == 10
varnish v1 -expect BROTLI.unbr.in > 0
varnish v1 -expect BROTLI.unbr.out > 0
varnish v1 -vcl+backend {
...
...
@@ -61,8 +63,10 @@ varnish v1 -cliok "vcl.list"
varnish v1 -vsc BROTLI.*
varnish v1 -expect BROTLI.br.ops == 10
varnish v1 -expect BROTLI.br.in > 0
varnish v1 -expect BROTLI.br.out > 0
varnish v1 -expect BROTLI.unbr.ops == 10
varnish v1 -expect BROTLI.unbr.in > 0
varnish v1 -expect BROTLI.unbr.out > 0
server s1 -wait
...
...
@@ -71,12 +75,16 @@ client c1 -run
varnish v1 -vsc BROTLI.*
varnish v1 -expect BROTLI.br.ops == 10
varnish v1 -expect BROTLI.br.in > 0
varnish v1 -expect BROTLI.br.out > 0
varnish v1 -expect BROTLI.unbr.ops == 10
varnish v1 -expect BROTLI.unbr.in > 0
varnish v1 -expect BROTLI.unbr.out > 0
varnish v1 -expect BROTLI.vcl2.mybr.ops == 10
varnish v1 -expect BROTLI.vcl2.mybr.in > 0
varnish v1 -expect BROTLI.vcl2.mybr.out > 0
varnish v1 -expect BROTLI.vcl2.myunbr.ops == 10
varnish v1 -expect BROTLI.vcl2.myunbr.in > 0
varnish v1 -expect BROTLI.vcl2.myunbr.out > 0
varnish v1 -vcl+backend {}
...
...
@@ -87,20 +95,26 @@ varnish v1 -cliok "vcl.state vcl2 cold"
# This has to be checked manually in the log.
varnish v1 -vsc BROTLI.vcl2.*
varnish v1 -expect BROTLI.br.ops == 10
varnish v1 -expect BROTLI.br.in > 0
varnish v1 -expect BROTLI.br.out > 0
varnish v1 -expect BROTLI.unbr.ops == 10
varnish v1 -expect BROTLI.unbr.in > 0
varnish v1 -expect BROTLI.unbr.out > 0
varnish v1 -cliok "vcl.state vcl2 warm"
# With vcl2 back in the warm state, stats for vcl2.* appear again.
varnish v1 -expect BROTLI.br.ops == 10
varnish v1 -expect BROTLI.br.in > 0
varnish v1 -expect BROTLI.br.out > 0
varnish v1 -expect BROTLI.unbr.ops == 10
varnish v1 -expect BROTLI.unbr.in > 0
varnish v1 -expect BROTLI.unbr.out > 0
varnish v1 -expect BROTLI.vcl2.mybr.ops == 10
varnish v1 -expect BROTLI.vcl2.mybr.in > 0
varnish v1 -expect BROTLI.vcl2.mybr.out > 0
varnish v1 -expect BROTLI.vcl2.myunbr.ops == 10
varnish v1 -expect BROTLI.vcl2.myunbr.in > 0
varnish v1 -expect BROTLI.vcl2.myunbr.out > 0
varnish v1 -cliok "vcl.state vcl2 cold"
...
...
@@ -109,6 +123,8 @@ varnish v1 -cliok "vcl.list"
varnish v1 -vsc BROTLI.vcl2.*
varnish v1 -expect BROTLI.br.ops == 10
varnish v1 -expect BROTLI.br.in > 0
varnish v1 -expect BROTLI.br.out > 0
varnish v1 -expect BROTLI.unbr.ops == 10
varnish v1 -expect BROTLI.unbr.in > 0
varnish v1 -expect BROTLI.unbr.out > 0
src/vfp_brotli.c
View file @
24b971bf
...
...
@@ -246,15 +246,17 @@ setOutputBuf(struct vbr *vbr, const void *ptr, ssize_t len)
}
static
BROTLI_BOOL
encode
(
struct
vbr
*
vbr
,
ssize_t
*
dl
,
int
finished
)
encode
(
struct
vbr
*
vbr
,
ssize_t
*
dl
,
int
finished
,
struct
VSC_brotli
*
stats
)
{
BROTLI_BOOL
ret
;
const
uint8_t
*
before
;
size_t
inb4
;
enum
BrotliEncoderOperation
op
=
BROTLI_OPERATION_PROCESS
;
CHECK_OBJ_NOTNULL
(
vbr
,
VBR_MAGIC
);
assert
(
vbr
->
which
==
ENC
);
before
=
vbr
->
stream
.
next_out
;
inb4
=
vbr
->
stream
.
avail_in
;
if
(
finished
)
op
=
BROTLI_OPERATION_FINISH
;
...
...
@@ -265,18 +267,24 @@ encode(struct vbr *vbr, ssize_t *dl, int finished)
&
vbr
->
stream
.
next_out
,
&
vbr
->
stream
.
total_out
);
*
dl
=
(
const
uint8_t
*
)
vbr
->
stream
.
next_out
-
before
;
if
(
stats
!=
NULL
)
{
assert
(
inb4
>=
vbr
->
stream
.
avail_in
);
stats
->
in
+=
(
inb4
-
vbr
->
stream
.
avail_in
);
}
return
(
ret
);
}
static
BrotliDecoderResult
decode
(
struct
vbr
*
vbr
,
ssize_t
*
dl
)
decode
(
struct
vbr
*
vbr
,
ssize_t
*
dl
,
struct
VSC_brotli
*
stats
)
{
BrotliDecoderResult
ret
;
const
uint8_t
*
before
;
size_t
inb4
;
CHECK_OBJ_NOTNULL
(
vbr
,
VBR_MAGIC
);
assert
(
vbr
->
which
==
DEC
);
before
=
vbr
->
stream
.
next_out
;
inb4
=
vbr
->
stream
.
avail_in
;
ret
=
BrotliDecoderDecompressStream
(
vbr
->
state
.
dec
,
&
vbr
->
stream
.
avail_in
,
...
...
@@ -285,6 +293,10 @@ decode(struct vbr *vbr, ssize_t *dl)
&
vbr
->
stream
.
next_out
,
&
vbr
->
stream
.
total_out
);
*
dl
=
(
const
uint8_t
*
)
vbr
->
stream
.
next_out
-
before
;
if
(
stats
!=
NULL
)
{
assert
(
inb4
>=
vbr
->
stream
.
avail_in
);
stats
->
in
+=
(
inb4
-
vbr
->
stream
.
avail_in
);
}
return
(
ret
);
}
...
...
@@ -380,10 +392,13 @@ vfp_br_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr,
enum
vfp_status
vp
=
VFP_ERROR
;
int
finished
=
0
;
BROTLI_BOOL
done
;
const
struct
vfp_priv
*
priv
;
CHECK_OBJ_NOTNULL
(
ctx
,
VFP_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ent
,
VFP_ENTRY_MAGIC
);
CAST_OBJ_NOTNULL
(
vbr
,
ent
->
priv1
,
VBR_MAGIC
);
AN
(
ent
->
vfp
);
CAST_OBJ_NOTNULL
(
priv
,
ent
->
vfp
->
priv1
,
VFP_PRIV_MAGIC
);
assert
(
vbr
->
which
==
ENC
);
AN
(
ptr
);
AN
(
lenp
);
...
...
@@ -403,7 +418,7 @@ vfp_br_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr,
setInputBuf
(
vbr
,
vbr
->
buf
,
len
);
}
if
(
!
isInputBufEmpty
(
vbr
)
||
finished
)
{
done
=
encode
(
vbr
,
&
dl
,
finished
);
done
=
encode
(
vbr
,
&
dl
,
finished
,
priv
->
stats
);
if
(
done
!=
BROTLI_TRUE
)
return
(
VFP_Error
(
ctx
,
"brotli encode failed"
));
if
(
dl
>
0
)
{
...
...
@@ -429,10 +444,13 @@ vfp_unbr_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr,
ssize_t
len
,
dl
;
enum
vfp_status
vp
=
VFP_ERROR
;
BrotliDecoderResult
result
=
BROTLI_DECODER_RESULT_ERROR
;
const
struct
vfp_priv
*
priv
;
CHECK_OBJ_NOTNULL
(
ctx
,
VFP_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ent
,
VFP_ENTRY_MAGIC
);
CAST_OBJ_NOTNULL
(
vbr
,
ent
->
priv1
,
VBR_MAGIC
);
AN
(
ent
->
vfp
);
CAST_OBJ_NOTNULL
(
priv
,
ent
->
vfp
->
priv1
,
VFP_PRIV_MAGIC
);
assert
(
vbr
->
which
==
DEC
);
AN
(
ptr
);
AN
(
lenp
);
...
...
@@ -450,7 +468,7 @@ vfp_unbr_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr,
setInputBuf
(
vbr
,
vbr
->
buf
,
len
);
}
if
(
!
isInputBufEmpty
(
vbr
)
||
vp
==
VFP_END
)
{
result
=
decode
(
vbr
,
&
dl
);
result
=
decode
(
vbr
,
&
dl
,
priv
->
stats
);
if
(
result
==
BROTLI_DECODER_RESULT_SUCCESS
&&
!
isInputBufEmpty
(
vbr
))
return
(
VFP_Error
(
ctx
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment