Skip to content

[upstream] extend the memory tier config to work with NUMA bindings and add tests #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 92 commits into from

Conversation

byrnedj
Copy link

@byrnedj byrnedj commented Jan 4, 2023

  • Add memory tier configs to cache allocator based on NUMA bindings
  • Add in MemoryTier tests
  • Add getPoolSize() and inline the calculate tier size for tests
  • Increase max number of tiers to 2 for tiers tests

This change is Reviewable

@byrnedj byrnedj requested review from vinser52 and igchor January 4, 2023 15:59
Copy link
Member

@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 11 files at r1, all commit messages.
Reviewable status: 10 of 11 files reviewed, 3 unresolved discussions (waiting on @byrnedj and @vinser52)


cachelib/allocator/CacheAllocator-inl.h line 116 at r1 (raw file):

  XDCHECK_EQ(memoryTierConfigs.size(), 1ul);
  opts.memBindNumaNodes = memoryTierConfigs[0].getMemBind();
  if (memoryTierConfigs.size() > 1) {

There is already assert 2 lines above so we'll never reach this line if we have 2 tiers. Perhaps it might be better to throw this exception from Config (congiureMemoryTiers) for now?


cachelib/allocator/CacheAllocator-inl.h line 2184 at r1 (raw file):

template <typename CacheTrait>
size_t CacheAllocator<CacheTrait>::getPoolSize(PoolId poolId) const {

Do you actually need this function? I think you could call getPoolStats and get the size from there.


cachelib/cachebench/util/CacheConfig.cpp line 104 at r1 (raw file):

  JSONSetVal(configJson, customConfigJson);
 
  JSONSetVal(configJson, usePosixShm);

why it's duplicated?

Copy link

@vinser52 vinser52 left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: 10 of 11 files reviewed, 3 unresolved discussions (waiting on @byrnedj and @igchor)


cachelib/cachebench/util/CacheConfig.cpp line 104 at r1 (raw file):

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

why it's duplicated?

Yeah, I think I already upstreamed these changes to Meta's main branch. Have you updated our main?

Copy link
Member

@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.

clang-format should be fixed

Reviewable status: 10 of 11 files reviewed, 3 unresolved discussions (waiting on @byrnedj and @vinser52)

@byrnedj byrnedj force-pushed the additional_memory_tier_config branch 2 times, most recently from dc3832d to 461f9c5 Compare January 5, 2023 12:49
Copy link
Author

@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.

done

Reviewable status: 3 of 11 files reviewed, 3 unresolved discussions (waiting on @igchor and @vinser52)


cachelib/allocator/CacheAllocator-inl.h line 116 at r1 (raw file):

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

There is already assert 2 lines above so we'll never reach this line if we have 2 tiers. Perhaps it might be better to throw this exception from Config (congiureMemoryTiers) for now?

configureMemoryTiers will throw if greater than kMaxTiers, so I removed this line.


cachelib/allocator/CacheAllocator-inl.h line 2184 at r1 (raw file):

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

Do you actually need this function? I think you could call getPoolStats and get the size from there.

Done.


cachelib/cachebench/util/CacheConfig.cpp line 104 at r1 (raw file):

Previously, vinser52 (Sergei Vinogradov) wrote…

Yeah, I think I already upstreamed these changes to Meta's main branch. Have you updated our main?

Done.

Copy link

@vinser52 vinser52 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 3 of 11 files reviewed, 4 unresolved discussions (waiting on @byrnedj and @igchor)


cachelib/cachebench/util/CacheConfig.cpp line 102 at r2 (raw file):

  JSONSetVal(configJson, nvmAdmissionRetentionTimeThreshold);

  JSONSetVal(configJson, customConfigJson);

Why this line is removed?

Copy link

@vinser52 vinser52 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 3 of 11 files reviewed, 5 unresolved discussions (waiting on @byrnedj and @igchor)


cachelib/allocator/tests/AllocatorMemoryTiersTest.h line 36 at r2 (raw file):

        {MemoryTierCacheConfig::fromShm().setRatio(1).setMemBind(
             std::string("0")),
         MemoryTierCacheConfig::fromShm().setRatio(1).setMemBind(

Will this test fail today (because only a single tier is allowed)?

@byrnedj byrnedj force-pushed the additional_memory_tier_config branch from 461f9c5 to 2bb164f Compare January 5, 2023 13:00
Copy link
Author

@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.

Reviewable status: 3 of 11 files reviewed, 5 unresolved discussions (waiting on @igchor and @vinser52)


cachelib/allocator/tests/AllocatorMemoryTiersTest.h line 36 at r2 (raw file):

Previously, vinser52 (Sergei Vinogradov) wrote…

Will this test fail today (because only a single tier is allowed)?

No because I increase kMaxTiers to 2 in CacheAllocatorConfig.h


cachelib/cachebench/util/CacheConfig.cpp line 102 at r2 (raw file):

Previously, vinser52 (Sergei Vinogradov) wrote…

Why this line is removed?

I just noticed this when removing the duplicate - I fixed now. There should be no change to this file.

Code quote:

customConfigJson

Copy link

@vinser52 vinser52 left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r3.
Reviewable status: 4 of 11 files reviewed, 4 unresolved discussions (waiting on @byrnedj and @igchor)


cachelib/allocator/tests/AllocatorMemoryTiersTest.h line 36 at r2 (raw file):

Previously, byrnedj (Daniel Byrne) wrote…

No because I increase kMaxTiers to 2 in CacheAllocatorConfig.h

In that case, I think we should throw an exception in the CacheAllocator constructor if (number of tiers > 1) because CacheAllocator is not enabled yet to support more then 1 tier.

Copy link
Author

@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.

Reviewable status: 4 of 11 files reviewed, 4 unresolved discussions (waiting on @igchor and @vinser52)


cachelib/allocator/tests/AllocatorMemoryTiersTest.h line 36 at r2 (raw file):

Previously, vinser52 (Sergei Vinogradov) wrote…

In that case, I think we should throw an exception in the CacheAllocator constructor if (number of tiers > 1) because CacheAllocator is not enabled yet to support more then 1 tier.

We currently have assert in CacheAllocator constructor to check number of tiers == 1, if you think exception is better I can change.

Copy link

@vinser52 vinser52 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 4 of 11 files reviewed, 4 unresolved discussions (waiting on @byrnedj and @igchor)


cachelib/allocator/tests/AllocatorMemoryTiersTest.h line 36 at r2 (raw file):

Previously, byrnedj (Daniel Byrne) wrote…

We currently have assert in CacheAllocator constructor to check number of tiers == 1, if you think exception is better I can change.

Yeah, I think an exception is better because assert is usually used to check for an unexpected condition caused by a mistake in the code logic. In our case, config allows to set 2 tiers but CacheAllocator does not support it yet. In other words cache config is the external input and we cannot control it - it is better to throw an exception in that case.

@byrnedj byrnedj force-pushed the additional_memory_tier_config branch from 2bb164f to a30859f Compare January 5, 2023 13:54
Copy link
Author

@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.

Reviewable status: 4 of 11 files reviewed, 4 unresolved discussions (waiting on @igchor and @vinser52)


cachelib/allocator/tests/AllocatorMemoryTiersTest.h line 36 at r2 (raw file):

Previously, vinser52 (Sergei Vinogradov) wrote…

Yeah, I think an exception is better because assert is usually used to check for an unexpected condition caused by a mistake in the code logic. In our case, config allows to set 2 tiers but CacheAllocator does not support it yet. In other words cache config is the external input and we cannot control it - it is better to throw an exception in that case.

okay - done.

Copy link

@vinser52 vinser52 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 4 of 11 files reviewed, 3 unresolved discussions (waiting on @igchor)

Copy link

@vinser52 vinser52 left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: 4 of 11 files reviewed, 3 unresolved discussions (waiting on @igchor)

Open Source Bot and others added 10 commits February 15, 2023 19:44
Summary:
GitHub commits:

facebook/wangle@43e5620
facebookexperimental/edencommon@3934bec
facebookincubator/katran@a4c94aa

Reviewed By: jurajh-fb

fbshipit-source-id: 720310662068e4aa245198d817666700c9dde1d5
Summary: As mentioned in the tasks, these stats make more sense in rates.

Reviewed By: jiayuebao

Differential Revision: D43243498

fbshipit-source-id: 556b0b4a062235bb3b34dd076e5f7a5a88316f8c
Summary:
GitHub commits:

facebook@ba9dd68
facebook/fbthrift@23208ff
facebookincubator/velox@68b8a45

Reviewed By: jurajh-fb

fbshipit-source-id: f8581e13cd1c0a2510d87f42c813ca2c65eaef1d
Summary:
GitHub commits:

facebook/fbthrift@3b00d58

Reviewed By: jurajh-fb

fbshipit-source-id: 23ecb07e7e9ebd4dfbf3980de141ea1ebe36bb12
Summary:
GitHub commits:

facebook/fbthrift@df0eb61
facebook/proxygen@7fc3fea

Reviewed By: jurajh-fb

fbshipit-source-id: fa982baf35fd98edc52be391f03d15a9c2c333bf
Summary:
GitHub commits:

facebook/fbthrift@1d01d76

Reviewed By: jurajh-fb

fbshipit-source-id: bdefba88e8d002c65d8b7c11e86c8aa772996d9b
Summary:
GitHub commits:

facebook/fbthrift@1b848d8
facebook/rocksdb@cfe50f7
pytorch/FBGEMM@c55d800

Reviewed By: bigfootjon

fbshipit-source-id: e840d1116311ac52336e598442cf66cdc50d7725
Summary:
GitHub commits:

facebook/fbthrift@90fddab

Reviewed By: bigfootjon

fbshipit-source-id: cf7ac48c00c548805fb74663fe3e9bd9f5906cc2
Summary: Currently `replacedPtr` is passed as an argument and such usage isn't easy to understand (we kept receiving user feedback on that). Now we want to return it.

Reviewed By: therealgymmy, antonf, jaesoo-fb

Differential Revision: D43143989

fbshipit-source-id: eaae055107050cd67a7ca8b26b716fffc0c002f2
Open Source Bot and others added 27 commits March 22, 2023 06:53
Summary:
Previously, in order to use a file as the backing store of nvm cache, user needs to create the file
with the given size a priori, hurting the usability of the feature. This change fixes it so that the
new file with the given size is automatically created if not exist. Also, if the file exists with
different size, this change will allow the cachebench to ftruncate or fallocate to the given size
automatically.

Reviewed By: therealgymmy

Differential Revision: D44154281

fbshipit-source-id: c622102d4d67b64da83dcad4fdade66473d70a1f
Summary:
GitHub commits:

facebook/fbthrift@9b313e2

Reviewed By: bigfootjon

fbshipit-source-id: 4398acf93c32d22238246b0df0f01c2605483c97
Summary:
GitHub commits:

facebook/fbthrift@6fbae55

Reviewed By: bigfootjon

fbshipit-source-id: 6f8278f6d8c2f25092b24aa41cee5f32c6e5ac3b
Summary:
GitHub commits:

facebook/fbthrift@6442718
facebookincubator/fizz@109be99

Reviewed By: bigfootjon

fbshipit-source-id: 9c75f0e170a10e2b6cf1913b407f117f1f4091e5
Summary:
GitHub commits:

facebook/fbthrift@5763f96

Reviewed By: bigfootjon

fbshipit-source-id: 56d3adc9df6b8e900d00622b5a7c08fe75d6c6a5
Reviewed By: DenisYaroshevskiy

Differential Revision: D44396854

fbshipit-source-id: 17d3f4271f1bf8c403519471a54bd910af38814c
Summary:
GitHub commits:

facebook/fbthrift@48771f2

Reviewed By: bigfootjon

fbshipit-source-id: 9c68f2e95e7b8007941238d42a6714682c5e4d68
Summary:
GitHub commits:

facebook/fbthrift@7ab0a87
facebook/proxygen@22104db
facebook/watchman@43ed48a
facebookincubator/katran@926b507
facebookincubator/velox@3159ba9

Reviewed By: jailby

fbshipit-source-id: 25e30991c7cb2da16ff3966627ff5a7fc182a553
Summary:
When size-awareness is enabled for mutable workloads, user must call `objCache_->mutateObject(objPtr, mutationCb)` so that object-cache can track the updated size.

What should happen inside `mutationCb`?
1. a construction of the new value with deep copy
2. if the new value is going to replace an old value, a destruction of the old value

See unit test for examples.

-----

Reviewed By: jaesoo-fb

Differential Revision: D42872059

fbshipit-source-id: b94eddd6d640a04ee7974f9273509e60d5aa6915
Summary:
GitHub commits:

facebook/fbthrift@737cfa0
facebook/mvfst@24e04e1
facebookincubator/velox@55daa3e
fairinternal/egohowto@f8b1870

Reviewed By: jailby

fbshipit-source-id: e801db60548241573e35446c8676039a893752a9
Summary:
GitHub commits:

facebook/fbthrift@ef080b3
facebook/proxygen@a2d125b

Reviewed By: jailby

fbshipit-source-id: 1b820a1e3c85011c2b6f535caca237a74ec69568
Summary:
GitHub commits:

facebook/fbthrift@6b2d7a9

Reviewed By: jailby

fbshipit-source-id: 3ccc40b3a1956cde45388e7e0ffad5d6196c517b
Summary:
GitHub commits:

facebook/fbthrift@639434b
facebook/proxygen@a628b5a
facebook/watchman@2fc3dba
facebookincubator/velox@38d7601

Reviewed By: jailby

fbshipit-source-id: 607d6696a1b803a79a4509c55de96e307f3b698a
Summary:
GitHub commits:

facebook/fbthrift@33a57fc

Reviewed By: yns88

fbshipit-source-id: a8cc153a7b8c1491ae264b42e4d1aaf6d637aefe
Summary:
GitHub commits:

facebook/fb303@28cfb1d
facebook/fbthrift@bb45e17
facebook/watchman@7aa562b
facebookexperimental/rust-shed@47f504b
facebookincubator/velox@58a8e26

Reviewed By: yns88

fbshipit-source-id: e56b09ecacd3bb3a4a8e7a16148faf44d5b0a437
Summary:
GitHub commits:

facebook/fbthrift@d0d2943
facebook/proxygen@ce6978b
facebookincubator/velox@aed1ddf

Reviewed By: yns88

fbshipit-source-id: 87cf81b096e7501d13a70ea6062da3e72a39aa65
Summary:
GitHub commits:

facebook/fbthrift@eb2041c
facebook/proxygen@c23cd09

Reviewed By: yns88

fbshipit-source-id: df09b7f4c50e00d5a1491740c999b9008ccfed0e
Summary:
GitHub commits:

facebook/fbthrift@ea52832
facebook/proxygen@a080dfe
facebook/wangle@a153b33
facebookincubator/katran@c24fd07

Reviewed By: yns88

fbshipit-source-id: 9e77bc08070edf5c78c85e856c57defc3b19f454
Summary:
GitHub commits:

facebook/fbthrift@cd36a53
facebook/watchman@b8c7a3d

Reviewed By: yns88

fbshipit-source-id: a1ce2257a8630a9098f239ca49e294cf3dc6bce0
Summary: As title

Reviewed By: jaesoo-fb

Differential Revision: D44358110

fbshipit-source-id: d9359f25b9f6f58dd7f22cb0b45dd71b6a73848b
Summary:
GitHub commits:

facebook/fbthrift@59053eb

Reviewed By: yns88

fbshipit-source-id: aea2de1893720da1b9b811c1fe00f3ad432fbfc5
Summary:
This should be enabled by default

It is an improvement in all cases. It’s roughly the same for hit-path. And, it helps miss path performance since it performs all the checks inline as opposed to thread-hop.

Reviewed By: jaesoo-fb

Differential Revision: D44554147

fbshipit-source-id: 6ec59d9ac1548ce30199ee1f3c495b92287fb739
Summary:
GitHub commits:

facebook/fb303@e3d5fe9
facebook/fbthrift@62c3335
facebookexperimental/rust-shed@cf98c92
facebookincubator/velox@0e5889c

Reviewed By: yns88

fbshipit-source-id: a4281211b976f5c65929bbc3bd0305225ecabd38
@byrnedj byrnedj force-pushed the additional_memory_tier_config branch from a30859f to aab34a6 Compare April 3, 2023 19:55
- Add in MemoryTier tests
- Increase max number of tiers to 2 for tiers tests
@byrnedj byrnedj closed this Apr 3, 2023
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.

7 participants