Skip to content
Merged
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 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ coverage

# build
dist
.wrangler

# nx
.nx
Expand Down
22 changes: 22 additions & 0 deletions examples/benchmark/functions/assets/[[path]].ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export async function onRequest(context: {
request: Request
// @ts-expect-error <ignore>
env: { WASM_BUCKET: R2Bucket }
next: () => Promise<Response>
}) {
const { request, env, next } = context
const url = new URL(request.url)
if (request.method !== 'GET' && request.method !== 'HEAD') return next()
if (!url.pathname.endsWith('.wasm')) return next()

const key = url.pathname
const object = await env.WASM_BUCKET.get(key)
if (!object) return next()

const headers = new Headers()
object.writeHttpMetadata(headers)
headers.set('etag', object.httpEtag)
headers.set('Cache-Control', 'public, max-age=31536000, immutable')

return new Response(object.body, { headers })
}
4 changes: 2 additions & 2 deletions examples/benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"test:lint": "biome lint --write",
"test:type": "tsgo --noEmit",
"build": "pnpm vite build",
"wrangler:deploy": "wrangler pages deploy"
"wrangler:deploy": "tsx ./src/scripts/deployPages.ts"
},
"dependencies": {
"@codemirror/commands": "^6.10.2",
Expand All @@ -25,7 +25,7 @@
"@tanstack/solid-virtual": "^3.10.8",
"@tursodatabase/database-wasm": "^0.4.4",
"codemirror": "^6.0.2",
"solid-js": "^1.9.10",
"solid-js": "^1.9.11",
"sqlocal": "^0.17.0",
"zod": "^4.3.6",
"zod-schema-faker": "^2.1.0"
Expand Down
5 changes: 5 additions & 0 deletions examples/benchmark/public/_routes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"version": 1,
"include": ["/assets/*.wasm"],
"exclude": []
}
12 changes: 6 additions & 6 deletions examples/benchmark/src/components/sqlTest.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createResource } from 'solid-js'
// import { DuckdbDB, duckdbFactory } from './database/duckdbDB.tsx'
// import { DuckdbSchemaMigrator } from './database/duckdbSchemaMigrator.tsx'
import { DuckdbDB, duckdbFactory } from './database/duckdbDB.tsx'
import { DuckdbSchemaMigrator } from './database/duckdbSchemaMigrator.tsx'
import { PgliteDB, pgliteFactory } from './database/pgliteDB.tsx'
import { PgliteSchemaMigrator } from './database/pgliteSchemaMigrator.tsx'
import { SqliteDB, sqliteFactory } from './database/sqliteDB.tsx'
Expand All @@ -10,7 +10,7 @@ import { StoolapSchemaMigrator } from './database/stoolapSchemaMigrator.tsx'
import { TanstackDB, tanstackDbFactory } from './database/tanstackDB.tsx'
import { TursoDB, tursoFactory } from './database/tursoDB.tsx'
import { TursoSchemaMigrator } from './database/tursoSchemaMigrator.tsx'
// import { TestDuckdbQuery } from './test/testDuckdbQuery.tsx'
import { TestDuckdbQuery } from './test/testDuckdbQuery.tsx'
import { TestPgliteDbIvm } from './test/testPgliteDbIvm.tsx'
import { TestPgliteDbQuery } from './test/testPgliteDbQuery.tsx'
import { TestSqliteQuery } from './test/testSqliteQuery.tsx'
Expand All @@ -21,7 +21,7 @@ import { UsageMonitor } from './usageMonitor.tsx'

export default function SqlTest(props: { query: string; rowCount: number }) {
const [tursoQueryDb] = createResource(tursoFactory)
// const [duckdbQueryDb] = createResource(duckdbFactory)
const [duckdbQueryDb] = createResource(duckdbFactory)
const [stoolapQueryDb] = createResource(stoolapFactory)

return (
Expand All @@ -36,13 +36,13 @@ export default function SqlTest(props: { query: string; rowCount: number }) {
</TanstackDB.Provider>
</article>

{/* <article>
<article>
<DuckdbDB.Provider value={duckdbQueryDb.latest!}>
<DuckdbSchemaMigrator>
<TestDuckdbQuery query={props.query} rowCount={props.rowCount} />
</DuckdbSchemaMigrator>
</DuckdbDB.Provider>
</article> */}
</article>

<article>
<StoolapDB.Provider value={stoolapQueryDb.latest!}>
Expand Down
31 changes: 31 additions & 0 deletions examples/benchmark/src/scripts/deployPages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { execSync } from 'node:child_process'
import { readdirSync, readFileSync, rmSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)

const wranglerToml = join(__dirname, '../../wrangler.toml')
const readBucketName = () => {
const text = readFileSync(wranglerToml, 'utf8')
const match = text.match(/bucket_name\s*=\s*"([^"]+)"/)
if (match?.[1]) return match[1]
throw Error(`'bucket_name=BUCKET_NAME' cannot be found in wrangler.toml`)
}
const bucketName = readBucketName()

const assetsDir = join(__dirname, '../../dist/assets')
readdirSync(assetsDir)
.filter((file) => file.endsWith('.wasm'))
.forEach((wasmFile) => {
const key = join('assets', wasmFile)
const filePath = join(assetsDir, wasmFile)
execSync(
`wrangler r2 object put --remote --file "${filePath}" --content-type application/wasm ${bucketName}/${key}`,
{ stdio: 'inherit' },
)
rmSync(filePath)
})

execSync(`wrangler pages deploy`, { stdio: 'inherit' })
7 changes: 7 additions & 0 deletions examples/benchmark/wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
name = "tanstack-db-sql-interpreter-benchmark"
pages_build_output_dir = "./dist"
compatibility_date = "2025-02-28"

[[r2_buckets]]
binding = "WASM_BUCKET"
bucket_name = "tanstack-db-interpreter-wasm"

[vars]
WASM_PUBLIC_BASE = "https://<your-public-bucket-domain>"
4 changes: 4 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"test:lint": {
"inputs": [
"{projectRoot}/src/*",
"{projectRoot}/functions/*",
"{projectRoot}/test/*",
"{projectRoot}/package.json",
"{workspaceRoot}/biome.json"
Expand All @@ -17,6 +18,7 @@
"test:type": {
"inputs": [
"{projectRoot}/src/*",
"{projectRoot}/functions/*",
"{projectRoot}/test/*",
"{projectRoot}/package.json",
"{projectRoot}/tsconfig.json",
Expand All @@ -28,6 +30,7 @@
"test:unit": {
"inputs": [
"{projectRoot}/src/*",
"{projectRoot}/functions/*",
"{projectRoot}/test/**/*",
"{projectRoot}/package.json",
"{projectRoot}/vitest.config.ts"
Expand All @@ -37,6 +40,7 @@
"build": {
"inputs": [
"{projectRoot}/src/**/*",
"{projectRoot}/functions/*",
"{projectRoot}/esbuild.ts",
"{projectRoot}/package.json",
"{projectRoot}/vite.config.ts"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"devDependencies": {
"@arethetypeswrong/cli": "^0.18.2",
"@biomejs/biome": "2.4.4",
"@types/node": "^24.6.2",
"@types/node": "^24.11.0",
"@typescript/native-preview": "7.0.0-dev.20260222.1",
"@vitest/coverage-v8": "4.0.18",
"esbuild": "^0.27.3",
Expand Down
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

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