]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove the total memory counter
authorOndřej Surý <ondrej@isc.org>
Thu, 19 Jan 2023 10:50:39 +0000 (11:50 +0100)
committerOndřej Surý <ondrej@isc.org>
Tue, 24 Jan 2023 17:57:16 +0000 (17:57 +0000)
The total memory counter had again little or no meaning when we removed
the internal memory allocator.  It was just a monotonic counter that
would count add the allocation sizes but never subtracted anything, so
it would be just a "big number".

bin/named/bind9.xsl
lib/dns/cache.c
lib/isc/include/isc/mem.h
lib/isc/mem.c
tests/isc/mem_test.c

index 6cbdfcc69311f9728edb3b25b0dbfc6606b34807..14901aa531f0f000c8a94e05d85fa406d9b9774a 100644 (file)
               <th>ID</th>
               <th>Name</th>
               <th>References</th>
-              <th>TotalUse</th>
               <th>InUse</th>
               <th>BlockSize</th>
               <th>Pools</th>
                 <td>
                   <xsl:value-of select="references"/>
                 </td>
-                <td>
-                  <xsl:value-of select="total"/>
-                </td>
                 <td>
                   <xsl:value-of select="inuse"/>
                 </td>
index 146ec8a3733ba5d1ec0afa5a0beb30ecb4731ebe..6f8067428c6db00bf07c82503fcbc80a1b394a9e 100644 (file)
@@ -644,13 +644,9 @@ dns_cache_dumpstats(dns_cache_t *cache, FILE *fp) {
        fprintf(fp, "%20" PRIu64 " %s\n", (uint64_t)dns_db_hashsize(cache->db),
                "cache database hash buckets");
 
-       fprintf(fp, "%20" PRIu64 " %s\n", (uint64_t)isc_mem_total(cache->mctx),
-               "cache tree memory total");
        fprintf(fp, "%20" PRIu64 " %s\n", (uint64_t)isc_mem_inuse(cache->mctx),
                "cache tree memory in use");
 
-       fprintf(fp, "%20" PRIu64 " %s\n", (uint64_t)isc_mem_total(cache->hmctx),
-               "cache heap memory total");
        fprintf(fp, "%20" PRIu64 " %s\n", (uint64_t)isc_mem_inuse(cache->hmctx),
                "cache heap memory in use");
 }
@@ -708,10 +704,8 @@ dns_cache_renderxml(dns_cache_t *cache, void *writer0) {
                        dns_db_nodecount(cache->db, dns_dbtree_nsec), writer));
        TRY0(renderstat("CacheBuckets", dns_db_hashsize(cache->db), writer));
 
-       TRY0(renderstat("TreeMemTotal", isc_mem_total(cache->mctx), writer));
        TRY0(renderstat("TreeMemInUse", isc_mem_inuse(cache->mctx), writer));
 
-       TRY0(renderstat("HeapMemTotal", isc_mem_total(cache->hmctx), writer));
        TRY0(renderstat("HeapMemInUse", isc_mem_inuse(cache->hmctx), writer));
 error:
        return (xmlrc);
@@ -782,18 +776,10 @@ dns_cache_renderjson(dns_cache_t *cache, void *cstats0) {
        CHECKMEM(obj);
        json_object_object_add(cstats, "CacheBuckets", obj);
 
-       obj = json_object_new_int64(isc_mem_total(cache->mctx));
-       CHECKMEM(obj);
-       json_object_object_add(cstats, "TreeMemTotal", obj);
-
        obj = json_object_new_int64(isc_mem_inuse(cache->mctx));
        CHECKMEM(obj);
        json_object_object_add(cstats, "TreeMemInUse", obj);
 
-       obj = json_object_new_int64(isc_mem_total(cache->hmctx));
-       CHECKMEM(obj);
-       json_object_object_add(cstats, "HeapMemTotal", obj);
-
        obj = json_object_new_int64(isc_mem_inuse(cache->hmctx));
        CHECKMEM(obj);
        json_object_object_add(cstats, "HeapMemInUse", obj);
index f2e4b43065725946c494641a2a3b4994348d615f..0a0c87759468900dff248831cce00ae9b9786bf7 100644 (file)
@@ -271,13 +271,6 @@ isc_mem_inuse(isc_mem_t *mctx);
  * allocated from the system but not yet used.
  */
 
-size_t
-isc_mem_total(isc_mem_t *mctx);
-/*%<
- * Get the total amount of memory in 'mctx', in bytes, including memory
- * not yet used.
- */
-
 bool
 isc_mem_isovermem(isc_mem_t *mctx);
 /*%<
index f7217f3471aec0186ef864bc64a279123cb91c88..63f5c4cf6e80c066bfe5550b9fd63ee4a7a496df 100644 (file)
@@ -141,7 +141,6 @@ struct isc_mem {
        struct stats stats[STATS_BUCKETS + 1];
        isc_refcount_t references;
        char name[16];
-       atomic_size_t total;
        atomic_size_t inuse;
        atomic_bool hi_called;
        atomic_bool is_overmem;
@@ -378,7 +377,6 @@ static void
 mem_getstats(isc_mem_t *ctx, size_t size) {
        struct stats *stats = stats_bucket(ctx, size);
 
-       atomic_fetch_add_relaxed(&ctx->total, size);
        atomic_fetch_add_release(&ctx->inuse, size);
 
        atomic_fetch_add_relaxed(&stats->gets, 1);
@@ -459,7 +457,6 @@ mem_create(isc_mem_t **ctxp, unsigned int debugging, unsigned int flags) {
        isc_mutex_init(&ctx->lock);
        isc_refcount_init(&ctx->references, 1);
 
-       atomic_init(&ctx->total, 0);
        atomic_init(&ctx->inuse, 0);
        atomic_init(&ctx->hi_water, 0);
        atomic_init(&ctx->lo_water, 0);
@@ -1014,13 +1011,6 @@ isc_mem_inuse(isc_mem_t *ctx) {
        return (atomic_load_acquire(&ctx->inuse));
 }
 
-size_t
-isc_mem_total(isc_mem_t *ctx) {
-       REQUIRE(VALID_CONTEXT(ctx));
-
-       return (atomic_load_acquire(&ctx->total));
-}
-
 void
 isc_mem_clearwater(isc_mem_t *mctx) {
        isc_mem_setwater(mctx, NULL, NULL, 0, 0);
@@ -1391,7 +1381,6 @@ isc_mem_references(isc_mem_t *ctx) {
 }
 
 typedef struct summarystat {
-       uint64_t total;
        uint64_t inuse;
        uint64_t contextsize;
 } summarystat_t;
@@ -1437,12 +1426,6 @@ xml_renderctx(isc_mem_t *ctx, summarystat_t *summary, xmlTextWriterPtr writer) {
                isc_refcount_current(&ctx->references)));
        TRY0(xmlTextWriterEndElement(writer)); /* references */
 
-       summary->total += isc_mem_total(ctx);
-       TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "total"));
-       TRY0(xmlTextWriterWriteFormatString(writer, "%" PRIu64 "",
-                                           (uint64_t)isc_mem_total(ctx)));
-       TRY0(xmlTextWriterEndElement(writer)); /* total */
-
        summary->inuse += isc_mem_inuse(ctx);
        TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "inuse"));
        TRY0(xmlTextWriterWriteFormatString(writer, "%" PRIu64 "",
@@ -1501,11 +1484,6 @@ isc_mem_renderxml(void *writer0) {
 
        TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "summary"));
 
-       TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "TotalUse"));
-       TRY0(xmlTextWriterWriteFormatString(writer, "%" PRIu64 "",
-                                           summary.total));
-       TRY0(xmlTextWriterEndElement(writer)); /* TotalUse */
-
        TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "InUse"));
        TRY0(xmlTextWriterWriteFormatString(writer, "%" PRIu64 "",
                                            summary.inuse));
@@ -1542,7 +1520,6 @@ json_renderctx(isc_mem_t *ctx, summarystat_t *summary, json_object *array) {
        MCTXLOCK(ctx);
 
        summary->contextsize += sizeof(*ctx);
-       summary->total += isc_mem_total(ctx);
        summary->inuse += isc_mem_inuse(ctx);
 #if ISC_MEM_TRACKLINES
        if (ctx->debuglist != NULL) {
@@ -1570,10 +1547,6 @@ json_renderctx(isc_mem_t *ctx, summarystat_t *summary, json_object *array) {
        CHECKMEM(obj);
        json_object_object_add(ctxobj, "references", obj);
 
-       obj = json_object_new_int64(isc_mem_total(ctx));
-       CHECKMEM(obj);
-       json_object_object_add(ctxobj, "total", obj);
-
        obj = json_object_new_int64(isc_mem_inuse(ctx));
        CHECKMEM(obj);
        json_object_object_add(ctxobj, "inuse", obj);
@@ -1622,10 +1595,6 @@ isc_mem_renderjson(void *memobj0) {
        }
        UNLOCK(&contextslock);
 
-       obj = json_object_new_int64(summary.total);
-       CHECKMEM(obj);
-       json_object_object_add(memobj, "TotalUse", obj);
-
        obj = json_object_new_int64(summary.inuse);
        CHECKMEM(obj);
        json_object_object_add(memobj, "InUse", obj);
index 5badf1a10c9e7396bbeb19aea6cc720971db3abd..cdcbda0f285a002a6c76e866871d503529095c08 100644 (file)
@@ -242,50 +242,6 @@ ISC_RUN_TEST_IMPL(isc_mem_allocate_zero) {
        isc_mem_free(mctx, ptr);
 }
 
-/* test TotalUse calculation */
-ISC_RUN_TEST_IMPL(isc_mem_total) {
-       isc_mem_t *mctx2 = NULL;
-       size_t before, after;
-       ssize_t diff;
-       int i;
-
-       /* Local alloc, free */
-       mctx2 = NULL;
-       isc_mem_create(&mctx2);
-
-       before = isc_mem_total(mctx2);
-
-       for (i = 0; i < 100000; i++) {
-               void *ptr;
-
-               ptr = isc_mem_get(mctx2, 2048);
-               isc_mem_put(mctx2, ptr, 2048);
-       }
-
-       after = isc_mem_total(mctx2);
-       diff = after - before;
-
-       assert_int_equal(diff, (2048) * 100000);
-
-       /* ISC_MEMFLAG_INTERNAL */
-
-       before = isc_mem_total(mctx);
-
-       for (i = 0; i < 100000; i++) {
-               void *ptr;
-
-               ptr = isc_mem_get(mctx, 2048);
-               isc_mem_put(mctx, ptr, 2048);
-       }
-
-       after = isc_mem_total(mctx);
-       diff = after - before;
-
-       assert_int_equal(diff, (2048) * 100000);
-
-       isc_mem_destroy(&mctx2);
-}
-
 /* test InUse calculation */
 ISC_RUN_TEST_IMPL(isc_mem_inuse) {
        isc_mem_t *mctx2 = NULL;
@@ -598,7 +554,6 @@ ISC_TEST_ENTRY(isc_mem_allocate_align)
 #endif /* defined(HAVE_MALLOC_NP_H) || defined(HAVE_JEMALLOC) */
 ISC_TEST_ENTRY(isc_mem_get_zero)
 ISC_TEST_ENTRY(isc_mem_allocate_zero)
-ISC_TEST_ENTRY(isc_mem_total)
 ISC_TEST_ENTRY(isc_mem_inuse)
 ISC_TEST_ENTRY(isc_mem_zeroget)
 ISC_TEST_ENTRY(isc_mem_reget)