Browse Source

rust/trillium: add two additional runtime variants (#8873)

Jacob Rothstein 1 year ago
parent
commit
50184be00b

File diff suppressed because it is too large
+ 422 - 226
frameworks/Rust/trillium/Cargo.lock


+ 19 - 5
frameworks/Rust/trillium/Cargo.toml

@@ -5,28 +5,42 @@ edition = "2021"
 
 
 [features]
 [features]
 jemallocator = ["dep:jemallocator"]
 jemallocator = ["dep:jemallocator"]
+tokio = ["dep:trillium-tokio", "sea-orm/runtime-tokio", "sqlx/runtime-tokio"]
+smol = [
+        "dep:trillium-smol",
+        "sea-orm/runtime-async-std",
+        "sqlx/runtime-async-std",
+]
+async-std = [
+        "dep:trillium-async-std",
+        "sea-orm/runtime-async-std",
+        "sqlx/runtime-async-std",
+]
 
 
 [dependencies]
 [dependencies]
 askama = "0.12.1"
 askama = "0.12.1"
+env_logger = "0.11.3"
 fastrand = "2.0.2"
 fastrand = "2.0.2"
 futures-lite = "2.3.0"
 futures-lite = "2.3.0"
+jemallocator = { version = "0.5.4", optional = true }
+moka = { version = "0.12.5", features = ["future"] }
 serde = { version = "1.0.197", features = ["derive"] }
 serde = { version = "1.0.197", features = ["derive"] }
 serde_json = "1.0.115"
 serde_json = "1.0.115"
+sqlx = "0.7.4"
 trillium = "0.2.19"
 trillium = "0.2.19"
 trillium-api = "0.1.0"
 trillium-api = "0.1.0"
 trillium-askama = "0.3.2"
 trillium-askama = "0.3.2"
-trillium-smol = "0.4.0"
+trillium-async-std = { version = "0.4.0", optional = true }
 trillium-logger = "0.4.5"
 trillium-logger = "0.4.5"
 trillium-router = "0.4.1"
 trillium-router = "0.4.1"
+trillium-smol = { version = "0.4.0", optional = true }
+trillium-tokio = { version = "0.4.0", optional = true }
 unicycle = "0.10.1"
 unicycle = "0.10.1"
-env_logger = "0.11.3"
-moka = { version = "0.12.5", features = ["future"] }
-jemallocator = {version="0.5.4", optional = true}
 
 
 [dependencies.sea-orm]
 [dependencies.sea-orm]
 version = "0.12.15"
 version = "0.12.15"
 default-features = false
 default-features = false
-features = ["runtime-async-std-native-tls", "sqlx-postgres", "macros"]
+features = ["sqlx-postgres", "macros"]
 
 
 [profile.release]
 [profile.release]
 panic = "abort"
 panic = "abort"

+ 55 - 1
frameworks/Rust/trillium/benchmark_config.json

@@ -23,7 +23,61 @@
         "webserver": "None",
         "webserver": "None",
         "os": "Linux",
         "os": "Linux",
         "database_os": "Linux",
         "database_os": "Linux",
-        "display_name": "Trillium",
+        "display_name": "Trillium [smol]",
+        "notes": "",
+        "versus": "None",
+        "tags": ["verified"]
+      }
+    },
+    {
+      "async-std": {
+        "db_url": "/db",
+        "json_url": "/json",
+        "query_url": "/queries/",
+        "plaintext_url": "/plaintext",
+        "fortune_url": "/fortunes",
+        "cached_query_url": "/cached-queries/",
+        "update_url": "/updates/",
+        "port": 8080,
+        "approach": "Realistic",
+        "classification": "Micro",
+        "database": "postgres",
+        "framework": "Trillium",
+        "language": "Rust",
+        "flavor": "None",
+        "orm": "Full",
+        "platform": "None",
+        "webserver": "None",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "Trillium [async-std]",
+        "notes": "",
+        "versus": "None",
+        "tags": ["verified"]
+      }
+    },
+    {
+      "tokio": {
+        "db_url": "/db",
+        "json_url": "/json",
+        "query_url": "/queries/",
+        "plaintext_url": "/plaintext",
+        "fortune_url": "/fortunes",
+        "cached_query_url": "/cached-queries/",
+        "update_url": "/updates/",
+        "port": 8080,
+        "approach": "Realistic",
+        "classification": "Micro",
+        "database": "postgres",
+        "framework": "Trillium",
+        "language": "Rust",
+        "flavor": "None",
+        "orm": "Full",
+        "platform": "None",
+        "webserver": "None",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "Trillium [tokio]",
         "notes": "",
         "notes": "",
         "versus": "None",
         "versus": "None",
         "tags": ["verified"]
         "tags": ["verified"]

+ 14 - 1
frameworks/Rust/trillium/src/main.rs

@@ -8,6 +8,18 @@ mod routes;
 use application::application;
 use application::application;
 use trillium::HttpConfig;
 use trillium::HttpConfig;
 
 
+#[cfg(all(feature = "smol", not(feature = "tokio"), not(feature = "async-std")))]
+use trillium_smol::config;
+
+#[cfg(all(feature = "tokio", not(feature = "smol"), not(feature = "async-std")))]
+use trillium_tokio::config;
+
+#[cfg(all(feature = "async-std", not(feature = "smol"), not(feature = "tokio")))]
+use trillium_async_std::config;
+
+#[cfg(not(any(feature = "async-std", feature = "smol", feature = "tokio")))]
+compile_error! {"please run with one of the following --features `async-std`, `smol`, `tokio`"}
+
 fn main() {
 fn main() {
     #[cfg(debug_assertions)]
     #[cfg(debug_assertions)]
     env_logger::init();
     env_logger::init();
@@ -17,7 +29,8 @@ fn main() {
         .with_request_buffer_initial_len(256)
         .with_request_buffer_initial_len(256)
         .with_response_header_initial_capacity(5);
         .with_response_header_initial_capacity(5);
 
 
-    trillium_smol::config()
+    config()
+        .with_nodelay()
         .with_http_config(http_config)
         .with_http_config(http_config)
         .run(application())
         .run(application())
 }
 }

+ 16 - 0
frameworks/Rust/trillium/trillium-async-std.dockerfile

@@ -0,0 +1,16 @@
+FROM rust:1.77
+WORKDIR /trillium
+COPY src src
+COPY templates templates
+COPY Cargo.toml Cargo.toml
+COPY Cargo.lock Cargo.lock
+
+EXPOSE 8080
+
+ENV RUSTFLAGS="-C target-cpu=native"
+ENV PORT=8080
+ENV HOST=0.0.0.0
+ENV DATABASE_URL=postgres://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world
+
+RUN cargo build --release --features jemallocator,async-std
+CMD ["./target/release/trillium-techempower"]

+ 16 - 0
frameworks/Rust/trillium/trillium-tokio.dockerfile

@@ -0,0 +1,16 @@
+FROM rust:1.77
+WORKDIR /trillium
+COPY src src
+COPY templates templates
+COPY Cargo.toml Cargo.toml
+COPY Cargo.lock Cargo.lock
+
+EXPOSE 8080
+
+ENV RUSTFLAGS="-C target-cpu=native"
+ENV PORT=8080
+ENV HOST=0.0.0.0
+ENV DATABASE_URL=postgres://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world
+
+RUN cargo build --release --features jemallocator,tokio
+CMD ["./target/release/trillium-techempower"]

+ 2 - 2
frameworks/Rust/trillium/trillium.dockerfile

@@ -1,4 +1,4 @@
-FROM rust:1.76
+FROM rust:1.77
 WORKDIR /trillium
 WORKDIR /trillium
 COPY src src
 COPY src src
 COPY templates templates
 COPY templates templates
@@ -12,5 +12,5 @@ ENV PORT=8080
 ENV HOST=0.0.0.0
 ENV HOST=0.0.0.0
 ENV DATABASE_URL=postgres://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world
 ENV DATABASE_URL=postgres://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world
 
 
-RUN cargo build --release --features jemallocator
+RUN cargo build --release --features jemallocator,smol
 CMD ["./target/release/trillium-techempower"]
 CMD ["./target/release/trillium-techempower"]

Some files were not shown because too many files changed in this diff