Skip to content

Commit 090d6ba

Browse files
committed
Fix typos
1 parent 3e67ffc commit 090d6ba

File tree

3 files changed

+31
-30
lines changed

3 files changed

+31
-30
lines changed

quickwit/quickwit-cli/src/logger.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ impl FormatFields<'_> for FieldFormat {
213213
}
214214

215215
/// Logger configurations specific to the jemalloc profiler.
216+
///
217+
/// A custom event formatter is used to print the backtrace of the
218+
/// profiling events.
216219
#[cfg(feature = "jemalloc-profiled")]
217220
pub(super) mod jemalloc_profiled {
218221
use std::fmt;
@@ -232,8 +235,8 @@ pub(super) mod jemalloc_profiled {
232235

233236
/// An event formatter specific to the memory profiler output.
234237
///
235-
/// Besides printing the spans and the fields of the tracing event, it also
236-
/// displays a backtrace.
238+
/// Also displays a backtrace after spans and the fields of the tracing
239+
/// event (into separate lines).
237240
struct ProfilingFormat {
238241
time_formatter: UtcTime<Vec<BorrowedFormatItem<'static>>>,
239242
}
@@ -298,10 +301,7 @@ pub(super) mod jemalloc_profiled {
298301
}
299302

300303
fn profiler_tracing_filter(metadata: &Metadata) -> bool {
301-
metadata.is_span()
302-
|| (metadata.is_event()
303-
&& metadata.level() == &Level::TRACE
304-
&& metadata.target() == JEMALLOC_PROFILER_TARGET)
304+
metadata.is_span() || (metadata.is_event() && metadata.target() == JEMALLOC_PROFILER_TARGET)
305305
}
306306

307307
/// Configures the regular logging layer and a specific layer that gathers

quickwit/quickwit-common/src/alloc_tracker.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ impl Allocations {
9090
}
9191
}
9292

93-
/// Records an allocation and occasionally reports the cumulated allocation size
94-
/// for the provided callsite_hash.
93+
/// Records an allocation and occasionally reports the cumulated allocation
94+
/// size for the provided callsite_hash.
9595
///
96-
/// Every time a the total allocated size with the same callsite_hash
97-
/// exceeds the previous reported value by at least reporting_interval, that
96+
/// Every time the total allocated size for a given callsite_hash exceeds
97+
/// the previous reported value by at least reporting_interval, the new total
9898
/// allocated size is reported.
9999
///
100100
/// WARN: this function should not allocate!
@@ -111,7 +111,7 @@ impl Allocations {
111111
return AllocRecordingResponse::TrackerFull("memory_locations");
112112
}
113113
if self.max_tracked_callsites == self.callsite_statistics.len() {
114-
return AllocRecordingResponse::TrackerFull("memory_locations");
114+
return AllocRecordingResponse::TrackerFull("tracked_callsites");
115115
}
116116
self.memory_locations.insert(
117117
ptr as usize,
@@ -144,6 +144,8 @@ impl Allocations {
144144

145145
/// Updates the the memory location and size of an existing allocation. Only
146146
/// update the statistics if the original allocation was recorded.
147+
///
148+
/// WARN: this function should not allocate!
147149
pub fn record_reallocation(
148150
&mut self,
149151
new_size_bytes: u64,

quickwit/quickwit-common/src/jemalloc_profiled.rs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ use crate::alloc_tracker::{
2929
const DEFAULT_MIN_ALLOC_BYTES_FOR_PROFILING: u64 = 64 * 1024;
3030
const DEFAULT_REPORTING_INTERVAL_BYTES: u64 = 1024 * 1024 * 1024;
3131

32+
/// This custom target name is used to filter profiling events in the tracing
33+
/// subscriber. It is also included in the printed log.
3234
pub const JEMALLOC_PROFILER_TARGET: &str = "jemprof";
3335

3436
/// Atomics are used to communicate configurations between the start/stop
35-
/// endpoints and the JemallocProfiled allocator wrapper.
37+
/// endpoints and the [JemallocProfiled] allocator wrapper.
3638
///
3739
/// The flags are padded to avoid false sharing of the CPU cache line between
3840
/// threads. 128 bytes is the cache line size on x86_64 and arm64.
@@ -130,11 +132,13 @@ pub fn stop_profiling() {
130132

131133
/// Wraps the Jemalloc global allocator calls with tracking routines.
132134
///
133-
/// The tracking routines are called only when [ENABLED] is set to true (calling
134-
/// [start_profiling()]), but we don't enforce any synchronization (we load it with
135-
/// Ordering::Relaxed) because it's fine to miss or record extra allocation events.
135+
/// The tracking routines are called only when FLAGS.enabled is set to true
136+
/// (calling [start_profiling()]). We load it with [Ordering::Relaxed] because
137+
/// it's fine to miss or record extra allocation events and prefer limiting the
138+
/// performance impact when profiling is not enabled.
136139
///
137-
/// It's important to ensure that no allocations are performed inside the allocator!
140+
/// Note: It's important to ensure that no allocations are performed inside the
141+
/// allocator! It can cause an abort, a panic or even a deadlock.
138142
pub struct JemallocProfiled(pub Jemalloc);
139143

140144
unsafe impl GlobalAlloc for JemallocProfiled {
@@ -176,13 +180,13 @@ unsafe impl GlobalAlloc for JemallocProfiled {
176180

177181
/// Prints both a backtrace and a Tokio tracing log
178182
///
179-
/// Warning: stdout might allocate a buffer on first use
183+
/// Warning: stdout writer might allocate a buffer on first use
180184
fn identify_callsite(callsite_hash: u64, stat: AllocStat) {
181185
// To generate a complete trace:
182186
// - tokio/tracing feature must be enabled, otherwise un-instrumented tasks will not propagate
183187
// parent spans
184-
// - the tracing fmt subscriber filter must keep all spans for this event (TRACE level)
185-
// See the logger configuration for more details.
188+
// - the tracing fmt subscriber filter must keep all spans for this event (TRACE level). See the
189+
// logger configuration for more details.
186190
trace!(target: JEMALLOC_PROFILER_TARGET, callsite=callsite_hash, allocs=stat.count, size=%stat.size);
187191
}
188192

@@ -195,7 +199,7 @@ fn backtrace_hash() -> u64 {
195199
hasher.finish()
196200
}
197201

198-
/// Warning: allocating inside this function can cause an error (abort, panic or even deadlock).
202+
/// Warning: this function should not allocate!
199203
#[cold]
200204
fn track_alloc_call(ptr: *mut u8, layout: Layout) {
201205
if layout.size() >= FLAGS.min_alloc_bytes_for_profiling.load(Ordering::Relaxed) as usize {
@@ -212,7 +216,7 @@ fn track_alloc_call(ptr: *mut u8, layout: Layout) {
212216
}
213217
AllocRecordingResponse::TrackerFull(table_name) => {
214218
// this message might be displayed multiple times but that's fine
215-
// warning: stdout might allocate a buffer on first use
219+
// warning: stdout writer might allocate a buffer on first use
216220
error!("heap profiling stopped, {table_name} full");
217221
FLAGS.enabled.store(false, Ordering::Relaxed);
218222
}
@@ -222,28 +226,23 @@ fn track_alloc_call(ptr: *mut u8, layout: Layout) {
222226
}
223227
}
224228

225-
/// Warning: allocating inside this function can cause an error (abort, panic or even deadlock).
229+
/// Warning: this function should not allocate!
226230
#[cold]
227231
fn track_dealloc_call(ptr: *mut u8, layout: Layout) {
228232
if layout.size() >= FLAGS.min_alloc_bytes_for_profiling.load(Ordering::Relaxed) as usize {
229233
ALLOCATION_TRACKER.lock().unwrap().record_deallocation(ptr);
230234
}
231235
}
232236

233-
/// Warning: allocating inside this function can cause an error (abort, panic or even deadlock).
237+
/// Warning: this function should not allocate!
234238
#[cold]
235-
fn track_realloc_call(
236-
old_ptr: *mut u8,
237-
new_pointer: *mut u8,
238-
current_layout: Layout,
239-
new_size: usize,
240-
) {
239+
fn track_realloc_call(old_ptr: *mut u8, new_ptr: *mut u8, current_layout: Layout, new_size: usize) {
241240
if current_layout.size() >= FLAGS.min_alloc_bytes_for_profiling.load(Ordering::Relaxed) as usize
242241
{
243242
let recording_response = ALLOCATION_TRACKER.lock().unwrap().record_reallocation(
244243
new_size as u64,
245244
old_ptr,
246-
new_pointer,
245+
new_ptr,
247246
);
248247

249248
match recording_response {

0 commit comments

Comments
 (0)