Skip to content

Conversation

@michaelortmann
Copy link
Member

@michaelortmann michaelortmann commented Feb 20, 2025

Found by: michaelortmann
Patch by: michaelortmann
Fixes:

One-line summary:
Enhance memory usage regarding log table - Fix regression since eggdrop 1.9.0rc1

Additional description (if needed):
This PR not only fixes the regression since eggdrop 1.9.0rc1, but makes eggdrop even better than before regarding amount of memory allocation for log table
During eggdrop startup, memory for log tables is allocated:

eggdrop/src/misc.c

Lines 92 to 101 in 341477a

void init_misc()
{
static int last = 0;
if (max_logs < 1)
max_logs = 1;
if (logs)
logs = nrealloc(logs, max_logs * sizeof(log_t));
else
logs = nmalloc(max_logs * sizeof(log_t));

about max-logs * LOGLINELEN bytes
default max-logs is 20
LOGLINELEN was rised from 1024 to 9000 since eggdrop 1.9.0rc1
20 * 9000 = 180 kbytes
Users probably raise max-logs to 100 or more in their configuration files so they wont have to care about it anymore, not aware of the memory usage implications.

This PR makes eggdrop to still allocate memory for max-logs log tables. but only about 56 bytes per table / logfile static. szlast (last log messages to track repeats) will be allocated (grow) dynamically until LOGLINELEN.

.status will now show the log table information, similar to socket table (and memory table, if debug enabled)

Add MIN() and MAX() to eggdrop.h

Test cases demonstrating functionality (if applicable):

$ grep max-logs BotA.conf 
set max-logs 100

Before:

[michael@zen ~]$ ps u|grep egg
michael   861664  0.0  0.0  18556 13664 pts/4    S+   04:41   0:00 ./eggdrop -t BotA.conf

After:

[michael@zen ~]$ ps u|grep egg
michael   862487  0.0  0.0  17668 12956 pts/4    S+   04:42   0:00 ./eggdrop -t BotA.conf

.status
Log table: 1/100 5728 bytes

@michaelortmann michaelortmann changed the title Enhance memory usage regarding log table (WIP) Enhance memory usage regarding log table Feb 20, 2025
Add MIN() and MAX() to eggdrop.h
@michaelortmann michaelortmann changed the title (WIP) Enhance memory usage regarding log table Enhance memory usage regarding log table Feb 25, 2025
@michaelortmann michaelortmann changed the title Enhance memory usage regarding log table Fix and enhance memory usage regarding log table Feb 25, 2025
@vanosg vanosg added this to the v1.10.2 milestone Jun 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants