Avoid intermediate buffers in sparse boolean compression
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rust
- Lĩnh vực
- performance
Hướng nghiên cứu
Start with vortex-btrblocks/src/schemes/boolean.rs and trace how BoolSparseScheme::encode calls Sparse::encode in encodings/sparse/src/lib.rs. The proposed change is to extract exception indices at their final unsigned width while preserving decoded values and nulls. The issue provides a standalone timing harness and command for measuring compression; confirm correctness and compare timings for both fixtures.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Default compression was about 25% faster in these runs. For 100,000 booleans with every 100th true, sliced to 5..99_997, base → patched median time was 41.1 → 31.2 µs (−25.6%); for 65,536 nullable booleans with every 100th validity bit false, it was 34.8 → 26.7 µs (−24.0%).
AI assistance: Perfloop.
Problem or motivation
In vortex-btrblocks/src/schemes/boolean.rs, BoolSparseScheme::encode calls Sparse::encode in encodings/sparse/src/lib.rs, then discards its exception values and narrows its indices. Output is correct; the intermediates add compression time.
Release-mode whole-call compression times include result destruction and exclude input setup.
These generated inputs do not establish end-to-end file-writing gains or a production workload mix.
Proposed solution
Extract exception indices directly at their final unsigned width, avoiding the full-length NotEq bitmap, mask index vector, filtered values, and u64 indices plus narrowing pass. Choose width from the last exception; return a constant for zero exceptions. Preserve decoded values and nulls.
Additional context
At unmodified upstream develop revision 895abdc29f9831d488b9865cf8dca7bad219b50c, save this standalone harness as vortex-btrblocks/tests/sparse_boolean_timing.rs (not an existing test). Run it there, then with the linked patch applied. It prints nanoseconds per call for both inputs using default CORE_2026_08_3 compression and fresh metadata per chunk.
cargo test --locked --profile bench -p vortex-btrblocks --test sparse_boolean_timing -- --nocapture --test-threads=1
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors
use std::hint::black_box;
use std::time::Instant;
use vortex_array::{IntoArray, VortexSessionExecute};
use vortex_array::arrays::BoolArray;
use vortex_array::validity::Validity;
use vortex_btrblocks::{BtrBlocksCompressorBuilder, CompressionSession};
use vortex_buffer::BitBuffer;
use vortex_edition::{EDITION_DECLARATIONS, EDITION_FAMILIES, EditionSession, EditionSessionExt};
use vortex_edition::declarations::core::CORE_2026_08_3;
use vortex_error::VortexResult;
use vortex_session::VortexSession;
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
#[test]
fn timing() -> VortexResult<()> {
let session = VortexSession::empty()
.with::<EditionSession>()
.with::<CompressionSession>();
vortex_alp::initialize(&session);
vortex_datetime_parts::initialize(&session);
vortex_decimal_byte_parts::initialize(&session);
vortex_fastlanes::initialize(&session);
vortex_fsst::initialize(&session);
vortex_onpair::initialize(&session);
vortex_sequence::initialize(&session);
vortex_sparse::initialize(&session);
vortex_zigzag::initialize(&session);
for family in EDITION_FAMILIES {
session.editions().declare_family(family)?;
}
for declaration in EDITION_DECLARATIONS {
session.register_edition(declaration)?;
}
session.enable_edition(CORE_2026_08_3)?;
let scattered = BitBuffer::from_iter((0..100_000).map(|i| i % 100 == 0))
.slice(5..99_997);
let values = BitBuffer::from_iter((0..65_536usize)
.map(|i| (i.wrapping_mul(0x9e3779b9).rotate_left(11) % 101) < 50));
let valid = BitBuffer::from_iter((0..65_536).map(|i| i % 100 != 0));
for (name, values, valid) in [
("scattered_fixture", scattered, None),
("validity_65536_true", values, Some(valid)),
] {
let fresh = || {
let validity = valid.as_ref().map_or(Validity::NonNullable, |v| {
Validity::Array(BoolArray::new(v.clone(), Validity::NonNullable).into_array())
});
BoolArray::new(values.clone(), validity).into_array()
};
let compressor = BtrBlocksCompressorBuilder::from_session(&session).build();
let mut ctx = session.create_execution_ctx();
black_box(compressor.compress(&fresh(), &mut ctx)?);
// Fresh metadata per chunk; input allocation is outside the timed compression.
let inputs: Vec<_> = (0..1000).map(|_| fresh()).collect();
let start = Instant::now();
for input in &inputs {
black_box(compressor.compress(black_box(input), &mut ctx)?);
}
let ns = start.elapsed().as_nanos() as f64 / 1000.0;
println!("{{\"metric\":\"{name}_ns\",\"value\":{ns}}}");
}
Ok(())
}
cc @lwwmanning @joseph-isaacs
Timing details
Scattered booleans: base 41,101.574 ns/call, patched 31,223.9 ns/call, paired decrease 10,530.575 ns/call (bounds 267.447 to 18,511.974 ns/call; −45.0% to −0.7%; n=32 complete pairs); nullable booleans: base 34,779.852 ns/call, patched 26,683.429 ns/call, paired decrease 8,331.742 ns/call (bounds 2,015.907 to 13,759.478 ns/call; −39.6% to −5.8%; n=49 complete pairs).
Made by Perfloop. Human sponsor: Tomás Senart.
- Ngôn ngữ chính
- Rust
- Star
- 3.2k
- Fork
- 239
- Merge trung bình
- 1 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 684
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của vortex-data/vortex
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
vortex-data/vortex#12633 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
vortex-data/vortex#12628 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
vortex-data/vortex#12491 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Fallible constructor for nested_case_whenCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
vortex-data/vortex#11425 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 67/100
vortex-data/vortex#12635 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của vortex-data/vortex
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
marklauter/tsong#110 ·
-
docs enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
wasm-bindgen/wasm-bindgen#5503 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
marketing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area: engine bug needs milestone
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Mudcrab-Team/mudcrab#1197 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày