perf: use sharded namespace cache
Enables the ShardedCache for the namespace schema cache.
//! Implementation of command line option for running router2
-use std::{collections::BTreeSet, sync::Arc};
+use std::{collections::BTreeSet, iter, sync::Arc};
use crate::{
clap_blocks::{
@@ -17,7 +17,7 @@ use crate::{
use observability_deps::tracing::*;
use router2::{
dml_handlers::{NamespaceAutocreation, SchemaValidator, ShardedWriteBuffer},
- namespace_cache::MemoryNamespaceCache,
+ namespace_cache::{MemoryNamespaceCache, ShardedCache},
sequencer::Sequencer,
server::{http::HttpDelegate, RouterServer},
sharder::JumpHash,
@@ -90,7 +90,9 @@ pub async fn command(config: Config) -> Result<()> {
)
.await?;
- let ns_cache = Arc::new(MemoryNamespaceCache::default());
+ let ns_cache = Arc::new(ShardedCache::new(
+ iter::repeat_with(|| Arc::new(MemoryNamespaceCache::default())).take(10),
+ ));
let handler_stack =
SchemaValidator::new(write_buffer, Arc::clone(&catalog), Arc::clone(&ns_cache));
