Skip to content

Commit

Permalink
feat: support set manifest path in foyer-bench
Browse files Browse the repository at this point in the history
Signed-off-by: MrCroxx <[email protected]>
  • Loading branch information
MrCroxx committed Oct 27, 2024
1 parent 0917930 commit d7b2979
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
10 changes: 10 additions & 0 deletions foyer-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ struct Args {
#[arg(short, long)]
dir: Option<String>,

/// Setup path for the manifest file.
///
/// The manifest file is required with `DirectFile` device.
#[arg(short, long)]
manifest: Option<String>,

/// In-memory cache capacity.
#[arg(long, default_value_t = ByteSize::gib(1))]
mem: ByteSize,
Expand Down Expand Up @@ -484,6 +490,10 @@ async fn benchmark(args: Args) {
_ => unreachable!(),
};

if let Some(path) = &args.manifest {
builder = builder.with_manifest_file_path(path);
}

builder = builder
.with_flush(args.flush)
.with_recover_mode(args.recover_mode)
Expand Down
8 changes: 2 additions & 6 deletions foyer-storage/src/large/recover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,8 @@ impl RecoverRunner {
}
region_manager.reclaim_semaphore().add_permits(permits);
region_manager.reclaim_semaphore_countdown().reset(countdown);

if watermark == Sequence::MAX {
// Only manifest error may cause MAX sequence watermark.
// Set it to a normal value after recovery.
config.manifest.update_sequence_watermark(seq).await?;
}
// Update the manifest sequence watermark with the smallest possible value.
config.manifest.update_sequence_watermark(seq).await?;

// Note: About reclaim semaphore permits and countdown:
//
Expand Down
19 changes: 18 additions & 1 deletion foyer/src/hybrid/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::{fmt::Debug, sync::Arc};
use std::{fmt::Debug, path::Path, sync::Arc};

use ahash::RandomState;
use foyer_common::{
Expand Down Expand Up @@ -215,6 +215,23 @@ where
}
}

/// Set the path for the manifest file.
///
/// The manifest file is used to tracking the watermark for fast disk cache clearing.
///
/// When creating a disk cache on a fs, it is not required to set the manifest file path.
///
/// When creating a disk cache on a raw device, it is required to set the manifest file path.
pub fn with_manifest_file_path(self, path: impl AsRef<Path>) -> Self {
let builder = self.builder.with_manifest_file_path(path);
Self {
name: self.name,
tracing_options: self.tracing_options,
memory: self.memory,
builder,
}
}

/// Enable/disable `sync` after writes.
///
/// Default: `false`.
Expand Down

0 comments on commit d7b2979

Please sign in to comment.