Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and enhance memory usage regarding log table #1783

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

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
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.

1 participant