| 716 | } |
| 717 | |
| 718 | void |
| 719 | StripeSM::dir_check() |
| 720 | { |
| 721 | static int const SEGMENT_HISTOGRAM_WIDTH = 16; |
| 722 | int hist[SEGMENT_HISTOGRAM_WIDTH + 1] = {0}; |
| 723 | unsigned short chain_tag[MAX_ENTRIES_PER_SEGMENT]; |
| 724 | int32_t chain_mark[MAX_ENTRIES_PER_SEGMENT]; |
| 725 | |
| 726 | this->loadMeta(); |
| 727 | this->loadDir(); |
| 728 | int frag_demographics[1 << DIR_SIZE_WIDTH][DIR_BLOCK_SIZES] = {{0}}; |
| 729 | int j; |
| 730 | int stale = 0, in_use = 0, empty = 0; |
| 731 | int free = 0, head = 0, buckets_in_use = 0; |
| 732 | |
| 733 | int max_chain_length = 0; |
| 734 | int64_t bytes_in_use = 0; |
| 735 | |
| 736 | ink_zero(frag_demographics); |
| 737 | |
| 738 | std::cout << "Stripe '[" << hashText << "]'" << std::endl; |
| 739 | std::cout << " Directory Bytes: " << _segments * _buckets * SIZEOF_DIR << std::endl; |
| 740 | std::cout << " Segments: " << _segments << std::endl; |
| 741 | std::cout << " Buckets per segment: " << _buckets << std::endl; |
| 742 | std::cout << " Entries: " << _segments * _buckets * DIR_DEPTH << std::endl; |
| 743 | |
| 744 | for (int s = 0; s < _segments; s++) { |
| 745 | CacheDirEntry *seg = this->dir_segment(s); |
| 746 | int seg_chain_max = 0; |
| 747 | int seg_empty = 0; |
| 748 | int seg_in_use = 0; |
| 749 | int seg_stale = 0; |
| 750 | int seg_bytes_in_use = 0; |
| 751 | int seg_dups = 0; |
| 752 | int seg_buckets_in_use = 0; |
| 753 | |
| 754 | ink_zero(chain_tag); |
| 755 | memset(chain_mark, -1, sizeof(chain_mark)); |
| 756 | for (int b = 0; b < _buckets; b++) { |
| 757 | CacheDirEntry *root = dir_bucket(b, seg); |
| 758 | int h = 0; |
| 759 | int chain_idx = 0; |
| 760 | int mark = 0; |
| 761 | ++seg_buckets_in_use; |
| 762 | // walking through the directories |
| 763 | for (CacheDirEntry *e = root; e; e = next_dir(e, seg)) { |
| 764 | if (!dir_offset(e)) { |
| 765 | ++seg_empty; |
| 766 | --seg_buckets_in_use; |
| 767 | // this should only happen on the first dir in a bucket |
| 768 | ink_assert(nullptr == next_dir(e, seg)); |
| 769 | break; |
| 770 | } else { |
| 771 | int e_idx = e - seg; |
| 772 | ++h; |
| 773 | chain_tag[chain_idx++] = dir_tag(e); |
| 774 | if (chain_mark[e_idx] == mark) { |
| 775 | printf(" - Cycle of length %d detected for bucket %d\n", h, b); |
no test coverage detected