From ca5840a144391442260f2477717914fc0bcb0b8a Mon Sep 17 00:00:00 2001
From: Tyler Mandry <tmandry@gmail.com>
Date: Mon, 14 Oct 2019 15:13:55 -0700
Subject: [PATCH] Add await-call-tree benchmark

---
 collector/benchmarks/README.md                |  4 ++++
 .../benchmarks/await-call-tree/Cargo.lock     |  6 +++++
 .../benchmarks/await-call-tree/Cargo.toml     |  5 +++++
 .../benchmarks/await-call-tree/src/lib.rs     | 22 +++++++++++++++++++
 4 files changed, 37 insertions(+)
 create mode 100644 collector/benchmarks/await-call-tree/Cargo.lock
 create mode 100644 collector/benchmarks/await-call-tree/Cargo.toml
 create mode 100644 collector/benchmarks/await-call-tree/src/lib.rs

diff --git a/collector/benchmarks/README.md b/collector/benchmarks/README.md
index cf88ec58f..659bce43d 100644
--- a/collector/benchmarks/README.md
+++ b/collector/benchmarks/README.md
@@ -64,6 +64,10 @@ These are artificial programs that stress one particular aspect of the
 compiler. Some are entirely artificial, and some are extracted from real
 programs.
 
+- **await-call-tree**: A tree of async fns that await each other, creating a
+  large type composed of many repeated `impl Future` types. Such types caused
+  [poor performance](https://github.com/rust-lang/rust/issues/65147) in the
+  past.
 - **coercions**: Contains a static array with 65,536 string literals, which
   caused [poor performance](https://github.com/rust-lang/rust/issues/32278) in
   the past.
diff --git a/collector/benchmarks/await-call-tree/Cargo.lock b/collector/benchmarks/await-call-tree/Cargo.lock
new file mode 100644
index 000000000..0aa9be9a5
--- /dev/null
+++ b/collector/benchmarks/await-call-tree/Cargo.lock
@@ -0,0 +1,6 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+[[package]]
+name = "await-call-tree"
+version = "0.1.0"
+
diff --git a/collector/benchmarks/await-call-tree/Cargo.toml b/collector/benchmarks/await-call-tree/Cargo.toml
new file mode 100644
index 000000000..d19bac871
--- /dev/null
+++ b/collector/benchmarks/await-call-tree/Cargo.toml
@@ -0,0 +1,5 @@
+[package]
+name = "await-call-tree"
+version = "0.1.0"
+authors = ["Tyler Mandry <tmandry@gmail.com>"]
+edition = "2018"
diff --git a/collector/benchmarks/await-call-tree/src/lib.rs b/collector/benchmarks/await-call-tree/src/lib.rs
new file mode 100644
index 000000000..67f9eefe2
--- /dev/null
+++ b/collector/benchmarks/await-call-tree/src/lib.rs
@@ -0,0 +1,22 @@
+#![type_length_limit="15000000"]
+#![allow(unused)]
+
+macro_rules! mk_async_fn {
+    ($f:ident $g:ident) => {
+        async fn $g() -> i32 {
+            $f().await;
+            $f().await;
+            $f().await
+        }
+    }
+}
+
+async fn a() -> i32 { 1 }
+
+mk_async_fn!(a b);
+mk_async_fn!(b c);
+mk_async_fn!(c d);
+mk_async_fn!(d e);
+mk_async_fn!(e f);
+mk_async_fn!(f g);
+mk_async_fn!(g h);