Skip to content

Attempt to disable NvmCacheState when NVM cache is not enabled. - #15

Merged
victoria-mcgrath merged 3 commits into
pmem:developfrom
victoria-mcgrath:nvm-check
Nov 29, 2021
Merged

Attempt to disable NvmCacheState when NVM cache is not enabled.#15
victoria-mcgrath merged 3 commits into
pmem:developfrom
victoria-mcgrath:nvm-check

Conversation

@victoria-mcgrath

@victoria-mcgrathvictoria-mcgrath commented Nov 23, 2021

Copy link
Copy Markdown
Collaborator

It seems that NvmCacheState object assumes that when cacheDir is specified then NVM cache is enabled. In case of cachebench used with multiple tiers and no NVM cache, this assumption is causing an error message: "E1122 21:27:43.287637 1212 NvmCacheState.cpp:135] unable to deserialize nvm metadata file: no content in file : ...".


This change is Reviewable

@igchorigchor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewable status: 0 of 4 files reviewed, 1 unresolved discussion (waiting on @igchor and @victoria-mcgrath)


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

 std::make_shared<MurmurHash2>()),
cacheCreationTime_{util::getCurrentTimeSec()},
nvmCacheState_{config_.cacheDir, config_.isNvmCacheEncryptionEnabled(),

Hm, maybe instead of adding a new isNvmCacheEnabled parameter to nvmCacheState_ we could just convert nvmCacheState_ into a pointer (or std::optional) and move this initialization to initNvmCache? I think it would be quite natural to keep everything related to nvm in that method.

@igchorigchor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed 4 of 4 files at r1.
Reviewable status: all files reviewed (commit messages unreviewed), 1 unresolved discussion (waiting on @victoria-mcgrath)

@victoria-mcgrath

Copy link
Copy Markdown
CollaboratorAuthor

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

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

Hm, maybe instead of adding a new isNvmCacheEnabled parameter to nvmCacheState_ we could just convert nvmCacheState_ into a pointer (or std::optional) and move this initialization to initNvmCache? I think it would be quite natural to keep everything related to nvm in that method.

I tried std::optional - please take a look.

@igchorigchor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewable status: 1 of 5 files reviewed, 1 unresolved discussion (waiting on @igchor and @victoria-mcgrath)


cachelib/allocator/CacheAllocator.h, line 972 at r2 (raw file):

time_tgetCacheCreationTime() constnoexcept { return cacheCreationTime_; }
time_tgetNVMCacheCreationTime() const {
return nvmCacheState_.value().getCreationTime();

I think you should handle the case where nvmCacheState_ is not specified - to have legacy behavior - you can just return cacheCreationTime.


cachelib/allocator/CacheAllocator-inl.h, line 3254 at r2 (raw file):

 ret.nvmCacheEnabled = nvmCache_ ? nvmCache_->isEnabled() : false;
if (nvmCacheState_.has_value()) {
ret.nvmUpTime = currTime - nvmCacheState_.value().getCreationTime();

I think you can just use getNVMCacheCreationTime one you fix it.

@igchorigchor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

Reviewable status: 1 of 5 files reviewed, 1 unresolved discussion (waiting on @igchor and @victoria-mcgrath)


cachelib/allocator/CacheAllocator.h, line 979 at r3 (raw file):

auto result = getCacheCreationTime();
if (nvmCacheState_.has_value()) {
result = nvmCacheState_.value().getCreationTime();

nit: you can use value_or instead of this if

@victoria-mcgrathvictoria-mcgrath changed the title WIP: Attempt to disable NvmCacheState when NVM cache is not enabled.Attempt to disable NvmCacheState when NVM cache is not enabled.Nov 29, 2021
@victoria-mcgrath
victoria-mcgrath marked this pull request as ready for review November 29, 2021 16:52

@igchorigchor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: 1 of 5 files reviewed, all discussions resolved (waiting on @igchor)

@victoria-mcgrathvictoria-mcgrath left a comment

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Reviewable status: 1 of 5 files reviewed, all discussions resolved (waiting on @igchor)


cachelib/allocator/CacheAllocator.h, line 972 at r2 (raw file):

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

I think you should handle the case where nvmCacheState_ is not specified - to have legacy behavior - you can just return cacheCreationTime.

Done.

@victoria-mcgrath
victoria-mcgrath merged commit 9291d51 into pmem:developNov 29, 2021
vinser52 pushed a commit to vinser52/CacheLib that referenced this pull request Sep 13, 2022
danielobiri pushed a commit to danielobiri/CacheLib that referenced this pull request Oct 20, 2022
Sign up for freeto 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.

2 participants

@victoria-mcgrath@igchor