Mailing List Archive

vmod_vsthrottle memory usage
Hi,

I'm looking at the vsthrottle vmod. Have a proof of concept VCL up and running,
and it seems to work very nicely (with varnish 4.1.9). Thanks for this work!

I'm wondering what vsthrottle's behaviour is when there's no memory available,
specifically when tb_alloc() fails.

From what I can understand from the code[1]:

b = tb_alloc(digest, limit, period, now);
AZ(VRB_INSERT(tbtree, &v->buckets, b));

and tb_alloc() also checks for a non-zero malloc result (AN()).

I understand we're talking about a remote possibility, and I see vsthrottle
reclaims unused memory. However, when no memory is available for the malloc,
will varnish leave a trace in syslog, exit and restart by way of the asserts?

--
Cosimo

[1] https://github.com/varnish/varnish-modules/blob/master/src/vmod_vsthrottle.c#L126-L127
_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
Re: vmod_vsthrottle memory usage [ In reply to ]
Hi cosimo,

Very simple, we crash and bring the whole thing down:
https://github.com/varnish/varnish-modules/blob/master/src/vmod_vsthrottle.c#L99

IIRC, on Linux, malloc always returns with an allocation, or OOM-kills you

--
Guillaume Quintard

On Wed, Apr 11, 2018 at 12:47 PM, Cosimo Streppone <cosimo@streppone.it>
wrote:

> Hi,
>
> I'm looking at the vsthrottle vmod. Have a proof of concept VCL up and
> running,
> and it seems to work very nicely (with varnish 4.1.9). Thanks for this
> work!
>
> I'm wondering what vsthrottle's behaviour is when there's no memory
> available,
> specifically when tb_alloc() fails.
>
> From what I can understand from the code[1]:
>
> b = tb_alloc(digest, limit, period, now);
> AZ(VRB_INSERT(tbtree, &v->buckets, b));
>
> and tb_alloc() also checks for a non-zero malloc result (AN()).
>
> I understand we're talking about a remote possibility, and I see vsthrottle
> reclaims unused memory. However, when no memory is available for the
> malloc,
> will varnish leave a trace in syslog, exit and restart by way of the
> asserts?
>
> --
> Cosimo
>
> [1] https://github.com/varnish/varnish-modules/blob/master/
> src/vmod_vsthrottle.c#L126-L127
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
Re: vmod_vsthrottle memory usage [ In reply to ]
> IIRC, on Linux, malloc always returns with an allocation, or OOM-kills you

That's the default behavior but I believe you can also change that.
_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc