Skip to content

Commit 65d784d

Browse files
committed
Set repr(C) on the Dsp struct to recover performance
After rust-lang/rust#102750 , Rust reorders fields in repr(Rust) structures based on size/alignment. Applying such reordering to the Dsp struct substantially hurts performance. Set repr(C) on the Dsp struct to recover that performance. See https://internals.rust-lang.org/t/unexpected-3-x-performance-regression-starting-with-rust-version-1-67/18724 for the test case and investigations that led to this.
1 parent b040eb4 commit 65d784d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

compiler/generator/rust/rust_code_container.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ void RustCodeContainer::produceClass()
176176
tab(n, *fOut);
177177
*fOut << "#[cfg_attr(feature = \"default-boxed\", derive(default_boxed::DefaultBoxed))]";
178178
tab(n, *fOut);
179+
*fOut << "#[repr(C)]";
180+
tab(n, *fOut);
179181
*fOut << "pub struct " << fKlassName << " {";
180182
tab(n + 1, *fOut);
181183

0 commit comments

Comments
 (0)