Skip to content

Commit

Permalink
Merge branch 'perf/reduce-cloning-for-dedupe' into perf/graphql-exe-c…
Browse files Browse the repository at this point in the history
…lean-up
  • Loading branch information
laststylebender14 committed Oct 24, 2024
2 parents 8b79a0c + 7bef2da commit e1b6e01
Show file tree
Hide file tree
Showing 613 changed files with 2,005 additions and 3,055 deletions.
37 changes: 22 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ indenter = "0.3.3"
derive_more = { workspace = true }
strum = "0.26.2"
dashmap = "6.1.0"
urlencoding = "2.1.3"

[dev-dependencies]
datatest-stable = "0.2.9"
Expand Down
6 changes: 3 additions & 3 deletions ci-benchmark/benchmark.graphql
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
schema @server(port: 8000, hostname: "0.0.0.0") @upstream(baseURL: "http://jsonplaceholder.typicode.com") {
schema @server(port: 8000, hostname: "0.0.0.0") {
query: Query
}

type Query @cache(maxAge: 30000) {
posts: [Post] @http(path: "/posts")
posts: [Post] @http(url: "http://jsonplaceholder.typicode.com/posts")
}

type User {
Expand All @@ -20,5 +20,5 @@ type Post {
userId: Int!
title: String!
body: String!
user: User @http(path: "/users/{{.value.userId}}")
user: User @http(url: "http://jsonplaceholder.typicode.com/users/{{.value.userId}}")
}
11 changes: 3 additions & 8 deletions ci-benchmark/nginx-benchmark.graphql
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
schema
@server(hostname: "0.0.0.0", port: 8000)
@upstream(
baseURL: "http://jsonplaceholder.typicode.com"
poolMaxIdlePerHost: 200
tcpKeepAlive: 60
proxy: {url: "http://127.0.0.1:3000"}
) {
@upstream(poolMaxIdlePerHost: 200, tcpKeepAlive: 60, proxy: {url: "http://127.0.0.1:3000"}) {
query: Query
}

type Query {
posts: [Post] @http(path: "/posts")
posts: [Post] @http(url: "http://jsonplaceholder.typicode.com/posts")
}

type User {
Expand All @@ -27,5 +22,5 @@ type Post {
userId: Int!
title: String!
body: String!
user: User @http(path: "/users/{{value.userId}}")
user: User @http(url: "http://jsonplaceholder.typicode.com/users/{{value.userId}}")
}
7 changes: 2 additions & 5 deletions examples/apollo-tracing.graphql
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
schema
@server(port: 8000, hostname: "0.0.0.0")
@upstream(baseURL: "http://jsonplaceholder.typicode.com")
@telemetry(export: {apollo: {apiKey: "1234", graphRef: "abc@123"}}) {
schema @server(port: 8000, hostname: "0.0.0.0") @telemetry(export: {apollo: {apiKey: "1234", graphRef: "abc@123"}}) {
query: Query
}

type Query @cache(maxAge: 30000) {
posts: [Post] @http(path: "/posts")
posts: [Post] @http(url: "http://jsonplaceholder.typicode.com/posts")
}

type Post {
Expand Down
20 changes: 14 additions & 6 deletions examples/apollo_federation_subgraph_post.graphql
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
schema
@server(port: 8001, enableFederation: true)
@upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42, batch: {delay: 100}) {
schema @server(port: 8001, enableFederation: true) @upstream(httpCache: 42, batch: {delay: 100}) {
query: Query
}

type Query {
posts: [Post] @http(path: "/posts")
posts: [Post] @http(url: "http://jsonplaceholder.typicode.com/posts")
}

type User @http(path: "/users", query: [{key: "id", value: "{{.value.id}}"}], batchKey: ["id"]) {
type User
@http(
url: "http://jsonplaceholder.typicode.com/users"
query: [{key: "id", value: "{{.value.id}}"}]
batchKey: ["id"]
) {
id: Int!
}

type Post @http(path: "/posts", query: [{key: "id", value: "{{.value.id}}"}], batchKey: ["id"]) {
type Post
@http(
url: "http://jsonplaceholder.typicode.com/posts"
query: [{key: "id", value: "{{.value.id}}"}]
batchKey: ["id"]
) {
id: Int!
userId: Int!
title: String!
Expand Down
13 changes: 8 additions & 5 deletions examples/apollo_federation_subgraph_user.graphql
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
schema
@server(port: 8002, enableFederation: true)
@upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42, batch: {delay: 100}) {
schema @server(port: 8002, enableFederation: true) @upstream(httpCache: 42, batch: {delay: 100}) {
query: Query
}

type Query {
user(id: Int!): User @http(path: "/users/{{.args.id}}")
user(id: Int!): User @http(url: "http://jsonplaceholder.typicode.com/users/{{.args.id}}")
}

type User @http(path: "/users", query: [{key: "id", value: "{{.value.id}}"}], batchKey: ["id"]) {
type User
@http(
url: "http://jsonplaceholder.typicode.com/users"
query: [{key: "id", value: "{{.value.id}}"}]
batchKey: ["id"]
) {
id: Int!
name: String
username: String
Expand Down
10 changes: 5 additions & 5 deletions examples/auth.graphql
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
schema
@server(port: 8000)
@upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42)
@upstream(httpCache: 42)
@link(id: "auth-basic", type: Htpasswd, src: ".htpasswd")
@link(id: "auth-jwt", type: Jwks, src: ".jwks") {
query: Query
mutation: Mutation
}

type Query {
posts: [Post] @http(path: "/posts")
user(id: Int!): User @http(path: "/users/{{.args.id}}")
posts: [Post] @http(url: "http://jsonplaceholder.typicode.com/posts")
user(id: Int!): User @http(url: "http://jsonplaceholder.typicode.com/users/{{.args.id}}")
}

type Mutation {
user(id: Int!): User @http(path: "/users/{{.args.id}}")
user(id: Int!): User @http(url: "http://jsonplaceholder.typicode.com/users/{{.args.id}}")
}

type User @protected {
Expand All @@ -30,5 +30,5 @@ type Post {
userId: Int!
title: String!
body: String! @protected
user: User @http(path: "/users/{{.value.userId}}")
user: User @http(url: "http://jsonplaceholder.typicode.com/users/{{.value.userId}}")
}
6 changes: 3 additions & 3 deletions examples/call.graphql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
schema @upstream(baseURL: "http://jsonplaceholder.typicode.com") {
schema {
query: Query
}

Expand All @@ -10,9 +10,9 @@ type Post {
}

type Query {
user(id: Int!): User @http(path: "/users/{{.args.id}}")
user(id: Int!): User @http(url: "http://jsonplaceholder.typicode.com/users/{{.args.id}}")
firstUser: User @call(steps: [{query: "user", args: {id: 1}}])
postFromUser(userId: Int!): [Post] @http(path: "/posts?userId={{.args.userId}}")
postFromUser(userId: Int!): [Post] @http(url: "http://jsonplaceholder.typicode.com/posts?userId={{.args.userId}}")
}

type User {
Expand Down
5 changes: 2 additions & 3 deletions examples/cors.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ schema
port: 8000
hostname: "0.0.0.0"
headers: {cors: {allowOrigins: ["*"], allowHeaders: ["*"], allowMethods: [POST, GET, OPTIONS]}}
)
@upstream(baseURL: "http://jsonplaceholder.typicode.com") {
) {
query: Query
}

type Query {
posts: [Post] @http(path: "/posts")
posts: [Post] @http(url: "http://jsonplaceholder.typicode.com/posts")
}

type Post {
Expand Down
9 changes: 4 additions & 5 deletions examples/graphql-composition.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@
# i.e. `tc start examples/jsonplaceholder.graphql`
# and then you can run this example and test it on 8001 port

schema
@server(port: 8001, queryValidation: false, hostname: "0.0.0.0")
@upstream(baseURL: "http://localhost:8000/graphql", httpCache: 42, batch: {delay: 1}) {
schema @server(port: 8001, queryValidation: false, hostname: "0.0.0.0") @upstream(httpCache: 42, batch: {delay: 1}) {
query: Query
}

type Query {
posts: [Post] @graphQL(name: "posts")
posts: [Post] @graphQL(url: "http://jsonplaceholder.typicode.com", name: "posts")
}

type Post {
id: Int!
userId: Int!
title: String!
body: String!
user: User @graphQL(name: "user", args: [{key: "id", value: "{{.value.userId}}"}])
user: User
@graphQL(url: "http://jsonplaceholder.typicode.com", name: "user", args: [{key: "id", value: "{{.value.userId}}"}])
}

type User {
Expand Down
14 changes: 10 additions & 4 deletions examples/grpc-reflection.graphql
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
# for test upstream server see [repo](https://github.com/tailcallhq/tailcall/tree/main/tailcall-upstream-grpc)
schema
@server(port: 8000)
@upstream(baseURL: "http://localhost:50051", httpCache: 42, batch: {delay: 10})
@upstream(httpCache: 42, batch: {delay: 10})
@link(src: "http://localhost:50051", type: Grpc, headers: [{key: "authorization", value: "Bearer 123"}]) {
query: Query
}

type Query {
news: NewsData! @grpc(method: "news.NewsService.GetAllNews")
newsById(news: NewsInput!): News! @grpc(method: "news.NewsService.GetNews", body: "{{args.news}}")
news: NewsData! @grpc(url: "http://localhost:50051", method: "news.NewsService.GetAllNews")
newsById(news: NewsInput!): News!
@grpc(url: "http://localhost:50051", method: "news.NewsService.GetNews", body: "{{args.news}}")
newsByIdBatch(news: NewsInput!): News!
@grpc(method: "news.NewsService.GetMultipleNews", body: "{{args.news}}", batchKey: ["news", "id"])
@grpc(
url: "http://localhost:50051"
method: "news.NewsService.GetMultipleNews"
body: "{{args.news}}"
batchKey: ["news", "id"]
)
}

type News {
Expand Down
14 changes: 10 additions & 4 deletions examples/grpc.graphql
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
# for test upstream server see [repo](https://github.com/tailcallhq/rust-grpc)
schema
@server(port: 8000)
@upstream(baseURL: "http://localhost:50051", httpCache: 42, batch: {delay: 10})
@upstream(httpCache: 42, batch: {delay: 10})
@link(id: "news", src: "../tailcall-fixtures/fixtures/protobuf/news.proto", type: Protobuf) {
query: Query
}

type Query {
news: NewsData! @grpc(method: "news.NewsService.GetAllNews")
newsById(news: NewsInput!): News! @grpc(method: "news.NewsService.GetNews", body: "{{.args.news}}")
news: NewsData! @grpc(url: "http://localhost:50051", method: "news.NewsService.GetAllNews")
newsById(news: NewsInput!): News!
@grpc(url: "http://localhost:50051", method: "news.NewsService.GetNews", body: "{{.args.news}}")
newsByIdBatch(news: NewsInput!): News!
@grpc(method: "news.NewsService.GetMultipleNews", body: "{{.args.news}}", batchKey: ["news", "id"])
@grpc(
url: "http://localhost:50051"
method: "news.NewsService.GetMultipleNews"
body: "{{.args.news}}"
batchKey: ["news", "id"]
)
}

type News {
Expand Down
Loading

1 comment on commit e1b6e01

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running 30s test @ http://localhost:8000/graphql

4 threads and 100 connections

Thread Stats Avg Stdev Max +/- Stdev
Latency 8.30ms 3.31ms 143.20ms 87.12%
Req/Sec 3.06k 349.09 3.86k 85.50%

365419 requests in 30.02s, 1.83GB read

Requests/sec: 12171.87

Transfer/sec: 62.47MB

Please sign in to comment.