Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove the logs-cache feature #1103

Merged
merged 1 commit into from
Jul 5, 2024
Merged
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
1 change: 0 additions & 1 deletion command/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ x509-parser = "^0.16.0"
unstable = []
logs-debug = []
logs-trace = []
logs-cache = []

[badges]
travis-ci = { repository = "sozu-proxy/sozu" }
Expand Down
37 changes: 4 additions & 33 deletions command/src/logging/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ impl From<&Option<AccessLogFormat>> for ProtobufAccessLogFormat {
}

pub struct InnerLogger {
version: u8,
directives: Vec<LogDirective>,
backend: LoggerBackend,
pub colored: bool,
Expand Down Expand Up @@ -93,7 +92,6 @@ impl Default for Logger {
fn default() -> Self {
Self {
inner: InnerLogger {
version: 1, // all call site start with a version of 0
directives: vec![LogDirective {
name: None,
level: LogLevelFilter::Error,
Expand Down Expand Up @@ -157,10 +155,6 @@ impl Logger {
}

pub fn set_directives(&mut self, directives: Vec<LogDirective>) {
self.version += 1;
if self.version >= LOG_LINE_ENABLED {
self.version = 0;
}
self.directives = directives;
}

Expand Down Expand Up @@ -307,16 +301,6 @@ impl InnerLogger {
false
}

pub fn cached_enabled(&self, call_site_state: &mut LogLineCachedState, meta: Metadata) -> bool {
if call_site_state.version() == self.version {
call_site_state.enabled()
} else {
let enabled = self.enabled(meta);
call_site_state.set(self.version, enabled);
enabled
}
}

fn compat_enabled(&self, meta: &log::Metadata) -> bool {
// Search for the longest match, the vector is assumed to be pre-sorted.
for directive in self.directives.iter().rev() {
Expand Down Expand Up @@ -789,23 +773,10 @@ impl LogLineCachedState {
macro_rules! _log_enabled {
($logger:expr, $lvl:expr) => {{
let logger = $logger.borrow_mut();
let enable = if cfg!(feature = "logs-cache") {
static mut LOG_LINE_CACHED_STATE: $crate::logging::LogLineCachedState =
$crate::logging::LogLineCachedState::new();
logger.cached_enabled(
unsafe { &mut LOG_LINE_CACHED_STATE },
$crate::logging::Metadata {
level: $lvl,
target: module_path!(),
},
)
} else {
logger.enabled($crate::logging::Metadata {
level: $lvl,
target: module_path!(),
})
};
if !enable {
if !logger.enabled($crate::logging::Metadata {
level: $lvl,
target: module_path!(),
}) {
return;
}
logger
Expand Down
5 changes: 0 additions & 5 deletions command/src/logging/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
//!
//! Instead of relying on well-known logging or tracing solutions,
//! Sōzu has its own logging stack that prioritizes CPU performance
//!
//! The `logs-cache` flag, on of that, saves lookup time by storing
//! the ENABLED status of each log call-site, in a `static mut`.
//! The gain in performance is measurable with a lot of log directives,
//! but mostly negligible, since CPUs are clever enough to recognize such patterns.

pub mod access_logs;
pub mod display;
Expand Down
Loading