Skip to content
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
2 changes: 2 additions & 0 deletions .github/workflows/sandbox-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
- modal
- namespace
- runloop
- upstash-box
- vercel
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -91,6 +92,7 @@ jobs:
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
NSC_TOKEN: ${{ secrets.NSC_TOKEN }}
RUNLOOP_API_KEY: ${{ secrets.RUNLOOP_API_KEY }}
UPSTASH_BOX_API_KEY: ${{ secrets.UPSTASH_BOX_API_KEY }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
Expand Down
2 changes: 1 addition & 1 deletion METHODOLOGY.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ npm run bench:burst # Burst only

### Provider Integration

**ComputeSDK**: Uses ComputeSDK for consistency and ease-of-use (e2b, daytona, blaxel, modal, vercel, hopx, codesandbox, runloop, namespace)
**ComputeSDK and direct SDK adapters**: Uses ComputeSDK where available and thin direct adapters otherwise for consistency and ease-of-use (e2b, daytona, blaxel, modal, vercel, hopx, codesandbox, runloop, namespace, upstash-box)

### Provider Execution Order

Expand Down
3 changes: 3 additions & 0 deletions env.example
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ RENDER_OWNER_ID=your_render_owner_id
######### SPRITES ########
SPRITES_TOKEN=your_sprites_token

######### UPSTASH BOX ########
UPSTASH_BOX_API_KEY=your_upstash_box_api_key

######### STORAGE ########
S3_ACCESS_KEY_ID=your_s3_access_key_id
S3_SECRET_ACCESS_KEY=your_s3_secret_access_key
Expand Down
16 changes: 16 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"bench:render": "tsx src/run.ts --provider render",
"bench:runloop": "tsx src/run.ts --provider runloop",
"bench:vercel": "tsx src/run.ts --provider vercel",
"bench:upstash-box": "tsx src/run.ts --provider upstash-box",
"bench:just-bash": "tsx src/run.ts --provider just-bash",
"bench:sprites": "tsx src/run.ts --provider sprites",
"bench:browser": "tsx src/run.ts --mode browser",
Expand Down Expand Up @@ -56,6 +57,7 @@
"@computesdk/sprites": "^0.1.5",
"@computesdk/tigris": "^1.1.1",
"@computesdk/vercel": "^1.7.22",
"@upstash/box": "^0.1.32",
"computesdk": "^2.5.4",
"dotenv": "^17.4.0",
"playwright-core": "^1.59.1"
Expand Down
7 changes: 7 additions & 0 deletions src/sandbox/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { cloudflare } from '@computesdk/cloudflare';
import { sprites } from '@computesdk/sprites';
import { compute } from 'computesdk';
import type { ProviderConfig } from './types.js';
import { createUpstashBoxCompute } from './upstash-box.js';

/**
* All provider benchmark configurations.
Expand Down Expand Up @@ -73,6 +74,12 @@ export const providers: ProviderConfig[] = [
requiredEnvVars: ['SPRITES_TOKEN'],
createCompute: () => sprites({ apiKey: process.env.SPRITES_TOKEN! }),
},
{
name: 'upstash-box',
requiredEnvVars: ['UPSTASH_BOX_API_KEY'],
createCompute: () => createUpstashBoxCompute({ apiKey: process.env.UPSTASH_BOX_API_KEY! }),
sandboxOptions: { runtime: 'node', ttl: 300 },
},
{
name: 'vercel',
requiredEnvVars: ['VERCEL_TOKEN', 'VERCEL_TEAM_ID', 'VERCEL_PROJECT_ID'],
Expand Down
47 changes: 47 additions & 0 deletions src/sandbox/upstash-box.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { EphemeralBox, type EphemeralBoxConfig } from '@upstash/box';

type UpstashBoxRunResult = {
exitCode: number;
stderr?: string;
};

type UpstashBoxSandbox = {
runCommand: (command: string) => Promise<UpstashBoxRunResult>;
destroy: () => Promise<void>;
};

type UpstashBoxCompute = {
sandbox: {
create: (options?: Record<string, unknown>) => Promise<UpstashBoxSandbox>;
};
};

const DEFAULT_EPHEMERAL_BOX_CONFIG: Pick<EphemeralBoxConfig, 'runtime' | 'ttl'> = {
runtime: 'node',
ttl: 300,
};

export function createUpstashBoxCompute(connectionOptions: Pick<EphemeralBoxConfig, 'apiKey'>): UpstashBoxCompute {
return {
sandbox: {
async create(options?: Record<string, unknown>): Promise<UpstashBoxSandbox> {
const box = await EphemeralBox.create({
...DEFAULT_EPHEMERAL_BOX_CONFIG,
...options as Partial<EphemeralBoxConfig>,
...connectionOptions,
});

return {
async runCommand(command: string): Promise<UpstashBoxRunResult> {
const run = await box.exec.command(command);
return {
exitCode: run.exitCode ?? 1,
stderr: run.exitCode === 0 ? undefined : run.result,
};
},
destroy: () => box.delete(),
};
},
},
};
}