Skip to content

Commit

Permalink
Set repr(C) on the Dsp struct to recover performance
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
joshtriplett authored and sletz committed Apr 2, 2024
1 parent 474b514 commit 3c16347
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/generator/rust/rust_code_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ void RustCodeContainer::produceClass()
tab(n, *fOut);
*fOut << "#[cfg_attr(feature = \"default-boxed\", derive(default_boxed::DefaultBoxed))]";
tab(n, *fOut);
*fOut << "#[repr(C)]";
tab(n, *fOut);
*fOut << "pub struct " << fKlassName << " {";
tab(n + 1, *fOut);

Expand Down

0 comments on commit 3c16347

Please sign in to comment.