Skip to content
Snippets Groups Projects

Knotc memstats

Merged Ghost User requested to merge mem-estim into master

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
98 99 $ knotc -c slave.conf checkconf # check configuration
99 100 $ knotd -c slave.conf
100 101 @end example
101
102 However to start it as a daemon, @code{knotc} tool should be used.
102 Estimate memory consumption for zone start it as a daemon, @code{knotc} tool should be used.
  • Ghost User
    Ghost User @ghost started a thread on commit 0b24db72
  • 116 116 you can use @code{knotc checkzone} action.
    117 117 @example
    118 118 $ knotc -c master.conf checkzone example.com
    119 @end example
    120
    121 For an aproximate estimate of server's memory consumption, you can use the @code{knotc memstats} action.
  • Ghost User
    Ghost User @ghost started a thread on commit 4bb1713d
  • 949 950 hattrie_apply_rev(est.dname_table, estimator_free_trie_node, NULL);
    950 951 hattrie_free(est.node_table);
    951 952 hattrie_free(est.dname_table);
    953
    954 size_t zone_size = (size_t)(((double)(est.rdata_size +
    955 est.node_size +
    956 est.rrset_size +
    957 est.dname_size +
    958 est.ahtable_size +
    959 malloc_size) * 1.2) / (1024.0 * 1024.0));
  • Ghost User
    Ghost User @ghost started a thread on commit 4bb1713d
  • 955 963 est.signed_count ?
    956 ((double)(est.record_count - est.signed_count)/ est.record_count) * 100 : 0.0,
    957 (size_t)(((double)(est.rdata_size +
    958 est.node_size +
    959 est.rrset_size +
    960 est.dname_size +
    961 est.ahtable_size +
    962 malloc_size) * 1.15) / (1024.0 * 1024.0)));
    964 ((double)(est.signed_count) / (est.record_count - est.signed_count)) * 100 : 0.0,
    965 zone_size);
    963 966 file_loader_free(loader);
    967 total_size += zone_size;
    968 }
    969
    970 if (argc == 0) { // for all zones
    971 log_zone_info("Estimated memory consumption for all zones=%zuMB.\n", total_size);
    • Author Contributor

      It may be a nitpicking, but I would prefer not to print messages like "...for all zones %zuMB" or "...for all zones is %zuMB". This make it more understandable than assignment operator (and without spaces around it).

    • Author Contributor

      Ok, I agree.

  • Ghost User
    Ghost User @ghost started a thread on commit d79a41e6
  • 40 uint16_t *types;
    41 size_t allocated;
    42 size_t used;
    43 } dummy_node_t;
    44
    45 // Insert value to position - move the rest of the array
    46 static void insert_on_pos(dummy_node_t *n, size_t pos, uint16_t t)
    47 {
    48 assert(pos <= n->used);
    49 memmove(n->types + pos + 1, n->types + pos, n->used - pos);
    50 n->types[pos] = t;
    51 n->used++;
    52 }
    53
    54 // Binary search in sorted array
    55 static int find_in_array(dummy_node_t *n, uint16_t t, size_t *pos, size_t bound)
  • Ghost User
    Ghost User @ghost started a thread on commit d79a41e6
  • 171 dummy_node_t *n;
    172 if (insert_dname_into_table(est, owner, &n) == 0) {
    173 // First time we see this dname
    174 est->size += dname_memsize(owner);
    175 // Add node constants
    176 est->size += sizeof(knot_node_t) * NODE_MULT + NODE_ADD;
    177 }
    178 knot_dname_free(&owner);
    179 assert(n);
    180
    181 // We will always add RDATA
    182 size_t rdlen = rdata_memsize(est, scanner);
    183 est->size += rdlen;
    184
    185 est->record_count++;
    186 est->signed_count += scanner->r_type == KNOT_RRTYPE_RRSIG ? 1 : 0;
  • Author Contributor

    Made a few comments, also:

    knot/zone/estimator.c:97:39: warning: passing 'uint8_t *' (aka 'unsigned char *') to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]
            value_t *val = hattrie_tryget(table, d->name, d->size);
                                                 ^~~~~~~
    ./common/hattrie/hat-trie.h:70:50: note: passing argument to parameter 'key' here
    value_t* hattrie_tryget (hattrie_t*, const char* key, size_t len);
                                                     ^
    knot/zone/estimator.c:102:23: warning: passing 'uint8_t *' (aka 'unsigned char *') to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]
                    *hattrie_get(table, d->name, d->size) = *n;
                                        ^~~~~~~
    ./common/hattrie/hat-trie.h:66:47: note: passing argument to parameter 'key' here
    value_t* hattrie_get (hattrie_t*, const char* key, size_t len);
  • Author Contributor

    Otherwise the estimates look sane.

  • Author Contributor

    Check out the changes please. Also, I've added missing header guards.

  • Author Contributor

    Ok, looks good. I have a few improvements in mind, but that would go to a separate ticket.

  • Author Contributor

    :thumbsup: :zap: :metal:

  • Please register or sign in to reply
    Loading