Tuning freeradius memory usage for small footprint machines

Peter Thomas (pethoma2) pethoma2 at cisco.com
Thu May 30 01:16:39 UTC 2024


Thank you! Disabling atomic queues brought down the memory usage a lot to ~10M. Wonder why atomic queues take up so much additional memory (~30M)?

Reducing the max_queue_size doesn't seem to help either.
#ifdef HAVE_STDATOMIC_H
        thread_pool.queue[i] = fr_atomic_queue_alloc(autofree, thread_pool.max_queue_size);
        if (!thread_pool.queue[i]) {
            ERROR("FATAL: Failed to set up request fifo");
            return -1;
        }
#else
________________________________
From: Alan DeKok <aland at deployingradius.com>
Sent: Monday, May 27, 2024 7:49 AM
To: FreeRadius users mailing list <freeradius-users at lists.freeradius.org>
Cc: Peter Thomas (pethoma2) <pethoma2 at cisco.com>
Subject: Re: Tuning freeradius memory usage for small footprint machines

On May 24, 2024, at 9:46 PM, Peter Thomas (pethoma2) via Freeradius-Users <freeradius-users at lists.freeradius.org> wrote:
>
> Thanks for the responses. I did some digging around and this is what I found.
>
> While running by disabling threads (-t) freeradius uses around 5MB while the normal mode uses about 43MB. In normal mode, freeradius seems to use a min of 9 threads even if I use extremely conservative server settings like start_servers = 1 max_servers = 1 min_spare_servers = 0 max_spare_servers = 0

  The large memory block is due to the atomic queues.  You can disable that by editing src/main/threads.c:

...
// add the next line
#undef HAVE_STDATOMIC_H

#ifdef HAVE_STDATOMIC_H
#include <freeradius-devel/atomic_queue.h>
#endif
...

  That should lower memory usage.

  As for starting 9 threads, nope.  That might be an OS / libc thing.  FreeRADIUS only starts the number of threads you tell it to.

  Alan DeKok.



More information about the Freeradius-Users mailing list