library: normalize stack and history allocation naming
Recent profiling and timings have resulted in improved newlib performance. This patch completes that process. It just normalizes naming conventions employed for all allocations involving reaped stacks & history support. The modules offering a 'reap' function will also offer the now standardized corresponding STACKS_INCR define. The modules which provide dynamic history support will now have a separate #define called NEWOLD_INCR used in allocations/reallocations. And, while values currently are set equal to that STACKS_INCR value, in the future some reason for divorcing those two may be discovered. ----------------------------- for future reference --- In those modules which contain the STACKS_INCR #define it is tempting to specify a large value so as to avoid repeated calls to malloc/realloc. However, in doing so an extra runtime price will be paid in 'cleanup_stack' calls with any iterative programs like top or slabtop. So, with the current values a balance has been sought. Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
21
proc/pids.c
21
proc/pids.c
@@ -45,10 +45,11 @@
|
||||
#include <proc/pids.h>
|
||||
|
||||
|
||||
//#define UNREF_RPTHASH // report on hashing, at uref time
|
||||
//#define UNREF_RPTHASH // report hash details at uref() time
|
||||
|
||||
#define FILL_ID_MAX 255 // upper limit for pid/uid fills
|
||||
#define MEMORY_INCR 128 // amt by which allocations grow
|
||||
#define FILL_ID_MAX 255 // upper limit with select of pid/uid
|
||||
#define STACKS_INCR 128 // amount reap stack allocations grow
|
||||
#define NEWOLD_INCR 128 // amt by which hist allocations grow
|
||||
|
||||
|
||||
struct stacks_extent {
|
||||
@@ -627,7 +628,7 @@ static inline int pids_make_hist (
|
||||
HST_t *h;
|
||||
|
||||
if (nSLOT + 1 >= Hr(HHist_siz)) {
|
||||
Hr(HHist_siz) += MEMORY_INCR;
|
||||
Hr(HHist_siz) += NEWOLD_INCR;
|
||||
Hr(PHist_sav) = realloc(Hr(PHist_sav), sizeof(HST_t) * Hr(HHist_siz));
|
||||
Hr(PHist_new) = realloc(Hr(PHist_new), sizeof(HST_t) * Hr(HHist_siz));
|
||||
if (!Hr(PHist_sav) || !Hr(PHist_new))
|
||||
@@ -1052,9 +1053,9 @@ static int pids_stacks_fetch (
|
||||
|
||||
// initialize stuff -----------------------------------
|
||||
if (!info->fetch.anchor) {
|
||||
if (!(info->fetch.anchor = calloc(sizeof(void *), MEMORY_INCR)))
|
||||
if (!(info->fetch.anchor = calloc(sizeof(void *), STACKS_INCR)))
|
||||
return -ENOMEM;
|
||||
n_alloc = MEMORY_INCR;
|
||||
n_alloc = STACKS_INCR;
|
||||
}
|
||||
if (!info->extents) {
|
||||
if (!(ext = pids_stacks_alloc(info, n_alloc)))
|
||||
@@ -1070,11 +1071,11 @@ static int pids_stacks_fetch (
|
||||
n_inuse = 0;
|
||||
while (info->read_something(info->fetch_PT, &task)) {
|
||||
if (!(n_inuse < n_alloc)) {
|
||||
n_alloc += MEMORY_INCR;
|
||||
n_alloc += STACKS_INCR;
|
||||
if ((!(info->fetch.anchor = realloc(info->fetch.anchor, sizeof(void *) * n_alloc)))
|
||||
|| (!(ext = pids_stacks_alloc(info, MEMORY_INCR))))
|
||||
|| (!(ext = pids_stacks_alloc(info, STACKS_INCR))))
|
||||
return -1;
|
||||
memcpy(info->fetch.anchor + n_inuse, ext->stacks, sizeof(void *) * MEMORY_INCR);
|
||||
memcpy(info->fetch.anchor + n_inuse, ext->stacks, sizeof(void *) * STACKS_INCR);
|
||||
}
|
||||
if (!pids_proc_tally(info, &info->fetch.counts, &task))
|
||||
return -1;
|
||||
@@ -1148,7 +1149,7 @@ PROCPS_EXPORT int procps_pids_new (
|
||||
pids_libflags_set(p);
|
||||
}
|
||||
|
||||
if (!(p->hist = calloc(MEMORY_INCR, sizeof(struct history_info)))) {
|
||||
if (!(p->hist = calloc(NEWOLD_INCR, sizeof(struct history_info)))) {
|
||||
free(p->items);
|
||||
free(p);
|
||||
return -ENOMEM;
|
||||
|
Reference in New Issue
Block a user