Skip to content

Commit

Permalink
refactor: change DEFAULT_PAGE_SIZE to 1536
Browse files Browse the repository at this point in the history
  • Loading branch information
WenyXu committed Nov 3, 2023
1 parent 74f9bb0 commit 43f07c5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/common/meta/src/range_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,16 @@ enum PaginationStreamState<K, V> {
Error,
}

pub const DEFAULT_PAGE_SIZE: usize = 512;
/// The Range Request's default page size.
///
/// It dependents on upstream KvStore server side grpc message size limitation.
/// (e.g., etcd has default grpc message size limitation is 4MiB)
///
/// Generally, almost all metadata is smaller than is 2700 Byte.
/// Therefore, We can set the [DEFAULT_PAGE_SIZE] to 1536 statically.
///
/// TODO(weny): Considers updating the default page size dynamically.
pub const DEFAULT_PAGE_SIZE: usize = 1536;

struct PaginationStreamFactory {
kv: KvBackendRef,
Expand Down
4 changes: 3 additions & 1 deletion src/meta-srv/src/handler/on_leader_start_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ impl HeartbeatHandler for OnLeaderStartHandler {
if let Some(election) = &ctx.election {
if election.in_infancy() {
ctx.is_infancy = true;
// TODO(weny): Unifies the multiple leader state between Context and MetaSrv.
// we can't ensure the in-memory kv has already been reset in the outside loop.
// We still use heartbeat requests to trigger resetting in-memory kv.
ctx.reset_in_memory();
ctx.reset_leader_cached_kv_backend();
}
}
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/meta-srv/src/service/store/cached_kv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl LeaderCachedKvBackend {
for prefix in &CACHE_KEY_PREFIXES[..] {
let _timer = metrics::METRIC_META_LEADER_CACHED_KV_LOAD.with_label_values(&[prefix]);

// TODO(weny): Refactors PaginationStream's ouput to unary output.
// TODO(weny): Refactors PaginationStream's output to unary output.
let stream = PaginationStream::new(
self.store.clone(),
RangeRequest::new().with_prefix(prefix.as_bytes()),
Expand Down

0 comments on commit 43f07c5

Please sign in to comment.