Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion quickwit/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ When the client is unlikely to match on an error, you can rely on the crate leve
### Design Patterns
- **Trait-based services**: `SearchService`, `MetastoreService`, etc. — enables mocking and multiple implementations
- **Feature gates**: Cloud backends (`azure`, `gcs`), message sources (`kafka`, `kinesis`, `pulsar`, `sqs`, `gcp-pubsub`), `postgres` metastore, `multilang` tokenizers
- **Metrics**: `once_cell::sync::Lazy` statics with `quickwit_common::metrics::*` factories
- **Metrics**: `std::sync::LazyLock` statics with `quickwit_common::metrics::*` factories

### Key Dependencies
- **Tantivy**: Search engine library (custom fork)
Expand Down
19 changes: 0 additions & 19 deletions quickwit/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion quickwit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ mrecordlog = { git = "https://github.com/quickwit-oss/mrecordlog", rev = "306c0a
new_string_template = "1.5"
nom = "8.0"
numfmt = "1.2"
once_cell = "1"
oneshot = "0.1"
openssl = { version = "0.10", default-features = false }
openssl-probe = "0.1"
Expand Down
1 change: 0 additions & 1 deletion quickwit/quickwit-actors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ anyhow = { workspace = true }
async-trait = { workspace = true }
flume = { workspace = true }
futures = { workspace = true }
once_cell = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
sync_wrapper = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions quickwit/quickwit-actors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

use std::fmt;
use std::num::NonZeroU64;
use std::sync::LazyLock;

use once_cell::sync::Lazy;
use tokio::time::Duration;
mod actor;
mod actor_context;
Expand Down Expand Up @@ -70,7 +70,7 @@ pub use self::supervisor::{Supervisor, SupervisorMetrics, SupervisorState};
/// If an actor does not advertise a progress within an interval of duration `HEARTBEAT`,
/// its supervisor will consider it as blocked and will proceed to kill it, as well
/// as all of the actors all the actors that share the killswitch.
pub static HEARTBEAT: Lazy<Duration> = Lazy::new(heartbeat_from_env_or_default);
pub static HEARTBEAT: LazyLock<Duration> = LazyLock::new(heartbeat_from_env_or_default);

/// Returns the actor's heartbeat duration:
/// - Derived from `QW_ACTOR_HEARTBEAT_SECS` if set and valid.
Expand Down
7 changes: 3 additions & 4 deletions quickwit/quickwit-actors/src/mailbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::any::Any;
use std::convert::Infallible;
use std::fmt;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, OnceLock, Weak};
use std::sync::{Arc, LazyLock, Weak};
use std::time::Instant;

use quickwit_common::metrics::{GaugeGuard, IntCounter, IntGauge};
Expand Down Expand Up @@ -386,16 +386,15 @@ impl<A: Actor> Inbox<A> {
}

fn get_actor_inboxes_count_gauge_guard() -> GaugeGuard<'static> {
static INBOX_GAUGE: std::sync::OnceLock<IntGauge> = OnceLock::new();
let gauge = INBOX_GAUGE.get_or_init(|| {
static INBOX_GAUGE: LazyLock<IntGauge> = LazyLock::new(|| {
quickwit_common::metrics::new_gauge(
"inboxes_count",
"overall count of actors",
"actor",
&[],
)
});
let mut gauge_guard = GaugeGuard::from_gauge(gauge);
let mut gauge_guard = GaugeGuard::from_gauge(&INBOX_GAUGE);
gauge_guard.add(1);
gauge_guard
}
Expand Down
1 change: 0 additions & 1 deletion quickwit/quickwit-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ humantime = { workspace = true }
indicatif = { workspace = true }
itertools = { workspace = true }
numfmt = { workspace = true }
once_cell = { workspace = true }
openssl-probe = { workspace = true, optional = true }
opentelemetry = { workspace = true }
opentelemetry-appender-tracing = { workspace = true }
Expand Down
18 changes: 9 additions & 9 deletions quickwit/quickwit-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use std::collections::HashSet;
use std::str::FromStr;
use std::sync::OnceLock;
use std::sync::LazyLock;

use anyhow::Context;
use clap::{Arg, ArgMatches, arg};
Expand Down Expand Up @@ -109,13 +109,13 @@ fn client_args() -> Vec<Arg> {
}

pub fn install_default_crypto_ring_provider() {
static CALL_ONLY_ONCE: OnceLock<Result<(), ()>> = OnceLock::new();
static CALL_ONLY_ONCE: LazyLock<Result<(), ()>> = LazyLock::new(|| {
rustls::crypto::ring::default_provider()
.install_default()
.map_err(|_| ())
});
CALL_ONLY_ONCE
.get_or_init(|| {
rustls::crypto::ring::default_provider()
.install_default()
.map_err(|_| ())
})
.as_ref()
.expect("rustls crypto ring default provider installation should not fail");
}

Expand Down Expand Up @@ -348,16 +348,16 @@ fn prompt_confirmation(prompt: &str, default: bool) -> bool {
}

pub mod busy_detector {
use std::sync::LazyLock;
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
use std::time::Instant;

use once_cell::sync::Lazy;
use tracing::debug;

use crate::metrics::CLI_METRICS;

// we need that time reference to use an atomic and not a mutex for LAST_UNPARK
static TIME_REF: Lazy<Instant> = Lazy::new(Instant::now);
static TIME_REF: LazyLock<Instant> = LazyLock::new(Instant::now);
static ENABLED: AtomicBool = AtomicBool::new(false);

const ALLOWED_DELAY_MICROS: u64 = 5000;
Expand Down
5 changes: 3 additions & 2 deletions quickwit/quickwit-cli/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use once_cell::sync::Lazy;
use std::sync::LazyLock;

use quickwit_common::metrics::{HistogramVec, new_histogram_vec};

pub struct CliMetrics {
Expand All @@ -35,4 +36,4 @@ impl Default for CliMetrics {
}

/// Serve counters exposes a bunch a set of metrics about the request received to quickwit.
pub static CLI_METRICS: Lazy<CliMetrics> = Lazy::new(CliMetrics::default);
pub static CLI_METRICS: LazyLock<CliMetrics> = LazyLock::new(CliMetrics::default);
1 change: 0 additions & 1 deletion quickwit/quickwit-cluster/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ bytesize = { workspace = true }
chitchat = { workspace = true }
futures = { workspace = true }
itertools = { workspace = true }
once_cell = { workspace = true }
pin-project = { workspace = true }
rand = { workspace = true }
serde = { workspace = true }
Expand Down
10 changes: 5 additions & 5 deletions quickwit/quickwit-cluster/src/grpc_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
// limitations under the License.

use std::net::SocketAddr;
use std::sync::LazyLock;

use bytesize::ByteSize;
use itertools::Itertools;
use once_cell::sync::Lazy;
use quickwit_common::tower::{ClientGrpcConfig, GrpcMetricsLayer, make_channel};
use quickwit_proto::cluster::cluster_service_grpc_server::ClusterServiceGrpcServer;
use quickwit_proto::cluster::{
Expand All @@ -30,10 +30,10 @@ use crate::Cluster;

const MAX_MESSAGE_SIZE: ByteSize = ByteSize::mib(64);

static CLUSTER_GRPC_CLIENT_METRICS_LAYER: Lazy<GrpcMetricsLayer> =
Lazy::new(|| GrpcMetricsLayer::new("cluster", "client"));
static CLUSTER_GRPC_SERVER_METRICS_LAYER: Lazy<GrpcMetricsLayer> =
Lazy::new(|| GrpcMetricsLayer::new("cluster", "server"));
static CLUSTER_GRPC_CLIENT_METRICS_LAYER: LazyLock<GrpcMetricsLayer> =
LazyLock::new(|| GrpcMetricsLayer::new("cluster", "client"));
static CLUSTER_GRPC_SERVER_METRICS_LAYER: LazyLock<GrpcMetricsLayer> =
LazyLock::new(|| GrpcMetricsLayer::new("cluster", "server"));

pub(crate) async fn cluster_grpc_client(
socket_addr: SocketAddr,
Expand Down
5 changes: 2 additions & 3 deletions quickwit/quickwit-cluster/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@

use std::collections::HashSet;
use std::net::SocketAddr;
use std::sync::Weak;
use std::sync::{LazyLock, Weak};
use std::time::Duration;

use chitchat::{Chitchat, ChitchatId};
use once_cell::sync::Lazy;
use quickwit_common::metrics::{IntCounter, IntGauge, new_counter, new_gauge};
use tokio::sync::Mutex;

Expand Down Expand Up @@ -118,7 +117,7 @@ impl Default for ClusterMetrics {
}
}

pub static CLUSTER_METRICS: Lazy<ClusterMetrics> = Lazy::new(ClusterMetrics::default);
pub static CLUSTER_METRICS: LazyLock<ClusterMetrics> = LazyLock::new(ClusterMetrics::default);

pub(crate) fn spawn_metrics_task(
weak_chitchat: Weak<Mutex<Chitchat>>,
Expand Down
1 change: 0 additions & 1 deletion quickwit/quickwit-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ http = { workspace = true }
hyper = { workspace = true }
hyper-util = { workspace = true, optional = true }
itertools = { workspace = true }
once_cell = { workspace = true }
pin-project = { workspace = true }
pnet = { workspace = true }
prometheus = { workspace = true }
Expand Down
6 changes: 3 additions & 3 deletions quickwit/quickwit-common/src/cpus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

use std::num::NonZero;
use std::sync::OnceLock;
use std::sync::LazyLock;

use tracing::{error, info, warn};

Expand All @@ -27,8 +27,8 @@ const KUBERNETES_LIMITS_CPU: &str = "KUBERNETES_LIMITS_CPU";
/// - from the operating system
/// - default to 2.
pub fn num_cpus() -> usize {
static NUM_CPUS: OnceLock<usize> = OnceLock::new();
*NUM_CPUS.get_or_init(num_cpus_aux)
static NUM_CPUS: LazyLock<usize> = LazyLock::new(num_cpus_aux);
*NUM_CPUS
}

fn num_cpus_aux() -> usize {
Expand Down
Loading
Loading