compact_hash.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include "compact_hash.h"
  2. #include <util/generic/map.h>
  3. #include <util/stream/str.h>
  4. namespace NKikimr {
  5. namespace NCHash {
  6. void TListPoolBase::FreeListPage(TListHeader* p) {
  7. Y_ASSERT(TAlignedPagePool::GetPageStart(p) == p);
  8. p->~TListHeader();
  9. PagePool_.ReturnPage(p);
  10. }
  11. size_t TListPoolBase::TUsedPages::PrintStat(const TStringBuf& header, IOutputStream& out) const {
  12. TMap<ui32, ui64> counts;
  13. size_t pages = 0;
  14. for (auto& p: FullPages) {
  15. ++pages;
  16. ++counts[p.As<TListHeader>()->ListSize];
  17. }
  18. for (auto& c: counts) {
  19. out << header << "Count of full pages<" << c.first << ">: " << c.second << Endl;
  20. }
  21. for (size_t i = 0; i < SmallPages.size(); ++i) {
  22. if (size_t size = SmallPages[i].Size()) {
  23. pages += size;
  24. out << header << "Count of partially free pages<" << SmallPages[i].Front()->As<TListHeader>()->ListSize << ">: " << size << Endl;
  25. }
  26. }
  27. for (size_t i = 0; i < MediumPages.size(); ++i) {
  28. if (size_t size = MediumPages[i].Size()) {
  29. pages += size;
  30. out << header << "Count of partially free pages<" << MediumPages[i].Front()->As<TListHeader>()->ListSize << ">: " << size << Endl;
  31. }
  32. }
  33. return pages;
  34. }
  35. TString TListPoolBase::TUsedPages::DebugInfo() const {
  36. TStringStream out;
  37. TMap<ui32, ui64> counts;
  38. for (auto& p: FullPages) {
  39. out << "Full page<" << p.As<TListHeader>()->ListSize << ">: " << p.As<TListHeader>()->FreeLists << Endl;
  40. }
  41. for (size_t i = 0; i < SmallPages.size(); ++i) {
  42. for (auto& p: SmallPages[i]) {
  43. out << "Partially free page<" << p.As<TListHeader>()->ListSize << ">: " << p.As<TListHeader>()->FreeLists << Endl;
  44. }
  45. }
  46. for (size_t i = 0; i < MediumPages.size(); ++i) {
  47. for (auto& p: MediumPages[i]) {
  48. out << "Partially free page<" << p.As<TListHeader>()->ListSize << ">: " << p.As<TListHeader>()->FreeLists << Endl;
  49. }
  50. }
  51. return out.Str();
  52. }
  53. } // NCHash
  54. } // NKikimr