old_api.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9/* DEBUG: section 13 High Level Memory Pool Management */
10
11#include "squid.h"
12#include "base/PackableStream.h"
13#include "ClientInfo.h"
14#include "dlink.h"
15#include "event.h"
16#include "fs_io.h"
17#include "icmp/net_db.h"
18#include "md5.h"
19#include "mem/Allocator.h"
20#include "mem/Pool.h"
21#include "mem/Stats.h"
22#include "MemBuf.h"
23#include "mgr/Registration.h"
24#include "SquidConfig.h"
25#include "Store.h"
26
27#include <iomanip>
28
29/* forward declarations */
30static void memFree2K(void *);
31static void memFree4K(void *);
32static void memFree8K(void *);
33static void memFree16K(void *);
34static void memFree32K(void *);
35static void memFree64K(void *);
36
37/* local prototypes */
38static void memStringStats(std::ostream &);
39
40/* module locals */
41static double xm_time = 0;
42static double xm_deltat = 0;
43
44/* string pools */
45#define mem_str_pool_count 6
46
47struct PoolMeta {
48 const char *name;
49 size_t obj_size;
50};
51
54
57
58/* local routines */
59
60// XXX: refactor objects using these pools to use MEMPROXY classes instead
61// then remove this function entirely
62static Mem::Allocator *&
63GetPool(size_t type)
64{
65 static Mem::Allocator *pools[MEM_MAX];
66 static bool initialized = false;
67
68 if (!initialized) {
69 memset(pools, '\0', sizeof(pools));
70 initialized = true;
71 // Mem::Init() makes use of GetPool(type) to initialize
72 // the actual pools. So must come after the flag is true
73 Mem::Init();
74 }
75
76 return pools[type];
77}
78
79static Mem::Allocator &
80GetStrPool(size_t type)
81{
82 static Mem::Allocator *strPools[mem_str_pool_count];
83 static bool initialized = false;
84
85 static const PoolMeta PoolAttrs[mem_str_pool_count] = {
86 {"Short Strings", Mem::Allocator::RoundedSize(36)}, /* to fit rfc1123 and similar */
87 {"Medium Strings", Mem::Allocator::RoundedSize(128)}, /* to fit most urls */
88 {"Long Strings", Mem::Allocator::RoundedSize(512)},
89 {"1KB Strings", Mem::Allocator::RoundedSize(1024)},
90 {"4KB Strings", Mem::Allocator::RoundedSize(4*1024)},
91 {"16KB Strings", Mem::Allocator::RoundedSize(16*1024)}
92 };
93
94 if (!initialized) {
95 memset(strPools, '\0', sizeof(strPools));
96
98 for (int i = 0; i < mem_str_pool_count; ++i) {
99 strPools[i] = memPoolCreate(PoolAttrs[i].name, PoolAttrs[i].obj_size);
100 strPools[i]->zeroBlocks(false);
101
102 if (strPools[i]->objectSize != PoolAttrs[i].obj_size)
103 debugs(13, DBG_IMPORTANT, "WARNING: " << PoolAttrs[i].name <<
104 " is " << strPools[i]->objectSize <<
105 " bytes instead of requested " <<
106 PoolAttrs[i].obj_size << " bytes");
107 }
108
109 initialized = true;
110 }
111
112 return *strPools[type];
113}
114
116static Mem::Allocator *
117memFindStringPool(size_t net_size, bool fuzzy)
118{
119 for (unsigned int i = 0; i < mem_str_pool_count; ++i) {
120 auto &pool = GetStrPool(i);
121 if (fuzzy && net_size < pool.objectSize)
122 return &pool;
123 if (net_size == pool.objectSize)
124 return &pool;
125 }
126 return nullptr;
127}
128
129static void
130memStringStats(std::ostream &stream)
131{
132 int i;
133 int pooled_count = 0;
134 size_t pooled_volume = 0;
135 /* heading */
136 stream << "String Pool\t Impact\t\t\n \t (%strings)\t (%volume)\n";
137 /* table body */
138
139 for (i = 0; i < mem_str_pool_count; ++i) {
140 const auto &pool = GetStrPool(i);
141 const auto plevel = pool.meter.inuse.currentLevel();
142 stream << std::setw(20) << std::left << pool.label;
143 stream << std::right << "\t " << xpercentInt(plevel, StrCountMeter.currentLevel());
144 stream << "\t " << xpercentInt(plevel * pool.objectSize, StrVolumeMeter.currentLevel()) << "\n";
145 pooled_count += plevel;
146 pooled_volume += plevel * pool.objectSize;
147 }
148
149 /* malloc strings */
150 stream << std::setw(20) << std::left << "Other Strings";
151 stream << std::right << "\t ";
152 stream << xpercentInt(StrCountMeter.currentLevel() - pooled_count, StrCountMeter.currentLevel()) << "\t ";
153 stream << xpercentInt(StrVolumeMeter.currentLevel() - pooled_volume, StrVolumeMeter.currentLevel()) << "\n\n";
154}
155
156static void
157memBufStats(std::ostream & stream)
158{
159 stream << "Large buffers: " <<
161 HugeBufVolumeMeter.currentLevel() / 1024 << " KB)\n";
162}
163
164void
166{
167 PackableStream stream(*sentry);
168 Report(stream);
169 memStringStats(stream);
170 memBufStats(stream);
171#if WITH_VALGRIND
172 if (RUNNING_ON_VALGRIND) {
173 long int leaked = 0, dubious = 0, reachable = 0, suppressed = 0;
174 stream << "Valgrind Report:\n";
175 stream << "Type\tAmount\n";
176 debugs(13, DBG_IMPORTANT, "Asking valgrind for memleaks");
177 VALGRIND_DO_LEAK_CHECK;
178 debugs(13, DBG_IMPORTANT, "Getting valgrind statistics");
179 VALGRIND_COUNT_LEAKS(leaked, dubious, reachable, suppressed);
180 stream << "Leaked\t" << leaked << "\n";
181 stream << "Dubious\t" << dubious << "\n";
182 stream << "Reachable\t" << reachable << "\n";
183 stream << "Suppressed\t" << suppressed << "\n";
184 }
185#endif
186 stream.flush();
187}
188
189/*
190 * public routines
191 */
192
193/*
194 * we have a limit on _total_ amount of idle memory so we ignore max_pages for now.
195 * Will ignore repeated calls for the same pool type.
196 *
197 * Relies on Mem::Init() having been called beforehand.
198 */
199void
200memDataInit(mem_type type, const char *name, size_t size, int, bool doZero)
201{
202 assert(name && size);
203
204 if (GetPool(type) != nullptr)
205 return;
206
207 GetPool(type) = memPoolCreate(name, size);
208 GetPool(type)->zeroBlocks(doZero);
209}
210
211/* find appropriate pool and use it (pools always init buffer with 0s) */
212void *
214{
215 assert(GetPool(type));
216 return GetPool(type)->alloc();
217}
218
219/* give memory back to the pool */
220void
221memFree(void *p, int type)
222{
223 assert(GetPool(type));
224 GetPool(type)->freeOne(p);
225}
226
227/* allocate a variable size buffer using best-fit string pool */
228void *
229memAllocString(size_t net_size, size_t * gross_size)
230{
231 assert(gross_size);
232
233 if (const auto pool = memFindStringPool(net_size, true)) {
234 *gross_size = pool->objectSize;
235 assert(*gross_size >= net_size);
237 StrVolumeMeter += *gross_size;
238 return pool->alloc();
239 }
240
241 *gross_size = net_size;
243 StrVolumeMeter += *gross_size;
244 return xcalloc(1, net_size);
245}
246
247void *
248memAllocRigid(size_t net_size)
249{
250 // TODO: Use memAllocString() instead (after it stops zeroing memory).
251
252 if (const auto pool = memFindStringPool(net_size, true)) {
254 StrVolumeMeter += pool->objectSize;
255 return pool->alloc();
256 }
257
259 StrVolumeMeter += net_size;
260 return xmalloc(net_size);
261}
262
263size_t
265{
266 size_t result = 0;
267
268 for (int counter = 0; counter < mem_str_pool_count; ++counter)
269 result += GetStrPool(counter).getInUseCount();
270
271 return result;
272}
273
274/* free buffer allocated with memAllocString() */
275void
276memFreeString(size_t size, void *buf)
277{
278 assert(buf);
279
280 if (const auto pool = memFindStringPool(size, false))
281 pool->freeOne(buf);
282 else
283 xfree(buf);
284
287}
288
289void
290memFreeRigid(void *buf, size_t net_size)
291{
292 // TODO: Use memFreeString() instead (after removing fuzzy=false pool search).
293
294 if (const auto pool = memFindStringPool(net_size, true)) {
295 pool->freeOne(buf);
296 StrVolumeMeter -= pool->objectSize;
298 return;
299 }
300
301 xfree(buf);
302 StrVolumeMeter -= net_size;
304}
305
306/* Find the best fit MEM_X_BUF type */
307static mem_type
308memFindBufSizeType(size_t net_size, size_t * gross_size)
309{
310 mem_type type;
311 size_t size;
312
313 if (net_size <= 2 * 1024) {
314 type = MEM_2K_BUF;
315 size = 2 * 1024;
316 } else if (net_size <= 4 * 1024) {
317 type = MEM_4K_BUF;
318 size = 4 * 1024;
319 } else if (net_size <= 8 * 1024) {
320 type = MEM_8K_BUF;
321 size = 8 * 1024;
322 } else if (net_size <= 16 * 1024) {
323 type = MEM_16K_BUF;
324 size = 16 * 1024;
325 } else if (net_size <= 32 * 1024) {
326 type = MEM_32K_BUF;
327 size = 32 * 1024;
328 } else if (net_size <= 64 * 1024) {
329 type = MEM_64K_BUF;
330 size = 64 * 1024;
331 } else {
332 type = MEM_NONE;
333 size = net_size;
334 }
335
336 if (gross_size)
337 *gross_size = size;
338
339 return type;
340}
341
342/* allocate a variable size buffer using best-fit pool */
343void *
344memAllocBuf(size_t net_size, size_t * gross_size)
345{
346 mem_type type = memFindBufSizeType(net_size, gross_size);
347
348 if (type != MEM_NONE)
349 return memAllocate(type);
350 else {
352 HugeBufVolumeMeter += *gross_size;
353 return xcalloc(1, net_size);
354 }
355}
356
357/* resize a variable sized buffer using best-fit pool */
358void *
359memReallocBuf(void *oldbuf, size_t net_size, size_t * gross_size)
360{
361 /* XXX This can be optimized on very large buffers to use realloc() */
362 /* TODO: if the existing gross size is >= new gross size, do nothing */
363 size_t new_gross_size;
364 void *newbuf = memAllocBuf(net_size, &new_gross_size);
365
366 if (oldbuf) {
367 size_t data_size = *gross_size;
368
369 if (data_size > net_size)
370 data_size = net_size;
371
372 memcpy(newbuf, oldbuf, data_size);
373
374 memFreeBuf(*gross_size, oldbuf);
375 }
376
377 *gross_size = new_gross_size;
378 return newbuf;
379}
380
381/* free buffer allocated with memAllocBuf() */
382void
383memFreeBuf(size_t size, void *buf)
384{
385 mem_type type = memFindBufSizeType(size, nullptr);
386
387 if (type != MEM_NONE)
388 memFree(buf, type);
389 else {
390 xfree(buf);
393 }
394}
395
396static double clean_interval = 15.0; /* time to live of idle chunk before release */
397
398void
400{
401 MemPools::GetInstance().clean(static_cast<time_t>(clean_interval));
402 eventAdd("memPoolCleanIdlePools", CleanIdlePools, nullptr, clean_interval, 1);
403}
404
405void
407{
408 int64_t new_pool_limit;
409
412 new_pool_limit = 0;
413 else if (Config.MemPools.limit > 0)
414 new_pool_limit = Config.MemPools.limit;
415 else {
416 if (Config.MemPools.limit == 0)
417 debugs(13, DBG_IMPORTANT, "memory_pools_limit 0 has been chagned to memory_pools_limit none. Please update your config");
418 new_pool_limit = -1;
419 }
420
421 MemPools::GetInstance().setIdleLimit(new_pool_limit);
422}
423
424void
426{
427 /* all pools are ready to be used */
428 static bool MemIsInitialized = false;
429 if (MemIsInitialized)
430 return;
431
442 memDataInit(MEM_2K_BUF, "2K Buffer", 2048, 10, false);
443 memDataInit(MEM_4K_BUF, "4K Buffer", 4096, 10, false);
444 memDataInit(MEM_8K_BUF, "8K Buffer", 8192, 10, false);
445 memDataInit(MEM_16K_BUF, "16K Buffer", 16384, 10, false);
446 memDataInit(MEM_32K_BUF, "32K Buffer", 32768, 10, false);
447 memDataInit(MEM_64K_BUF, "64K Buffer", 65536, 10, false);
448 memDataInit(MEM_DREAD_CTRL, "dread_ctrl", sizeof(dread_ctrl), 0);
449 memDataInit(MEM_DWRITE_Q, "dwrite_q", sizeof(dwrite_q), 0);
451 GetPool(MEM_MD5_DIGEST)->setChunkSize(512 * 1024);
452
453 MemIsInitialized = true;
454
455 // finally register with the cache manager
456 Mgr::RegisterAction("mem", "Memory Utilization", Mem::Stats, 0, 1);
457}
458
459static mem_type &
461{
462 int tmp = (int)aMem;
463 aMem = (mem_type)(++tmp);
464 return aMem;
465}
466
467/*
468 * Test that all entries are initialized
469 */
470void
472{
473 mem_type t = MEM_NONE;
474
475 while (++t < MEM_MAX) {
476 /*
477 * If you hit this assertion, then you forgot to add a
478 * memDataInit() line for type 't'.
479 */
480 assert(GetPool(t));
481 }
482}
483
484void
486{
487 if (Config.MemPools.limit > 0) // do not reset if disabled or same
490
492 const auto poolsInUse = Mem::GlobalStats(stats);
493 if (stats.items_inuse) {
494 debugs(13, 2, stats.items_inuse <<
495 " items in " << stats.chunks_inuse << " chunks and " <<
496 poolsInUse << " pools are left dirty");
497 }
498}
499
500int
502{
503 return GetPool(type)->getInUseCount();
504}
505
506/* ick */
507
508void
509memFree2K(void *p)
510{
512}
513
514void
515memFree4K(void *p)
516{
518}
519
520void
521memFree8K(void *p)
522{
524}
525
526void
528{
530}
531
532void
534{
536}
537
538void
540{
542}
543
544static void
545cxx_xfree(void * ptr)
546{
547 xfree(ptr);
548}
549
550FREE *
552{
553 switch (size) {
554
555 case 2 * 1024:
556 return memFree2K;
557
558 case 4 * 1024:
559 return memFree4K;
560
561 case 8 * 1024:
562 return memFree8K;
563
564 case 16 * 1024:
565 return memFree16K;
566
567 case 32 * 1024:
568 return memFree32K;
569
570 case 64 * 1024:
571 return memFree64K;
572
573 default:
576 return cxx_xfree;
577 }
578}
579
580void
581Mem::PoolReport(const PoolStats *mp_st, const PoolMeter *AllMeter, std::ostream &stream)
582{
583 int excess = 0;
584 int needed = 0;
585 PoolMeter *pm = mp_st->meter;
586 const char *delim = "\t ";
587
588 stream.setf(std::ios_base::fixed);
589 stream << std::setw(20) << std::left << mp_st->label << delim;
590 stream << std::setw(4) << std::right << mp_st->obj_size << delim;
591
592 /* Chunks */
593 if (mp_st->chunk_capacity) {
594 stream << std::setw(4) << toKB(mp_st->obj_size * mp_st->chunk_capacity) << delim;
595 stream << std::setw(4) << mp_st->chunk_capacity << delim;
596
597 needed = mp_st->items_inuse / mp_st->chunk_capacity;
598
599 if (mp_st->items_inuse % mp_st->chunk_capacity)
600 ++needed;
601
602 excess = mp_st->chunks_inuse - needed;
603
604 stream << std::setw(4) << mp_st->chunks_alloc << delim;
605 stream << std::setw(4) << mp_st->chunks_inuse << delim;
606 stream << std::setw(4) << mp_st->chunks_free << delim;
607 stream << std::setw(4) << mp_st->chunks_partial << delim;
608 stream << std::setprecision(3) << xpercent(excess, needed) << delim;
609 } else {
610 stream << delim;
611 stream << delim;
612 stream << delim;
613 stream << delim;
614 stream << delim;
615 stream << delim;
616 stream << delim;
617 }
618 /*
619 * Fragmentation calculation:
620 * needed = inuse.currentLevel() / chunk_capacity
621 * excess = used - needed
622 * fragmentation = excess / needed * 100%
623 *
624 * Fragm = (alloced - (inuse / obj_ch) ) / alloced
625 */
626 /* allocated */
627 stream << mp_st->items_alloc << delim;
628 stream << toKB(mp_st->obj_size * pm->alloc.currentLevel()) << delim;
629 stream << toKB(mp_st->obj_size * pm->alloc.peak()) << delim;
630 stream << std::setprecision(2) << ((squid_curtime - pm->alloc.peakTime()) / 3600.) << delim;
631 stream << std::setprecision(3) << xpercent(mp_st->obj_size * pm->alloc.currentLevel(), AllMeter->alloc.currentLevel()) << delim;
632 /* in use */
633 stream << mp_st->items_inuse << delim;
634 stream << toKB(mp_st->obj_size * pm->inuse.currentLevel()) << delim;
635 stream << toKB(mp_st->obj_size * pm->inuse.peak()) << delim;
636 stream << std::setprecision(2) << ((squid_curtime - pm->inuse.peakTime()) / 3600.) << delim;
637 stream << std::setprecision(3) << xpercent(pm->inuse.currentLevel(), pm->alloc.currentLevel()) << delim;
638 /* idle */
639 stream << mp_st->items_idle << delim;
640 stream << toKB(mp_st->obj_size * pm->idle.currentLevel()) << delim;
641 stream << toKB(mp_st->obj_size * pm->idle.peak()) << delim;
642 /* saved */
643 stream << (int)pm->gb_saved.count << delim;
644 stream << std::setprecision(3) << xpercent(pm->gb_saved.count, AllMeter->gb_allocated.count) << delim;
645 stream << std::setprecision(3) << xpercent(pm->gb_saved.bytes, AllMeter->gb_allocated.bytes) << delim;
646 stream << std::setprecision(3) << xdiv(pm->gb_allocated.count - pm->gb_oallocated.count, xm_deltat) << "\n";
648}
649
650void
651Mem::Report(std::ostream &stream)
652{
653 static char buf[64];
654 int not_used = 0;
655
656 /* caption */
657 stream << "Current memory usage:\n";
658 /* heading */
659 stream << "Pool\t Obj Size\t"
660 "Chunks\t\t\t\t\t\t\t"
661 "Allocated\t\t\t\t\t"
662 "In Use\t\t\t\t\t"
663 "Idle\t\t\t"
664 "Allocations Saved\t\t\t"
665 "Rate\t"
666 "\n"
667 " \t (bytes)\t"
668 "KB/ch\t obj/ch\t"
669 "(#)\t used\t free\t part\t %Frag\t "
670 "(#)\t (KB)\t high (KB)\t high (hrs)\t %Tot\t"
671 "(#)\t (KB)\t high (KB)\t high (hrs)\t %alloc\t"
672 "(#)\t (KB)\t high (KB)\t"
673 "(#)\t %cnt\t %vol\t"
674 "(#)/sec\t"
675 "\n";
678
679 /* Get stats for Totals report line */
680 PoolStats mp_total;
681 const auto poolsInUse = GlobalStats(mp_total);
682
683 std::vector<PoolStats> usedPools;
684 usedPools.reserve(poolsInUse);
685
686 /* main table */
687 for (const auto pool : MemPools::GetInstance().pools) {
688 PoolStats mp_stats;
689 pool->getStats(mp_stats);
690
691 if (mp_stats.pool->meter.gb_allocated.count > 0)
692 usedPools.emplace_back(mp_stats);
693 else
694 ++not_used;
695 }
696
697 // sort on %Total Allocated (largest first)
698 std::sort(usedPools.begin(), usedPools.end(), [](const PoolStats &a, const PoolStats &b) {
699 return (double(a.obj_size) * a.meter->alloc.currentLevel()) > (double(b.obj_size) * b.meter->alloc.currentLevel());
700 });
701
702 for (const auto &pool: usedPools) {
703 PoolReport(&pool, mp_total.meter, stream);
704 }
705
706 PoolReport(&mp_total, mp_total.meter, stream);
707
708 /* Cumulative */
709 stream << "Cumulative allocated volume: "<< double_to_str(buf, 64, mp_total.meter->gb_allocated.bytes) << "\n";
710 /* overhead */
711 stream << "Current overhead: " << mp_total.overhead << " bytes (" <<
712 std::setprecision(3) << xpercent(mp_total.overhead, mp_total.meter->inuse.currentLevel()) << "%)\n";
713 /* limits */
714 if (MemPools::GetInstance().idleLimit() >= 0)
715 stream << "Idle pool limit: " << std::setprecision(2) << toMB(MemPools::GetInstance().idleLimit()) << " MB\n";
716 /* limits */
717 auto poolCount = MemPools::GetInstance().pools.size();
718 stream << "Total Pools created: " << poolCount << "\n";
719 stream << "Pools ever used: " << poolCount - not_used << " (shown above)\n";
720 stream << "Currently in use: " << poolsInUse << "\n";
721}
722
int size
Definition: ModDevPoll.cc:75
time_t squid_curtime
Definition: stub_libtime.cc:20
#define memPoolCreate
Creates a named MemPool of elements with the given size.
Definition: Pool.h:123
class SquidConfig Config
Definition: SquidConfig.cc:12
#define assert(EX)
Definition: assert.h:17
void setIdleLimit(const ssize_t newLimit)
Definition: Pool.h:78
std::list< Mem::Allocator * > pools
Definition: Pool.h:112
static MemPools & GetInstance()
Definition: Pool.cc:27
void clean(time_t maxage)
Definition: Pool.cc:105
static size_t RoundedSize(const size_t minSize)
Definition: Allocator.h:89
int getInUseCount() const
the difference between the number of alloc() and freeOne() calls
Definition: Allocator.h:55
virtual void setChunkSize(size_t)
XXX: Misplaced – not all allocators have a notion of a "chunk". See MemPoolChunked.
Definition: Allocator.h:61
void freeOne(void *obj)
return memory reserved by alloc()
Definition: Allocator.h:47
void zeroBlocks(const bool doIt)
Definition: Allocator.h:58
void * alloc()
provide (and reserve) memory suitable for storing one object
Definition: Allocator.h:40
PoolMeter meter
statistics tracked for this allocator
Definition: Allocator.h:111
ssize_t currentLevel() const
Definition: Meter.h:26
time_t peakTime() const
Definition: Meter.h:28
ssize_t peak() const
Definition: Meter.h:27
Meter idle
Definition: Meter.h:91
mgb_t gb_allocated
Definition: Meter.h:94
Meter alloc
Definition: Meter.h:89
Meter inuse
Definition: Meter.h:90
mgb_t gb_oallocated
Definition: Meter.h:95
mgb_t gb_saved
Definition: Meter.h:98
int items_inuse
Definition: Stats.h:33
const char * label
Definition: Stats.h:21
int overhead
Definition: Stats.h:36
int obj_size
Definition: Stats.h:23
int items_alloc
Definition: Stats.h:32
Allocator * pool
Definition: Stats.h:20
int chunks_free
Definition: Stats.h:30
int chunks_inuse
Definition: Stats.h:28
int chunk_capacity
Definition: Stats.h:24
int chunks_partial
Definition: Stats.h:29
int chunks_alloc
Definition: Stats.h:27
PoolMeter * meter
Definition: Stats.h:22
int items_idle
Definition: Stats.h:34
int64_t limit
Definition: SquidConfig.h:439
struct SquidConfig::@111 MemPools
struct SquidConfig::@106 onoff
Definition: fs_io.h:35
#define DBG_IMPORTANT
Definition: Stream.h:38
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:193
void eventAdd(const char *name, EVH *func, void *arg, double when, int weight, bool cbdata)
Definition: event.cc:107
#define toMB(size)
Definition: Pool.h:52
#define toKB(size)
Definition: Pool.h:54
#define SQUID_MD5_DIGEST_LENGTH
Definition: md5.h:66
void FREE(void *)
Definition: forward.h:37
mem_type
Types of memory pool which do not yet use MEMPROXY_CLASS() API.
Definition: forward.h:40
@ MEM_NONE
Definition: forward.h:41
@ MEM_32K_BUF
Definition: forward.h:46
@ MEM_2K_BUF
Definition: forward.h:42
@ MEM_4K_BUF
Definition: forward.h:43
@ MEM_64K_BUF
Definition: forward.h:47
@ MEM_DWRITE_Q
Definition: forward.h:49
@ MEM_MAX
Definition: forward.h:51
@ MEM_MD5_DIGEST
Definition: forward.h:50
@ MEM_8K_BUF
Definition: forward.h:44
@ MEM_16K_BUF
Definition: forward.h:45
@ MEM_DREAD_CTRL
Definition: forward.h:48
size_t GlobalStats(PoolStats &)
Definition: Stats.cc:15
void PoolReport(const PoolStats *, const PoolMeter *, std::ostream &)
Definition: old_api.cc:581
void Init()
Definition: old_api.cc:425
void Report(std::ostream &)
Definition: old_api.cc:651
void CleanIdlePools(void *unused)
Definition: old_api.cc:399
void Stats(StoreEntry *)
Definition: old_api.cc:165
void RegisterAction(char const *action, char const *desc, OBJH *handler, int pw_req_flag, int atomic)
Definition: Registration.cc:16
class Ping::pingStats_ stats
#define xfree
#define xmalloc
void memFree(void *p, int type)
Free a element allocated by memAllocate()
Definition: old_api.cc:221
static Mem::Meter HugeBufCountMeter
Definition: old_api.cc:55
static Mem::Allocator & GetStrPool(size_t type)
Definition: old_api.cc:80
#define mem_str_pool_count
Definition: old_api.cc:45
static Mem::Allocator *& GetPool(size_t type)
Definition: old_api.cc:63
static void memFree4K(void *)
Definition: old_api.cc:515
static double xm_time
Definition: old_api.cc:41
void memClean(void)
Main cleanup handler.
Definition: old_api.cc:485
void memFreeBuf(size_t size, void *buf)
Definition: old_api.cc:383
int memInUse(mem_type type)
Definition: old_api.cc:501
static mem_type memFindBufSizeType(size_t net_size, size_t *gross_size)
Definition: old_api.cc:308
size_t memStringCount()
Definition: old_api.cc:264
void * memReallocBuf(void *oldbuf, size_t net_size, size_t *gross_size)
Definition: old_api.cc:359
void memCheckInit(void)
Definition: old_api.cc:471
static mem_type & operator++(mem_type &aMem)
Definition: old_api.cc:460
static double xm_deltat
Definition: old_api.cc:42
static void memFree2K(void *)
Definition: old_api.cc:509
static void memFree16K(void *)
Definition: old_api.cc:527
void * memAllocBuf(size_t net_size, size_t *gross_size)
Definition: old_api.cc:344
static void memFree32K(void *)
Definition: old_api.cc:533
static double clean_interval
Definition: old_api.cc:396
void * memAllocate(mem_type type)
Allocate one element from the typed pool.
Definition: old_api.cc:213
static Mem::Meter StrVolumeMeter
Definition: old_api.cc:53
static void cxx_xfree(void *ptr)
Definition: old_api.cc:545
static Mem::Allocator * memFindStringPool(size_t net_size, bool fuzzy)
Definition: old_api.cc:117
static Mem::Meter HugeBufVolumeMeter
Definition: old_api.cc:56
static void memFree64K(void *)
Definition: old_api.cc:539
void memFreeRigid(void *buf, size_t net_size)
Definition: old_api.cc:290
static void memFree8K(void *)
Definition: old_api.cc:521
void * memAllocRigid(size_t net_size)
Definition: old_api.cc:248
void memDataInit(mem_type type, const char *name, size_t size, int, bool doZero)
Definition: old_api.cc:200
static void memStringStats(std::ostream &)
Definition: old_api.cc:130
static Mem::Meter StrCountMeter
Definition: old_api.cc:52
static void memBufStats(std::ostream &stream)
Definition: old_api.cc:157
void memFreeString(size_t size, void *buf)
Definition: old_api.cc:276
void * memAllocString(size_t net_size, size_t *gross_size)
Definition: old_api.cc:229
void memConfigure(void)
Definition: old_api.cc:406
FREE * memFreeBufFunc(size_t size)
Definition: old_api.cc:551
const char * name
Definition: old_api.cc:48
size_t obj_size
Definition: old_api.cc:49
int unsigned int
Definition: stub_fd.cc:19
double current_dtime
the current UNIX time in seconds (with microsecond precision)
Definition: stub_libtime.cc:19
SQUIDCEXTERN int xpercentInt(double part, double whole)
Definition: util.c:46
SQUIDCEXTERN double xpercent(double part, double whole)
Definition: util.c:40
SQUIDCEXTERN double xdiv(double nom, double denom)
Definition: util.c:53
SQUIDCEXTERN const char * double_to_str(char *buf, int buf_size, double value)
Definition: util.c:90
void * xcalloc(size_t n, size_t sz)
Definition: xalloc.cc:71

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors