Skip to content

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

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

Merged
merged 3 commits into from
Nov 29, 2021

Conversation

victoria-mcgrath
Copy link
Collaborator

@victoria-mcgrath victoria-mcgrath commented Nov 23, 2021

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

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.

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.

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 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
Collaborator Author


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.

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.

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_t getCacheCreationTime() const noexcept { return cacheCreationTime_; }
  time_t getNVMCacheCreationTime() 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.

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.

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-mcgrath victoria-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
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.

:lgtm:

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

Copy link
Collaborator Author

@victoria-mcgrath victoria-mcgrath 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: 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:develop Nov 29, 2021
vinser52 added 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 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.

2 participants