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

Fix bug in size estimation of array buffers #2991

Merged
merged 15 commits into from
Aug 16, 2023
Merged
53 changes: 32 additions & 21 deletions crates/re_log_types/src/data_table.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use std::collections::BTreeMap;

use re_types::ComponentName;

use ahash::HashMap;
use itertools::Itertools as _;
use itertools::{izip, Itertools as _};
use nohash_hasher::IntSet;
use re_types::ComponentName;
use smallvec::SmallVec;

use crate::{
Expand Down Expand Up @@ -1138,11 +1139,11 @@ impl DataTable {
cells: ref cells2,
} = row2;

for (c1, c2) in cells1.0.iter().zip(&cells2.0) {
for (c1, c2) in izip!(&cells1.0, &cells2.0) {
if c1 != c2 {
anyhow::ensure!(
c1.datatype() == c2.datatype(),
"Found discrepancy in row #{ri}, cells' datatypes don't match!\n{}",
"Found discrepancy in row #{ri}: cells' datatypes don't match!\n{}",
similar_asserts::SimpleDiff::from_str(
&format!("{:?}", c1.datatype()),
&format!("{:?}", c2.datatype()),
Expand All @@ -1160,7 +1161,7 @@ impl DataTable {
) {
anyhow::ensure!(
arr1.validity() == arr2.validity(),
"Found discrepancy in row #{ri}, union arrays' validity bitmaps don't match!\n{}\n{}",
"Found discrepancy in row #{ri}: union arrays' validity bitmaps don't match!\n{}\n{}",
similar_asserts::SimpleDiff::from_str(&row1.to_string(), &row2.to_string(), "row1", "row2"),
similar_asserts::SimpleDiff::from_str(
&format!("{:?}", arr1.validity()),
Expand All @@ -1171,7 +1172,7 @@ impl DataTable {
);
anyhow::ensure!(
arr1.types() == arr2.types(),
"Found discrepancy in row #{ri}, union arrays' type indices don't match!\n{}\n{}",
"Found discrepancy in row #{ri}: union arrays' type indices don't match!\n{}\n{}",
similar_asserts::SimpleDiff::from_str(&row1.to_string(), &row2.to_string(), "row1", "row2"),
similar_asserts::SimpleDiff::from_str(
&format!("{:?}", arr1.types()),
Expand All @@ -1182,7 +1183,7 @@ impl DataTable {
);
anyhow::ensure!(
arr1.offsets() == arr2.offsets(),
"Found discrepancy in row #{ri}, union arrays' offsets don't match!\n{}\n{}",
"Found discrepancy in row #{ri}: union arrays' offsets don't match!\n{}\n{}",
similar_asserts::SimpleDiff::from_str(&row1.to_string(), &row2.to_string(), "row1", "row2"),
similar_asserts::SimpleDiff::from_str(
&format!("{:?}", arr1.offsets()),
Expand All @@ -1196,10 +1197,10 @@ impl DataTable {
}

let mut size_mismatches = vec![];
for (c1, c2) in cells1.0.iter().zip(&cells2.0) {
for (c1, c2) in izip!(&cells1.0, &cells2.0) {
if c1.total_size_bytes() != c2.total_size_bytes() {
size_mismatches.push(format!(
"Found discrepancy in row #{ri}, cells' sizes don't match! {} ({}) vs. {} ({}) bytes",
"Sizes don't match! {} ({}) vs. {} ({}) bytes. Perhaps the validity differs?",
c1.total_size_bytes(),
c1.component_name(),
c2.total_size_bytes(),
Expand All @@ -1208,7 +1209,7 @@ impl DataTable {

fn cell_to_bytes(cell: DataCell) -> Vec<u8> {
let row = DataRow::from_cells1(
RowId::random(),
RowId::ZERO,
"cell",
TimePoint::default(),
cell.num_instances(),
Expand All @@ -1229,17 +1230,25 @@ impl DataTable {
}

let c1_bytes = cell_to_bytes(c1.clone());
let c2_bytes = cell_to_bytes(c1.clone());
let c2_bytes = cell_to_bytes(c2.clone());

size_mismatches.push(
similar_asserts::SimpleDiff::from_str(
&format!("{c1_bytes:?}"),
&format!("{c2_bytes:?}"),
"cell1_ipc",
"cell2_ipc",
)
.to_string(),
);
size_mismatches.push(format!(
"IPC size is {} vs {} bytes",
c1_bytes.len(),
c2_bytes.len()
));

if c1_bytes.len().max(c2_bytes.len()) < 300 {
size_mismatches.push(
similar_asserts::SimpleDiff::from_str(
&format!("{c1_bytes:#?}"),
&format!("{c2_bytes:#?}"),
"cell1_ipc",
"cell2_ipc",
)
.to_string(),
);
}
}
}

Expand All @@ -1248,7 +1257,9 @@ impl DataTable {
&& entity_path1 == entity_path2
&& num_instances1 == num_instances2
&& cells1 == cells2,
"Found discrepancy in row #{ri}:\n{}\n{}",
"Found discrepancy in row #{ri}:\n{}\n{}\
\n\nrow1:\n{row1}
\n\nrow2:\n{row2}",
similar_asserts::SimpleDiff::from_str(
&row1.to_string(),
&row2.to_string(),
Expand Down
2 changes: 1 addition & 1 deletion crates/re_types/source_hash.txt

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

10 changes: 9 additions & 1 deletion crates/re_types/src/components/line_strip2d.rs

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

10 changes: 9 additions & 1 deletion crates/re_types/src/components/line_strip3d.rs

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

10 changes: 9 additions & 1 deletion crates/re_types/src/components/origin3d.rs

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

10 changes: 9 additions & 1 deletion crates/re_types/src/components/point2d.rs

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

10 changes: 9 additions & 1 deletion crates/re_types/src/components/point3d.rs

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

10 changes: 9 additions & 1 deletion crates/re_types/src/components/vector3d.rs

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

10 changes: 9 additions & 1 deletion crates/re_types/src/datatypes/mat3x3.rs

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

10 changes: 9 additions & 1 deletion crates/re_types/src/datatypes/mat4x4.rs

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

10 changes: 9 additions & 1 deletion crates/re_types/src/datatypes/quaternion.rs

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

10 changes: 9 additions & 1 deletion crates/re_types/src/datatypes/rotation3d.rs

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

10 changes: 9 additions & 1 deletion crates/re_types/src/datatypes/rotation_axis_angle.rs

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

10 changes: 9 additions & 1 deletion crates/re_types/src/datatypes/scale3d.rs

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

20 changes: 18 additions & 2 deletions crates/re_types/src/datatypes/translation_and_mat3x3.rs

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

10 changes: 9 additions & 1 deletion crates/re_types/src/datatypes/translation_rotation_scale3d.rs

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

Loading
Loading