Rust-side Variant marshalling#1600
Draft
Bromeon wants to merge 3 commits into
Draft
Conversation
|
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1600 |
Bromeon
force-pushed
the
perf/variant-rust-marshal
branch
6 times, most recently
from
May 18, 2026 19:41
3a3fc71 to
c46ca24
Compare
Bromeon
force-pushed
the
perf/variant-rust-marshal
branch
from
May 23, 2026 14:38
c46ca24 to
c9bb01f
Compare
Bromeon
force-pushed
the
perf/variant-rust-marshal
branch
from
May 31, 2026 10:23
c9bb01f to
edb4f83
Compare
Bromeon
force-pushed
the
perf/variant-rust-marshal
branch
4 times, most recently
from
June 12, 2026 22:16
eeebe71 to
e0aefc5
Compare
Bromeon
force-pushed
the
perf/variant-rust-marshal
branch
2 times, most recently
from
June 28, 2026 22:15
e02e35a to
95a6b23
Compare
Bromeon
force-pushed
the
perf/variant-rust-marshal
branch
from
July 7, 2026 05:02
95a6b23 to
6815624
Compare
Bromeon
force-pushed
the
perf/variant-rust-marshal
branch
2 times, most recently
from
July 18, 2026 21:37
bf27835 to
820f769
Compare
Manual-mode benches must return `crate::framework::BenchResult`; missing it previously produced a confusing downstream compile error.
`Extend` pre-allocates from the iterator's size hint to avoid per-element grows; over-reported hints trim unused trailing slots instead of panicking, and a saturating add guards against a hostile hint overflowing the target length. The fast path takes a single base pointer and offsets with raw pointer arithmetic, instead of one `array_operator_index` FFI call per element. `resize_default` complements `resize()` for default-constructible types; `resize_nil` covers `VarArray`, whose `Variant` element the `Copy` bound of `resize_default` excludes. Includes the `PackedFloat32Array` <-> `Array` conversion benchmarks, which also exercise this array-growth path.
Builtins that are small enough and whose Default/Clone/Drop don't need FFI (e.g. numbers, vectors, color, RID) now marshal in-place in Variant's struct layout, skipping the engine's Variant FFI functions. This is an internal optimization with no user-facing API for now. RustMarshal relies on Godot's private Variant layout (tag@0, data@8), which the GDExtension ABI doesn't guarantee. A startup self-check builds INT and Vector3 variants via raw FFI and compares them against RustVariant reads, panicking toward the variant-ffi-marshal fallback on mismatch. Codegen fails fast on a missing builtin size, so a stale size table can't misclassify a heap-allocated type as in-place-storable.
Bromeon
force-pushed
the
perf/variant-rust-marshal
branch
from
July 21, 2026 20:32
820f769 to
e9a0a2d
Compare
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.
For
VariantholdingCopybuiltin types (or rather those that don't need an FFI constructor/destructor), we can emulate Godot'sVariantlayout directly in Rust. This saves a large number of FFI calls for justVariantconversions and has the potential to speed up operations across the board.