Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New codegen architecture #211

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,197 changes: 724 additions & 473 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ members = [
"test_codegen",
"benches",
"crates/*",
]
]
19 changes: 11 additions & 8 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,26 @@ edition = "2021"
[dependencies]
# Path dependencies
cornucopia = { path = "../crates/cornucopia" }
cornucopia_sync = { path = "../crates/client_sync" }
cornucopia_async = { path = "../crates/client_async" }

# benchmarking
criterion = { version = "0.5.1", features = ["html_reports"] }

# async
tokio = { version = "1.24.2", features = ["full"] }
futures = "0.3.25"
tokio = { version = "1.28.1", features = ["macros", "rt-multi-thread"] }
futures = "0.3.28"

# rust-postgres interaction
postgres = "0.19.4"
tokio-postgres = "0.7.7"
postgres-types = "0.2.4"
postgres = "0.19.5"
tokio-postgres = "0.7.8"
postgres-types = "0.2.5"

# diesel
diesel = { version = "2.0.2", features = ["postgres"] }
diesel = { version = "2.0.4", features = ["postgres"] }

# Temporary files
tempfile = "3.5.0"

generated = { path = "generated" }

[[bench]]
name = "execution"
Expand Down
16 changes: 8 additions & 8 deletions benches/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ fn bench(c: &mut Criterion) {
cornucopia::container::cleanup(false).ok();
cornucopia::container::setup(false).unwrap();
let client = &mut cornucopia_conn().unwrap();

cornucopia::load_schema(client, &["../codegen_test/schema.sql"]).unwrap();
let tmp = tempfile::tempdir().unwrap();
cornucopia::load_schema(client, &["../test_codegen/schema.sql"]).unwrap();
c.bench_function("codegen_sync", |b| {
b.iter(|| {
cornucopia::generate_live(
cornucopia::gen_live(
client,
"../test_codegen/queries",
None,
"../test_codegen/queries".as_ref(),
tmp.path(),
CodegenSettings {
gen_sync: true,
gen_async: false,
Expand All @@ -24,10 +24,10 @@ fn bench(c: &mut Criterion) {
});
c.bench_function("codegen_async", |b| {
b.iter(|| {
cornucopia::generate_live(
cornucopia::gen_live(
client,
"../test_codegen/queries",
None,
"../test_codegen/queries".as_ref(),
tmp.path(),
CodegenSettings {
gen_sync: true,
gen_async: false,
Expand Down
6 changes: 2 additions & 4 deletions benches/execution/cornucopia_benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ use criterion::Bencher;
use futures::executor::block_on;
use tokio_postgres::Client;

use self::generated::queries::bench::{
use generated::queries::bench::{
async_::{comments_by_post_id, insert_user, post_by_user_ids, select_complex, users},
Comment, Post, User,
};

mod generated;

pub fn bench_trivial_query(b: &mut Bencher, client: &Client) {
let mut stmt = users();
b.iter(|| block_on(async { stmt.bind(client).all().await.unwrap() }))
Expand Down Expand Up @@ -113,7 +111,7 @@ pub mod sync {
use criterion::Bencher;
use postgres::Client;

use super::generated::queries::bench::{
use generated::queries::bench::{
sync::{comments_by_post_id, insert_user, post_by_user_ids, select_complex, users},
Comment, Post, User,
};
Expand Down
Loading