From 65d784dc60bde625def4aae1d3dc28c9557fc9dd Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Mon, 24 Apr 2023 00:11:08 +0900 Subject: [PATCH] Set repr(C) on the Dsp struct to recover performance After https://github.com/rust-lang/rust/pull/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. --- compiler/generator/rust/rust_code_container.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/generator/rust/rust_code_container.cpp b/compiler/generator/rust/rust_code_container.cpp index 9e1b201d29..4b2d89ddbb 100644 --- a/compiler/generator/rust/rust_code_container.cpp +++ b/compiler/generator/rust/rust_code_container.cpp @@ -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);