You can experiment with cargo build --timings
and cargo rustc -- -Zself-profile
to try finding the slowest part of the build process.
If it's caused by monomorphization then working around this issue is straight forward. You may need to patch many of the transitive dependencies that the project uses, though. There are around 200 of them.
cargo llvm-lines -p exec
gives me (this is the top-N with at least 1000 lines of IR):
Lines Copies Function name
----- ------ -------------
278457 13948 (TOTAL)
12090 (4.3%, 4.3%) 65 (0.5%, 0.5%) async_graphql::resolver_utils::container::Fields::add_set::{{closure}}
4700 (1.7%, 6.0%) 18 (0.1%, 0.6%) <futures_util::stream::futures_unordered::FuturesUnordered<Fut> as futures_core::stream::Stream>::poll_next
3718 (1.3%, 7.4%) 13 (0.1%, 0.7%) async_graphql::resolver_utils::container::resolve_container_inner::{{closure}}
3508 (1.3%, 8.6%) 159 (1.1%, 1.8%) core::result::Result<T,E>::map_err
3060 (1.1%, 9.7%) 18 (0.1%, 2.0%) <futures_util::future::try_join_all::TryJoinAll<F> as core::future::future::Future>::poll
2977 (1.1%, 10.8%) 13 (0.1%, 2.1%) async_graphql::resolver_utils::container::Fields::add_set
2791 (1.0%, 11.8%) 49 (0.4%, 2.4%) <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
2754 (1.0%, 12.8%) 18 (0.1%, 2.5%) <futures_util::stream::futures_ordered::FuturesOrdered<Fut> as futures_core::stream::Stream>::poll_next
2736 (1.0%, 13.8%) 8 (0.1%, 2.6%) async_graphql::resolver_utils::list::resolve_list::{{closure}}
2536 (0.9%, 14.7%) 16 (0.1%, 2.7%) async_graphql::resolver_utils::list::resolve_list::{{closure}}::{{closure}}
2502 (0.9%, 15.6%) 18 (0.1%, 2.8%) futures_util::stream::futures_unordered::FuturesUnordered<Fut>::new
2472 (0.9%, 16.5%) 42 (0.3%, 3.1%) alloc::vec::Vec<T,A>::extend_trusted
2442 (0.9%, 17.3%) 66 (0.5%, 3.6%) <alloc::sync::Weak<T,A> as core::ops::drop::Drop>::drop
2416 (0.9%, 18.2%) 96 (0.7%, 4.3%) std::panic::catch_unwind
2124 (0.8%, 19.0%) 18 (0.1%, 4.4%) futures_util::stream::futures_unordered::ready_to_run_queue::ReadyToRunQueue<Fut>::dequeue
1980 (0.7%, 19.7%) 18 (0.1%, 4.6%) futures_util::stream::futures_unordered::FuturesUnordered<Fut>::release_task
1919 (0.7%, 20.4%) 89 (0.6%, 5.2%) core::option::Option<T>::map
1907 (0.7%, 21.1%) 103 (0.7%, 5.9%) core::iter::adapters::map::map_fold::{{closure}}
1905 (0.7%, 21.7%) 92 (0.7%, 6.6%) <core::result::Result<T,E> as core::ops::try_trait::Try>::branch
1873 (0.7%, 22.4%) 35 (0.3%, 6.8%) <alloc::vec::into_iter::IntoIter<T,A> as core::iter::traits::iterator::Iterator>::fold
1854 (0.7%, 23.1%) 18 (0.1%, 7.0%) futures_util::stream::futures_unordered::FuturesUnordered<Fut>::unlink
1746 (0.6%, 23.7%) 18 (0.1%, 7.1%) futures_util::stream::futures_unordered::FuturesUnordered<Fut>::link
1677 (0.6%, 24.3%) 65 (0.5%, 7.6%) async_graphql::resolver_utils::container::Fields::add_set::{{closure}}::{{closure}}
1582 (0.6%, 24.9%) 18 (0.1%, 7.7%) futures_util::stream::futures_unordered::FuturesUnordered<Fut>::push
1529 (0.5%, 25.4%) 59 (0.4%, 8.1%) <alloc::boxed::Box<T,A> as core::ops::drop::Drop>::drop
1448 (0.5%, 25.9%) 16 (0.1%, 8.2%) tokio::runtime::task::core::Cell<T,S>::new
1408 (0.5%, 26.5%) 19 (0.1%, 8.4%) <&T as async_graphql::base::OutputType>::resolve::{{closure}}
1383 (0.5%, 26.9%) 1 (0.0%, 8.4%) async_graphql::http::multipart::receive_batch_multipart::{{closure}}
1278 (0.5%, 27.4%) 18 (0.1%, 8.5%) <core::slice::iter::IterMut<T> as core::iter::traits::iterator::Iterator>::fold
1267 (0.5%, 27.9%) 1 (0.0%, 8.5%) <crate1::ports::graphql::model1::Model1 as async_graphql::resolver_utils::container::ContainerType>::resolve_field::{{closure}}
1253 (0.4%, 28.3%) 148 (1.1%, 9.6%) core::ops::function::FnOnce::call_once
1251 (0.4%, 28.8%) 179 (1.3%, 10.9%) alloc::boxed::Box<T>::new
1248 (0.4%, 29.2%) 80 (0.6%, 11.4%) tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
1241 (0.4%, 29.7%) 10 (0.1%, 11.5%) <axum::serve::WithGracefulShutdown<L,M,S,F> as core::future::into_future::IntoFuture>::into_future::{{closure}}::{{closure}}
1234 (0.4%, 30.1%) 2 (0.0%, 11.5%) alloc::collections::binary_heap::BinaryHeap<T,A>::sift_down_range
1232 (0.4%, 30.5%) 16 (0.1%, 11.6%) tokio::runtime::task::harness::poll_future
1186 (0.4%, 31.0%) 1 (0.0%, 11.6%) <async_graphql::extensions::apollo_persisted_queries::ApolloPersistedQueriesExtension<T> as async_graphql::extensions::Extension>::prepare_request::{{closure}}
1170 (0.4%, 31.4%) 1 (0.0%, 11.6%) <axum::serve::WithGracefulShutdown<L,M,S,F> as core::future::into_future::IntoFuture>::into_future::{{closure}}
1151 (0.4%, 31.8%) 18 (0.1%, 11.8%) futures_util::future::try_join_all::try_join_all
1114 (0.4%, 32.2%) 1 (0.0%, 11.8%) async_graphql::schema::prepare_request::{{closure}}
1105 (0.4%, 32.6%) 1 (0.0%, 11.8%) pest::error::Error<R>::format
1064 (0.4%, 33.0%) 18 (0.1%, 11.9%) <futures_util::stream::try_stream::try_collect::TryCollect<St,C> as core::future::future::Future>::poll
1056 (0.4%, 33.4%) 96 (0.7%, 12.6%) std::panicking::try::do_catch
1036 (0.4%, 33.7%) 9 (0.1%, 12.7%) async_graphql::types::external::optional::<impl async_graphql::base::OutputType for core::option::Option<T>>::resolve::{{closure}}
1034 (0.4%, 34.1%) 22 (0.2%, 12.8%) core::iter::traits::exact_size::ExactSizeIterator::len
1028 (0.4%, 34.5%) 18 (0.1%, 13.0%) <futures_util::future::try_maybe_done::TryMaybeDone<Fut> as core::future::future::Future>::poll
async-graphql
looks like it might be compile-time-hostile. This is not the full story, as Result::map_err()
also shows up in the top-5, and that could be used by anything.