MCPcopy Create free account
hub / github.com/ElementsProject/lightning / timers_dump

Function timers_dump

ccan/ccan/timer/timer.c:501–555  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

499}
500
501void timers_dump(const struct timers *timers, FILE *fp)
502{
503 unsigned int l, i, off;
504 unsigned long long base;
505
506 if (!fp)
507 fp = stderr;
508
509 fprintf(fp, "Base: %llu\n", (unsigned long long)timers->base);
510
511 if (!timers->level[0])
512 goto past_levels;
513
514 fprintf(fp, "Level 0:\n");
515
516 /* First level is simple. */
517 off = timers->base % PER_LEVEL;
518 for (i = 0; i < PER_LEVEL; i++) {
519 const struct list_head *h;
520
521 fprintf(fp, " Bucket %llu (%lu):",
522 (i+off) % PER_LEVEL, timers->base + i);
523 h = &timers->level[0]->list[(i+off) % PER_LEVEL];
524 dump_bucket_stats(fp, h);
525 }
526
527 /* For other levels, "current" bucket has been emptied, and may contain
528 * entries for the current + level_size bucket. */
529 for (l = 1; l < ARRAY_SIZE(timers->level) && timers->level[l]; l++) {
530 uint64_t per_bucket = 1ULL << (TIMER_LEVEL_BITS * l);
531
532 off = ((timers->base >> (l*TIMER_LEVEL_BITS)) % PER_LEVEL);
533 /* We start at *next* bucket. */
534 base = (timers->base & ~(per_bucket - 1)) + per_bucket;
535
536 fprintf(fp, "Level %u:\n", l);
537 for (i = 1; i <= PER_LEVEL; i++) {
538 const struct list_head *h;
539
540 fprintf(fp, " Bucket %llu (%llu - %llu):",
541 (i+off) % PER_LEVEL,
542 base, base + per_bucket - 1);
543
544 h = &timers->level[l]->list[(i+off) % PER_LEVEL];
545 dump_bucket_stats(fp, h);
546 base += per_bucket;
547 }
548 }
549
550past_levels:
551 if (!list_empty(&timers->far)) {
552 fprintf(fp, "Far timers:");
553 dump_bucket_stats(fp, &timers->far);
554 }
555}
556#endif
557
558void timers_cleanup(struct timers *timers)

Callers 1

mainFunction · 0.85

Calls 1

dump_bucket_statsFunction · 0.85

Tested by 1

mainFunction · 0.68