Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try to reduce code size when using Lpspi futures
A handful of inlines, code movements, and structural changes to reduce code size due to Lpspi fututures. I'm only measuring using the rtic_spi_blocking example and today's stable toolchain. Here's the before (using futures, without this commit): cargo bloat --example=rtic_spi_blocking --target=thumbv7em-none-eabihf --features=board/imxrt1010evk,board/spi --release --full-fn --filter="imxrt_hal?" File .text Size Crate Name 1.0% 8.0% 912B imxrt_hal? <imxrt_hal::common::lpspi::Lpspi<P,_> as embedded_hal::blocking::spi::Transfer<u8>>::transfer::h14f349cc5cffb732 0.4% 3.6% 416B imxrt_hal? <imxrt_hal::common::lpspi::Lpspi<P,_> as embedded_hal::blocking::spi::Write<u16>>::write::h7197ec21e2742661 0.4% 3.3% 372B imxrt_hal? <imxrt_hal::common::lpspi::Lpspi<P,_> as embedded_hal::blocking::spi::Write<u32>>::write::h7a95cfc351eae3bd 0.4% 3.1% 352B imxrt_hal? <imxrt_hal::common::lpspi::Lpspi<P,_> as embedded_hal::blocking::spi::Write<u8>>::write::h97a4d00b9d61362e 0.3% 2.3% 260B imxrt_hal? <imxrt_hal::common::lpspi::LpspiError as core::fmt::Debug>::fmt::h159b83c70fb11bb8 0.2% 1.3% 152B imxrt_hal imxrt_hal::common::lpspi::Lpspi<P,_>::spin_start_transaction::{{closure}}::h851006df67b00efe 0.1% 1.1% 120B imxrt_hal imxrt_hal::common::lpspi::Lpspi<P,_>::recover_from_error::hcb7d1a99cf628a19 0.1% 0.7% 84B imxrt_hal imxrt_hal::chip::imxrt10xx::ccm::clock_gate::Locator::set::he922d425fd153971 0.1% 0.6% 74B imxrt_hal <imxrt_hal::common::lpspi::TransmitBuffer<W> as imxrt_hal::common::lpspi::TransmitData>::next_word::h89742fedea75aa39 0.1% 0.5% 56B imxrt_hal imxrt_hal::common::lpspi::Lpspi<P,_>::spin_for_fifo_space::{{closure}}::hb88c57be8c5c038a 0.0% 0.3% 34B imxrt_hal <imxrt_hal::common::lpspi::TransmitBuffer<W> as imxrt_hal::common::lpspi::TransmitData>::next_word::{{closure}}::h2ade022f73d53893 0.0% 0.3% 32B imxrt_hal imxrt_hal::common::lpspi::word_count::h369e015c99262d71 0.0% 0.2% 22B imxrt_hal <imxrt_hal::common::lpspi::TransmitBuffer<W> as imxrt_hal::common::lpspi::TransmitData>::next_word::{{closure}}::h5fee28c4feefa0c4 0.0% 0.1% 8B imxrt_hal imxrt_hal::chip::imxrt10xx::ccm::wait_handshake::h65a4921464b13727 0.0% 0.0% 2B std core::ptr::drop_in_place<imxrt_hal::common::lpspi::LpspiError>::ha1d57218f9d3130e 0.0% 0.0% 0B And 0 smaller methods. Use -n N to show more. 3.0% 25.4% 2.8KiB filtered data size, the file size is 93.3KiB And here's the after (using futures, with this commit): cargo bloat --example=rtic_spi_blocking --target=thumbv7em-none-eabihf --features=board/imxrt1010evk,board/spi --release --full-fn --filter="imxrt_hal?" File .text Size Crate Name 0.7% 6.3% 664B imxrt_hal? <imxrt_hal::common::lpspi::Lpspi<P,_> as embedded_hal::blocking::spi::Transfer<u8>>::transfer::h14f349cc5cffb732 0.3% 2.5% 260B imxrt_hal? <imxrt_hal::common::lpspi::Lpspi<P,_> as embedded_hal::blocking::spi::Write<u16>>::write::h7197ec21e2742661 0.3% 2.5% 260B imxrt_hal? <imxrt_hal::common::lpspi::LpspiError as core::fmt::Debug>::fmt::h159b83c70fb11bb8 0.2% 1.7% 176B imxrt_hal? <imxrt_hal::common::lpspi::Lpspi<P,_> as embedded_hal::blocking::spi::Write<u32>>::write::h7a95cfc351eae3bd 0.2% 1.7% 176B imxrt_hal? <imxrt_hal::common::lpspi::Lpspi<P,_> as embedded_hal::blocking::spi::Write<u8>>::write::h97a4d00b9d61362e 0.1% 1.1% 120B imxrt_hal imxrt_hal::common::lpspi::Lpspi<P,_>::recover_from_error::hcb7d1a99cf628a19 0.1% 0.8% 84B imxrt_hal imxrt_hal::chip::imxrt10xx::ccm::clock_gate::Locator::set::he922d425fd153971 0.1% 0.8% 80B imxrt_hal imxrt_hal::common::lpspi::Lpspi<P,_>::enqueue_transaction::hbbccb7c33a84537a 0.1% 0.7% 74B imxrt_hal <imxrt_hal::common::lpspi::TransmitBuffer<W> as imxrt_hal::common::lpspi::TransmitData>::next_word::h89742fedea75aa39 0.1% 0.5% 56B imxrt_hal imxrt_hal::common::lpspi::Lpspi<P,_>::spin_for_fifo_space::{{closure}}::hb88c57be8c5c038a 0.0% 0.3% 36B imxrt_hal imxrt_hal::common::lpspi::Lpspi<P,_>::wait_for_transmit_fifo_space::h5850db6571c1671b 0.0% 0.3% 34B imxrt_hal <imxrt_hal::common::lpspi::TransmitBuffer<W> as imxrt_hal::common::lpspi::TransmitData>::next_word::{{closure}}::h2ade022f73d53893 0.0% 0.2% 22B imxrt_hal <imxrt_hal::common::lpspi::TransmitBuffer<W> as imxrt_hal::common::lpspi::TransmitData>::next_word::{{closure}}::h5fee28c4feefa0c4 0.0% 0.1% 8B imxrt_hal imxrt_hal::chip::imxrt10xx::ccm::wait_handshake::h65a4921464b13727 0.0% 0.0% 2B std core::ptr::drop_in_place<imxrt_hal::common::lpspi::LpspiError>::ha1d57218f9d3130e 0.0% 0.0% 0B And 0 smaller methods. Use -n N to show more. 2.2% 19.4% 2.0KiB filtered data size, the file size is 92.4KiB If I switch from full LTO to thin local LTO and reveal the whole build with `cargo bloat`, I see that TryJoin::poll() is 460 bytes large. If TryJoin::poll is inlined within the transfer function, that helps explain why it's so big. Note that I've been using the checked-in configuration for the release profile.
- Loading branch information