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 committed Apr 23, 2023
1 parent b040eb4 commit 65d784d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/generator/rust/rust_code_container.cpp
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 65d784d

Please sign in to comment.