-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Description
This simple test of a codegen macro from protocol using a transport from protocol-mve-transport takes an unreasonable amount of time to compile. protocol
itself takes 4 to 5 minutes to compile on my laptop but compiling this simple example takes up to 20 minutes on the same hardware, and that's with a lot of the macro expansion in protocol
disabled to reduce the time spent. -Z self-profile
indicates that time is overwhelmingly (> 90%) spent as self time in typeck_tables_of
for this main function under collect_mod_item_types
etc.
use core::fmt::{self, Display, Formatter};
use core_error::Error;
use futures::{channel::mpsc::unbounded, executor::LocalPool, task::LocalSpawnExt, StreamExt};
use protocol::protocol;
use protocol_mve_transport::{Coalesce, Unravel};
use void::Void;
#[protocol]
#[derive(Debug)]
pub struct Unit;
#[protocol]
#[derive(Debug)]
pub struct Newtype(u16);
#[protocol]
#[derive(Debug)]
pub struct Tuple(Vec<String>, u8, Newtype);
#[protocol]
#[derive(Debug)]
pub struct Test {
data: u8,
other: String,
unit: Unit,
tuple: Tuple,
}
fn main() {
let mut pool = LocalPool::new();
let s = pool.spawner();
let spawner = s.clone();
let (a_sender, a_receiver) = unbounded();
let (b_sender, b_receiver) = unbounded();
s.spawn_local(async move {
Unravel::<Void, _, _, _, Test>::new(
a_receiver.map(Ok::<Vec<u8>, Void>),
b_sender,
spawner,
Test {
data: 10,
other: "hello".to_owned(),
unit: Unit,
tuple: Tuple(
["there", "general", "kenoi"]
.iter()
.cloned()
.map(String::from)
.collect(),
5,
Newtype(20),
),
},
)
.await
.unwrap();
})
.unwrap();
let spawner = s.clone();
s.spawn_local(async move {
let data = Coalesce::<_, _, _, _, Test>::new(
b_receiver.map(Ok::<Vec<u8>, Void>),
a_sender,
spawner,
);
println!("{:?}", data.await.unwrap())
})
.unwrap();
pool.run();
}
Unfortunately, there isn't a lot that I can do to reduce this as I have no idea what the underlying factors are that would lead to this occurring. I have a very limited understanding of incremental compilation or what individual queries are responsible for. If any logs, profile traces, etc. would be helpful please let me know and I will provide them.