Thread View: news.software.nntp
1 messages
1 total messages
Started by Marc Slemko
Mon, 11 Aug 1997 00:00
INN and realloc()
Author: Marc Slemko
Date: Mon, 11 Aug 1997 00:00
Date: Mon, 11 Aug 1997 00:00
39 lines
2536 bytes
2536 bytes
Has anyone looked into just how much INN calls realloc()? While
adding some code for debugging something else (INN deciding it
wanted to grab all the vm in the system), I noticed things like
(in 1.5.1+patches):
Aug 10 18:01:51 scanner innd: RENEW: site.c:387: trying to realloc 78080 bytes
Aug 10 18:01:51 scanner innd: RENEW: site.c:431: trying to realloc 51456 bytes
Aug 10 18:01:51 scanner innd: RENEW: site.c:387: trying to realloc 79104 bytes
Aug 10 18:01:51 scanner innd: RENEW: site.c:387: trying to realloc 80128 bytes
Aug 10 18:01:52 scanner innd: RENEW: site.c:387: trying to realloc 81152 bytes
Aug 10 18:01:52 scanner innd: RENEW: site.c:387: trying to realloc 82176 bytes
Aug 10 18:01:52 scanner innd: RENEW: site.c:431: trying to realloc 52480 bytes
Aug 10 18:01:52 scanner innd: RENEW: site.c:387: trying to realloc 83200 bytes
Aug 10 18:01:52 scanner innd: RENEW: site.c:387: trying to realloc 84224 bytes
Aug 10 18:01:52 scanner innd: RENEW: site.c:392: trying to realloc 17664 bytes
Aug 10 18:01:52 scanner innd: RENEW: site.c:387: trying to realloc 85248 bytes
Aug 10 18:01:52 scanner innd: RENEW: site.c:431: trying to realloc 53504 bytes
Depending on your malloc implementation, this can be quite painful.
Some realloc()s simply copy the whole bit of memory each time and
don't even try to expand the given space... some buffers grow to
be hundreds of K in size, 1k at a time. Most of them are coming
from the BUFFappend macro:
if (i_ + l_ > bp_->Size) { \
/* Round size up to next 1K. */ \
bp_->Size += (l_ + 0x3FF) & ~0x3FF; \
RENEW(bp_->Data, char, bp_->Size); \
} \
Bumping the 1k up to 16k helped nicely. A more complicated algorithm
that picked the new size based on the old one could reduce the number
of calls even further without resulting in a huge waste of memory.
Couldn't say if it actually has any real-world impact on performance;
I would doubt it would be a measurable difference.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads