Files
qdrant/lib/segment/benches/segment_info.rs
Ivan Boldyrev 56799122b0 Split SegmentEntry into appendable and non-appendable part (#8047)
* Split `SegmentEntry`

Add `ImmutableSegmentEntry` for operations that can be applied to
immutable segments, and make the `SegmentEntry` as it subtrait.

* Rename to `NonAppendableSegmentEntry`

It differs semantically from `ImmutableSegmentEntry` by allowing point
deletion.  Move point deletion to the trait too.

* Fix docstring

* use NonAppendableSegmentEntry where possible

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2026-02-05 15:46:58 +01:00

61 lines
1.9 KiB
Rust

use common::counter::hardware_counter::HardwareCounterCell;
use criterion::{Criterion, criterion_group, criterion_main};
use segment::data_types::vectors::only_default_vector;
use segment::entry::entry_point::{NonAppendableSegmentEntry, SegmentEntry};
use segment::json_path::JsonPath;
use segment::segment_constructor::simple_segment_constructor::build_simple_segment;
use segment::types::{Distance, Payload, PayloadFieldSchema, PayloadSchemaType};
use serde_json::{Map, Value};
use tempfile::Builder;
pub fn criterion_benchmark(c: &mut Criterion) {
let dir = Builder::new().prefix("segment_dir").tempdir().unwrap();
let dim = 400;
let mut segment = build_simple_segment(dir.path(), dim, Distance::Dot).unwrap();
let vector = vec![0.1f32; 400];
let mut payload: Map<String, Value> = Map::default();
for i in 0..3 {
let key = format!("key{i}");
payload.insert(key.clone(), "value".to_string().into());
segment
.create_field_index(
100,
&JsonPath::new(&key),
Some(&PayloadFieldSchema::FieldType(PayloadSchemaType::Keyword)),
&HardwareCounterCell::new(),
)
.unwrap();
}
let payload = Payload::from(payload);
let hw_counter = HardwareCounterCell::new();
for id in 0..100000u64 {
segment
.upsert_point(100, id.into(), only_default_vector(&vector), &hw_counter)
.unwrap();
segment
.set_payload(100, id.into(), &payload, &None, &hw_counter)
.unwrap();
}
c.bench_function("segment-info", |b| {
b.iter(|| {
let _ = segment.info();
})
});
c.bench_function("segment-size-info", |b| {
b.iter(|| {
let _ = segment.size_info();
})
});
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);