Skip to content

Conversation

@guptask
Copy link

@guptask guptask commented Nov 21, 2022

added ability for compressed pointer to use full 32 bits for addressing in single tier mode and use 31 bits for addressing in multi-tier mode


This change is Reviewable

@guptask guptask self-assigned this Nov 21, 2022
@guptask guptask force-pushed the cptr_tiers branch 7 times, most recently from 37218e1 to b5dcfea Compare November 28, 2022 23:54
@guptask guptask marked this pull request as ready for review November 29, 2022 22:37
@guptask guptask requested a review from igchor November 29, 2022 22:37
Copy link

@igchor igchor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 10 of 10 files at r1, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @guptask)


cachelib/allocator/memory/CompressedPtr.h line 49 at r1 (raw file):

// the following are for pointer compression for the memory allocator.  We
// compress pointers by storing the tier index, slab index and alloc index
// of the allocation inside the slab. With slab worth kNumSlabBits (22 bits)

why this description is repeated?


cachelib/allocator/memory/CompressedPtr.h line 82 at r1 (raw file):

  // maximum adressable memory for pointer compression to work.
  static constexpr size_t getMaxAddressableSize() noexcept {
    return static_cast<size_t>(1) << (kNumSlabIdxBits + Slab::kNumSlabBits + 1);

why +1? we have the same total addressable memory in total - half for each tier, right?
Can you add some test for this?


cachelib/allocator/memory/CompressedPtr.h line 139 at r1 (raw file):

      return (slabIdx << kNumAllocIdxBits) + allocIdx;
    }
    XDCHECK_LT(slabIdx, (1u << kNumSlabIdxBits) - 1);

is this assert correct? with tier ID bit, we have less bits for slab, right?

You could also add ASSERT for tid I guess (< 2).


cachelib/allocator/memory/CompressedPtr.h line 214 at r1 (raw file):

    }

    bool isMultiTiered = allocators_.size() > 1 ? true : false;

you can drop ? true : false part


cachelib/allocator/memory/CompressedPtr.h line 216 at r1 (raw file):

    bool isMultiTiered = allocators_.size() > 1 ? true : false;
    auto cptr = allocators_[tid]->compress(uncompressed, isMultiTiered);
    if (allocators_.size() > 1) { // config has multiple tiers

why not just use isMultiTIered?


cachelib/allocator/memory/CompressedPtr.h line 226 at r1 (raw file):

      return nullptr;
    }
    bool isMultiTiered = allocators_.size() > 1 ? true : false;

same here


cachelib/allocator/tests/AllocatorMemoryTiersTest.h line 139 at r1 (raw file):

        slabStats = allocator->getAllocationClassStats(0,0,cid);
    }
    ASSERT_GE(slabStats.approxFreePercent,9.5);

why this is removed?

@guptask
Copy link
Author

guptask commented Nov 30, 2022

cachelib/allocator/memory/CompressedPtr.h line 49 at r1 (raw file):

Previously, igchor (Igor Chorążewicz) wrote…

why this description is repeated?

fixed

@guptask
Copy link
Author

guptask commented Nov 30, 2022

cachelib/allocator/memory/CompressedPtr.h line 82 at r1 (raw file):

Previously, igchor (Igor Chorążewicz) wrote…

why +1? we have the same total addressable memory in total - half for each tier, right?
Can you add some test for this?

I changed kNumTierIdxOffset to 31 from 32.

@guptask
Copy link
Author

guptask commented Nov 30, 2022

cachelib/allocator/memory/CompressedPtr.h line 82 at r1 (raw file):

Previously, guptask (Sounak Gupta) wrote…

I changed kNumTierIdxOffset to 31 from 32.

kNumSlabIdxBits = kNumTierIdxOffset (31) - kNumAllocIdxBits (16)

@guptask
Copy link
Author

guptask commented Nov 30, 2022

cachelib/allocator/memory/CompressedPtr.h line 139 at r1 (raw file):

Previously, igchor (Igor Chorążewicz) wrote…

is this assert correct? with tier ID bit, we have less bits for slab, right?

You could also add ASSERT for tid I guess (< 2).

In single tier mode, CompressedPtr doesn't reserve the 32nd bit for tier id. In this PR, kNumTierIdxOffset was changed from 32 to 31. So kNumSlabIdxBits = kNumTierIdxOffset - kNumAllocIdxBits = 31-16 = 15.

@guptask
Copy link
Author

guptask commented Nov 30, 2022

cachelib/allocator/tests/AllocatorMemoryTiersTest.h line 139 at r1 (raw file):

Previously, igchor (Igor Chorążewicz) wrote…

why this is removed?

moving to a separate commit since this fix is not directly related to CompressedPtr PR

@guptask
Copy link
Author

guptask commented Nov 30, 2022

cachelib/allocator/memory/CompressedPtr.h line 214 at r1 (raw file):

Previously, igchor (Igor Chorążewicz) wrote…

you can drop ? true : false part

done

@guptask
Copy link
Author

guptask commented Nov 30, 2022

cachelib/allocator/memory/CompressedPtr.h line 216 at r1 (raw file):

Previously, igchor (Igor Chorążewicz) wrote…

why not just use isMultiTIered?

done

@guptask
Copy link
Author

guptask commented Nov 30, 2022

cachelib/allocator/memory/CompressedPtr.h line 226 at r1 (raw file):

Previously, igchor (Igor Chorążewicz) wrote…

same here

done

…ng in single tier mode and use 31 bits for addressing in multi-tier mode
@guptask guptask requested a review from igchor November 30, 2022 18:25
Copy link

@igchor igchor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guptask can you run a hit_ratio leader and follower benchmark to see if there is no regression? I don't expect any but it would be good to make sure everything works as expected.

Reviewable status: 9 of 10 files reviewed, all discussions resolved (waiting on @guptask)

@guptask
Copy link
Author

guptask commented Nov 30, 2022

done. regression not observed.

Copy link

@byrnedj byrnedj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @guptask)

@byrnedj byrnedj merged commit 621d0cf into intel:develop Nov 30, 2022
@guptask guptask deleted the cptr_tiers branch November 30, 2022 23:39
byrnedj pushed a commit that referenced this pull request Jul 23, 2023
Fix eviction flow and removeCb calls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants