also rip out memoization code and make rest compile

This commit is contained in:
Christian Schwarz
2023-08-29 15:28:14 +00:00
parent 4db24c9de0
commit fa1fb214b3
8 changed files with 19 additions and 56 deletions

View File

@@ -8,10 +8,9 @@ use std::collections::BinaryHeap;
use std::ops::Range;
use std::{fs, path::Path, str};
use crate::tenant::disk_btree::PAGE_SZ;
use pageserver::repository::{Key, KEY_SIZE};
use pageserver::tenant::block_io::FileBlockReader;
use pageserver::tenant::disk_btree::{DiskBtreeReader, VisitDirection};
use pageserver::tenant::disk_btree::{DiskBtreeReader, VisitDirection, PAGE_SZ};
use pageserver::tenant::storage_layer::delta_layer::{Summary, DELTA_KEY_SIZE};
use pageserver::tenant::storage_layer::range_overlaps;
use pageserver::virtual_file::VirtualFile;
@@ -135,9 +134,6 @@ pub(crate) async fn main(cmd: &AnalyzeLayerMapCmd) -> Result<()> {
let storage_path = &cmd.path;
let max_holes = cmd.max_holes.unwrap_or(DEFAULT_MAX_HOLES);
// Initialize virtual_file (file desriptor cache) and page cache which are needed to access layer persistent B-Tree.
pageserver::page_cache::init(100);
let mut total_delta_layers = 0usize;
let mut total_image_layers = 0usize;
let mut total_excess_layers = 0usize;

View File

@@ -2,7 +2,6 @@ use std::path::{Path, PathBuf};
use anyhow::Result;
use clap::Subcommand;
use pageserver::page_cache;
use pageserver::tenant::block_io::BlockCursor;
use pageserver::tenant::disk_btree::DiskBtreeReader;
use pageserver::tenant::storage_layer::delta_layer::{BlobRef, Summary};
@@ -45,7 +44,6 @@ pub(crate) enum LayerCmd {
async fn read_delta_file(path: impl AsRef<Path>) -> Result<()> {
let path = path.as_ref();
page_cache::init(100);
let file = FileBlockReader::new(VirtualFile::open(path)?);
let summary_blk = file.read_blk(0).await?;
let actual_summary = Summary::des_prefix(summary_blk.as_ref())?;

View File

@@ -12,8 +12,7 @@ use clap::{Parser, Subcommand};
use layers::LayerCmd;
use pageserver::{
context::{DownloadBehavior, RequestContext},
page_cache,
task_mgr::TaskKind,
task_mgr::TaskKind,
tenant::{dump_layerfile_from_path, metadata::TimelineMetadata},
};
use postgres_ffi::ControlFileData;
@@ -114,8 +113,6 @@ fn read_pg_control_file(control_file_path: &Path) -> anyhow::Result<()> {
}
async fn print_layerfile(path: &Path) -> anyhow::Result<()> {
// Basic initialization of things that don't change after startup
page_cache::init(100);
let ctx = RequestContext::new(TaskKind::DebugTool, DownloadBehavior::Error);
dump_layerfile_from_path(path, true, &ctx).await
}

View File

@@ -20,7 +20,7 @@ use metrics::set_build_info_metric;
use pageserver::{
config::{defaults::*, PageServerConf},
context::{DownloadBehavior, RequestContext},
http, page_cache, page_service, task_mgr,
http, page_service, task_mgr,
task_mgr::TaskKind,
task_mgr::{BACKGROUND_RUNTIME, COMPUTE_REQUEST_RUNTIME, MGMT_REQUEST_RUNTIME},
tenant::mgr,
@@ -123,9 +123,6 @@ fn main() -> anyhow::Result<()> {
// Initialize up failpoints support
let scenario = pageserver::failpoint_support::init();
// Basic initialization of things that don't change after startup
page_cache::init(conf.page_cache_size);
start_pageserver(launch_ts, conf).context("Failed to start pageserver")?;
scenario.teardown();

View File

@@ -1,13 +1,22 @@
use std::cell::RefCell;
use crate::tenant::disk_btree::PAGE_SZ;
pub(crate) type Buffer = Box<[u8; PAGE_SZ]>;
// Thread-local list of re-usable buffers.
thread_local! {
static POOL: RefCell<Vec<Buffer>> = RefCell::new(Vec::new());
}
pub(crate) fn get() -> Buffer {
todo!()
let maybe = POOL.with(|rc| rc.borrow_mut().pop());
match maybe {
Some(buf) => buf,
Nonne => Box::new([0; PAGE_SZ]),
}
}
pub(crate) fn put(buf: Buffer) {
todo!()
POOL.with(|rc| rc.borrow_mut().push(buf))
}

View File

@@ -145,20 +145,14 @@ impl<'a> BlockCursor<'a> {
/// for modifying the file, nor for invalidating the cache if it is modified.
pub struct FileBlockReader<F> {
pub file: F,
/// Unique ID of this file, used as key in the page cache.
file_id: page_cache::FileId,
}
impl<F> FileBlockReader<F> {
pub fn new(file: F) -> Self {
let file_id = page_cache::next_file_id();
FileBlockReader { file_id, file }
FileBlockReader { file }
}
}
macro_rules! impls {
(FileBlockReader<$ty:ty>) => {
impl FileBlockReader<$ty> {
@@ -182,7 +176,7 @@ macro_rules! impls {
let buf = crate::buffer_pool::get();
// Read the page from disk into the buffer
let mut write_guard = self.fill_buffer(buf, blknum).await?;
todo!()
Ok(BlockLease::PageReadGuard(write_guard))
}
}
};

View File

@@ -15,8 +15,6 @@ use tracing::*;
use utils::id::{TenantId, TimelineId};
pub struct EphemeralFile {
page_cache_file_id: page_cache::FileId,
_tenant_id: TenantId,
_timeline_id: TimelineId,
file: VirtualFile,
@@ -47,7 +45,6 @@ impl EphemeralFile {
)?;
Ok(EphemeralFile {
page_cache_file_id: page_cache::next_file_id(),
_tenant_id: tenant_id,
_timeline_id: timeline_id,
file,

View File

@@ -2445,15 +2445,7 @@ impl Timeline {
}
async fn lookup_cached_page(&self, key: &Key, lsn: Lsn) -> Option<(Lsn, Bytes)> {
let cache = page_cache::get();
// FIXME: It's pointless to check the cache for things that are not 8kB pages.
// We should look at the key to determine if it's a cacheable object
let (lsn, read_guard) = cache
.lookup_materialized_page(self.tenant_id, self.timeline_id, key, lsn)
.await?;
let img = Bytes::from(read_guard.to_vec());
Some((lsn, img))
None
}
fn get_ancestor_timeline(&self) -> anyhow::Result<Arc<Timeline>> {
@@ -4192,23 +4184,6 @@ impl Timeline {
Err(e) => return Err(PageReconstructError::from(e)),
};
if img.len() == PAGE_SZ {
let cache = page_cache::get();
if let Err(e) = cache
.memorize_materialized_page(
self.tenant_id,
self.timeline_id,
key,
last_rec_lsn,
&img,
)
.await
.context("Materialized page memoization failed")
{
return Err(PageReconstructError::from(e));
}
}
Ok(img)
}
}