perf(int32): default vtkCellArray to int32 storage fork-wide (+ STL reader)#76
Merged
Conversation
…k-wide) Flip vtkCellArray's default offset/connectivity storage from 64-bit to 32-bit regardless of vtkIdType width. Stock VTK defaults these to 64-bit; for the overwhelmingly common case (meshes with < 2^31 points/cells) that doubles the cell-array footprint and halves memory-bandwidth density -- the bottleneck on large meshes. int32-by-default is a broad perf/memory win. Safety: every value-writing path now auto-widens 32->64 bit when a value cannot be represented in int32, so meshes with >2^31 points/cells stay correct. The guard (WidenStorageForValue) is a single predicted-not-taken branch on the common path; the out-of-line ConvertTo64BitStorage runs only on real overflow. Guarded paths: InsertNextCell (all overloads funnel through the (npts,pts) and (int) forms), InsertCellPoint, UpdateCellCount, ReplaceCellAtId, ReplaceCellPointAtId, AppendLegacyFormat (and ImportLegacyFormat via it), Append, SetOffset. SetData stays caller-controlled (explicit width choice). Integer VALUES are identical to stock VTK; only the container narrows (width-relaxed rule). The bit-exact gate (compare.py) now compares integer arrays by value normalized to int64 rather than by raw container bytes, so the int32/int64 dtype difference is not a failure; float arrays stay strict (maxULP=0). Restore stock behaviour with SetDefaultStorageIs64Bit(true). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Apply the fvtk int32-default rule to the fast binary-STL path: store the triangle offsets/connectivity as int32 when every value fits (numFile*3 bounds both the largest offset and the largest vertex index), widening to int64 only for >2^31-element meshes. Halves the cell-array footprint; values are identical (STL order-free gate already canonicalizes). SetData is caller-controlled so it does not pick up the vtkCellArray default automatically. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Make int32 the default integer-storage width for cell topology across fvtk — stock VTK defaults
vtkCellArrayoffsets/connectivity to int64, which doubles the cell-array footprint and halves memory-bandwidth density (the bottleneck on large meshes) for the overwhelmingly common case (< 2³¹ points/cells). Integer values are identical to stock; only the container narrows ("width-relaxed" rule).What changed
vtkCellArray::DefaultStorageIs64Bit = false— every new cell array defaults to int32 storage regardless ofvtkIdTypewidth.WidenStorageForValueis a single predicted-not-taken branch on the common path; out-of-lineConvertTo64BitStorageruns only on real overflow. Guarded:InsertNextCell(all overloads funnel through the(npts,pts)/(int)forms),InsertCellPoint,UpdateCellCount,ReplaceCellAtId,ReplaceCellPointAtId,AppendLegacyFormat(+ImportLegacyFormat),Append,SetOffset.SetDatastays caller-controlled. Restore stock behaviour withSetDefaultStorageIs64Bit(true).SetDatais explicit).compare.py): integer arrays compared by value normalized to int64 (container width ignored); float arrays stay strict (maxULP=0).Validation (executor build → manylinux_2_28 container)
common_cellarray,ply_roundtrip, locators, SMP determinism, wrapper parity).🤖 Generated with Claude Code