Add objsize_max

parent 93578934
..
Copyright 2023 UPLEX Nils Goroll Systemoptimierung
SPDX-License-Identifier: BSD-2-Clause
See LICENSE file for full text of license
===================
About this document
===================
.. keep this section at the top!
This document contains a log of noteworthy changes to SLASH/ from new
to old.
==============
SLASH/ Changes
==============
* The ``objsize_max`` tunable has been added, which defaults to 1/4 of
*dsksize*.
The tunable is going to be used to allow SLASH/ to make an educated
guess about how much space to allocate in advance when the object
size is not known upfront, for example with *chunked encoding*.
Base of the changelog: e3a454096759cafd30d9008f4b11cc754297b250
......@@ -3553,6 +3553,11 @@ fellow_busy_obj_getspace(struct fellow_busy *fbo, size_t *sz, uint8_t **ptr)
max = (size_t)1 << fbo->fc->tune->chunk_exponent;
assert(max <= FIO_MAX);
if (fbo->sz_returned >= fbo->fc->tune->objsize_max)
return (FCR_ALLOCFAIL("objsize_max reached"));
if (*sz + fbo->sz_returned > fbo->fc->tune->objsize_max)
*sz = fbo->fc->tune->objsize_max - fbo->sz_returned;
/*
* for content-length, varnish-cache will ask for less and less.
*
......
......@@ -744,6 +744,10 @@ fellow_stream_f(void *priv, unsigned flush, const void *ptr, ssize_t len)
int r;
CAST_OBJ_NOTNULL(fs, priv, FELLOW_STREAM_MAGIC);
if (fs->state == BOS_FAILED)
return (-1);
assert((fs->state == BOS_FINISHED && fs->available >= fs->written) ||
(fs->state == BOS_STREAM && fs->available > fs->written));
assert(fs->checkpoint == fs->written);
......
......@@ -100,6 +100,9 @@ stvfe_tune_check(struct stvfe_tune *tune)
tune->dsk_reserve_chunks = l;
}
if (tune->objsize_max == 0)
tune->objsize_max = (tune->dsksz >> 2);
//lint --e{685,568} misc const comparisons
#define TUNE(t, n, d, min, max) \
if (tune->n < (min)) \
......
......@@ -45,6 +45,7 @@ TUNE(uint8_t, wait_table_exponent, 10, 6, 32);
TUNE(unsigned, dsk_reserve_chunks, 4, 2, UINT_MAX);
TUNE(unsigned, mem_reserve_chunks, 1, 0, UINT_MAX);
TUNE(size_t, objsize_hint, 256 * 1024, 4096, SIZE_MAX);
TUNE(size_t, objsize_max, 0, 0, SIZE_MAX);
TUNE(size_t, discard_immediate, 256 * 1024, 4096, SIZE_MAX);
TUNE(unsigned, readahead, 2, 0, UINT_MAX);
TUNE(unsigned, io_batch_min, 8, 1, UINT_MAX);
......
......@@ -51,7 +51,7 @@ vcl storage objects and methods
new xfellow = slash.fellow(STRING filename, BYTES dsksize, BYTES memsize, BYTES objsize_hint, BOOL delete)
STRING xfellow.tune([INT logbuffer_size], [DURATION logbuffer_flush_interval], [REAL log_rewrite_ratio], [INT chunk_exponent], [BYTES chunk_bytes], [INT dsk_reserve_chunks], [INT mem_reserve_chunks], [BYTES objsize_hint], [INT cram], [INT readahead], [BYTES discard_immediate], [INT io_batch_min], [INT io_batch_max], [ENUM hash_obj], [ENUM hash_log], [ENUM ioerr_obj], [ENUM ioerr_log], [ENUM allocerr_obj], [ENUM allocerr_log])
STRING xfellow.tune([INT logbuffer_size], [DURATION logbuffer_flush_interval], [REAL log_rewrite_ratio], [INT chunk_exponent], [BYTES chunk_bytes], [INT dsk_reserve_chunks], [INT mem_reserve_chunks], [BYTES objsize_hint], [BYTES objsize_max], [INT cram], [INT readahead], [BYTES discard_immediate], [INT io_batch_min], [INT io_batch_max], [ENUM hash_obj], [ENUM hash_log], [ENUM ioerr_obj], [ENUM ioerr_log], [ENUM allocerr_obj], [ENUM allocerr_log])
STEVEDORE xfellow.storage()
......@@ -68,7 +68,7 @@ vcl functions
STRING tune_buddy(STEVEDORE storage, [INT chunk_exponent], [BYTES chunk_bytes], [INT reserve_chunks], [INT cram])
STRING tune_fellow(STEVEDORE storage, [INT logbuffer_size], [DURATION logbuffer_flush_interval], [REAL log_rewrite_ratio], [INT chunk_exponent], [BYTES chunk_bytes], [INT dsk_reserve_chunks], [INT mem_reserve_chunks], [BYTES objsize_hint], [INT cram], [INT readahead], [BYTES discard_immediate], [INT io_batch_min], [INT io_batch_max], [ENUM hash_obj], [ENUM hash_log], [ENUM ioerr_obj], [ENUM ioerr_log], [ENUM allocerr_obj], [ENUM allocerr_log])
STRING tune_fellow(STEVEDORE storage, [INT logbuffer_size], [DURATION logbuffer_flush_interval], [REAL log_rewrite_ratio], [INT chunk_exponent], [BYTES chunk_bytes], [INT dsk_reserve_chunks], [INT mem_reserve_chunks], [BYTES objsize_hint], [BYTES objsize_max], [INT cram], [INT readahead], [BYTES discard_immediate], [INT io_batch_min], [INT io_batch_max], [ENUM hash_obj], [ENUM hash_log], [ENUM ioerr_obj], [ENUM ioerr_log], [ENUM allocerr_obj], [ENUM allocerr_log])
vcl loadmasters (storage routers)
---------------------------------
......@@ -479,8 +479,8 @@ will be used (which might fail of insufficient memory is available).
.. _xfellow.tune():
STRING xfellow.tune([INT logbuffer_size], [DURATION logbuffer_flush_interval], [REAL log_rewrite_ratio], [INT chunk_exponent], [BYTES chunk_bytes], [INT wait_table_exponent], [INT dsk_reserve_chunks], [INT mem_reserve_chunks], [BYTES objsize_hint], [INT cram], [INT readahead], [BYTES discard_immediate], [INT io_batch_min], [INT io_batch_max], [ENUM hash_obj], [ENUM hash_log], [ENUM ioerr_obj], [ENUM ioerr_log], [ENUM allocerr_obj], [ENUM allocerr_log])
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
STRING xfellow.tune([INT logbuffer_size], [DURATION logbuffer_flush_interval], [REAL log_rewrite_ratio], [INT chunk_exponent], [BYTES chunk_bytes], [INT wait_table_exponent], [INT dsk_reserve_chunks], [INT mem_reserve_chunks], [BYTES objsize_hint], [BYTES objsize_max], [INT cram], [INT readahead], [BYTES discard_immediate], [INT io_batch_min], [INT io_batch_max], [ENUM hash_obj], [ENUM hash_log], [ENUM ioerr_obj], [ENUM ioerr_log], [ENUM allocerr_obj], [ENUM allocerr_log])
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
::
......@@ -494,6 +494,7 @@ STRING xfellow.tune([INT logbuffer_size], [DURATION logbuffer_flush_interval], [
[INT dsk_reserve_chunks],
[INT mem_reserve_chunks],
[BYTES objsize_hint],
[BYTES objsize_max],
[INT cram],
[INT readahead],
[BYTES discard_immediate],
......@@ -630,6 +631,18 @@ fellow storage can be fine tuned:
used to (re)size the fixed log space. The value should be chosen as
a safe *lower* bound of average object size.
* *objsize_max*
- unit: bytes
- default: 0
specifies the maxiumum object size which fellow will accept.
The default of ``0`` represents 1/4th of *dsksize*. It is strongly
recommended to not use a value higher than that.
The effectively enforced value is rounded up to 4KB.
* *cram* is documented in `xbuddy.tune()`_
* *readahead*
......@@ -811,8 +824,8 @@ Can only be called from ``vcl_init {}``.
.. _slash.tune_fellow():
STRING tune_fellow(STEVEDORE storage, [INT logbuffer_size], [DURATION logbuffer_flush_interval], [REAL log_rewrite_ratio], [INT chunk_exponent], [BYTES chunk_bytes], [INT wait_table_exponent], [INT dsk_reserve_chunks], [INT mem_reserve_chunks], [BYTES objsize_hint], [INT cram], [INT readahead], [BYTES discard_immediate], [INT io_batch_min], [INT io_batch_max], [ENUM hash_obj], [ENUM hash_log], [ENUM ioerr_obj], [ENUM ioerr_log], [ENUM allocerr_obj], [ENUM allocerr_log])
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
STRING tune_fellow(STEVEDORE storage, [INT logbuffer_size], [DURATION logbuffer_flush_interval], [REAL log_rewrite_ratio], [INT chunk_exponent], [BYTES chunk_bytes], [INT wait_table_exponent], [INT dsk_reserve_chunks], [INT mem_reserve_chunks], [BYTES objsize_hint], [BYTES objsize_max], [INT cram], [INT readahead], [BYTES discard_immediate], [INT io_batch_min], [INT io_batch_max], [ENUM hash_obj], [ENUM hash_log], [ENUM ioerr_obj], [ENUM ioerr_log], [ENUM allocerr_obj], [ENUM allocerr_log])
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
::
......@@ -827,6 +840,7 @@ STRING tune_fellow(STEVEDORE storage, [INT logbuffer_size], [DURATION logbuffer_
[INT dsk_reserve_chunks],
[INT mem_reserve_chunks],
[BYTES objsize_hint],
[BYTES objsize_max],
[INT cram],
[INT readahead],
[BYTES discard_immediate],
......
......@@ -36,7 +36,7 @@ vcl storage objects and methods
new xfellow = slash.fellow(STRING filename, BYTES dsksize, BYTES memsize, BYTES objsize_hint, BOOL delete)
STRING xfellow.tune([INT logbuffer_size], [DURATION logbuffer_flush_interval], [REAL log_rewrite_ratio], [INT chunk_exponent], [BYTES chunk_bytes], [INT dsk_reserve_chunks], [INT mem_reserve_chunks], [BYTES objsize_hint], [INT cram], [INT readahead], [BYTES discard_immediate], [INT io_batch_min], [INT io_batch_max], [ENUM hash_obj], [ENUM hash_log], [ENUM ioerr_obj], [ENUM ioerr_log], [ENUM allocerr_obj], [ENUM allocerr_log])
STRING xfellow.tune([INT logbuffer_size], [DURATION logbuffer_flush_interval], [REAL log_rewrite_ratio], [INT chunk_exponent], [BYTES chunk_bytes], [INT dsk_reserve_chunks], [INT mem_reserve_chunks], [BYTES objsize_hint], [BYTES objsize_max], [INT cram], [INT readahead], [BYTES discard_immediate], [INT io_batch_min], [INT io_batch_max], [ENUM hash_obj], [ENUM hash_log], [ENUM ioerr_obj], [ENUM ioerr_log], [ENUM allocerr_obj], [ENUM allocerr_log])
STEVEDORE xfellow.storage()
......@@ -53,7 +53,7 @@ vcl functions
STRING tune_buddy(STEVEDORE storage, [INT chunk_exponent], [BYTES chunk_bytes], [INT reserve_chunks], [INT cram])
STRING tune_fellow(STEVEDORE storage, [INT logbuffer_size], [DURATION logbuffer_flush_interval], [REAL log_rewrite_ratio], [INT chunk_exponent], [BYTES chunk_bytes], [INT dsk_reserve_chunks], [INT mem_reserve_chunks], [BYTES objsize_hint], [INT cram], [INT readahead], [BYTES discard_immediate], [INT io_batch_min], [INT io_batch_max], [ENUM hash_obj], [ENUM hash_log], [ENUM ioerr_obj], [ENUM ioerr_log], [ENUM allocerr_obj], [ENUM allocerr_log])
STRING tune_fellow(STEVEDORE storage, [INT logbuffer_size], [DURATION logbuffer_flush_interval], [REAL log_rewrite_ratio], [INT chunk_exponent], [BYTES chunk_bytes], [INT dsk_reserve_chunks], [INT mem_reserve_chunks], [BYTES objsize_hint], [BYTES objsize_max], [INT cram], [INT readahead], [BYTES discard_immediate], [INT io_batch_min], [INT io_batch_max], [ENUM hash_obj], [ENUM hash_log], [ENUM ioerr_obj], [ENUM ioerr_log], [ENUM allocerr_obj], [ENUM allocerr_log])
vcl loadmasters (storage routers)
---------------------------------
......@@ -433,6 +433,7 @@ $Method STRING .tune(
[ INT dsk_reserve_chunks ],
[ INT mem_reserve_chunks ],
[ BYTES objsize_hint ],
[ BYTES objsize_max ],
[ INT cram ],
[ INT readahead ],
[ BYTES discard_immediate ],
......@@ -568,6 +569,18 @@ fellow storage can be fine tuned:
used to (re)size the fixed log space. The value should be chosen as
a safe *lower* bound of average object size.
* *objsize_max*
- unit: bytes
- default: 0
specifies the maxiumum object size which fellow will accept.
The default of ``0`` represents 1/4th of *dsksize*. It is strongly
recommended to not use a value higher than that.
The effectively enforced value is rounded up to 4KB.
* *cram* is documented in `xbuddy.tune()`_
* *readahead*
......@@ -749,6 +762,7 @@ $Function STRING tune_fellow(
[ INT dsk_reserve_chunks ],
[ INT mem_reserve_chunks ],
[ BYTES objsize_hint ],
[ BYTES objsize_max ],
[ INT cram ],
[ INT readahead ],
[ BYTES discard_immediate ],
......
......@@ -7,7 +7,10 @@ shell -err -expect " fellow file can only be used once" \
-sfellow2=fellow,clashfile,100MB,1MB,64KB \
}
varnish v1 -vcl {
varnish v1 \
-arg "-E${libvmod_slash}" \
-arg "-sfellow1=fellow,fellowfile,1MB,1MB,64KB" \
-vcl {
backend none none;
} -start
......@@ -19,4 +22,67 @@ varnish v1 -errvcl {can only be used on a fellow storage} {
sub vcl_init {
slash.tune_fellow(storage.Transient, chunk_bytes = 1KB);
}
}
\ No newline at end of file
}
server s1 {
rxreq
expect req.url == "/256k"
txresp -bodylen 262144
rxreq
expect req.url == "/256k+1"
txresp -bodylen 262145
} -start
varnish v1 -vcl+backend {
sub vcl_backend_response {
set beresp.do_stream = false;
}
}
client c1 {
txreq -url "/256k"
rxresp
expect resp.status == 200
expect resp.bodylen == 262144
txreq -url "/256k+1"
rxresp
expect resp.status == 503
} -start
client c2 {
txreq -url "/256k"
rxresp
expect resp.status == 200
expect resp.bodylen == 262144
txreq -url "/256k+1"
rxresp
expect resp.status == 503
} -start
client c1 -wait
client c2 -wait
server s1 -wait
server s1 {
rxreq
expect req.url == "/16k"
txresp -bodylen 16384
} -start
varnish v1 -vcl+backend {
import slash;
sub vcl_init {
slash.tune_fellow(storage.fellow1, objsize_max = 12K);
}
sub vcl_backend_response {
set beresp.do_stream = false;
}
}
client c3 {
txreq -url "/16k"
rxresp
expect resp.status == 503
} -run
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