René's URL Explorer Experiment


Title: perf(sandbox): grant the run_code session lease in the reconnect instead of extra E2B round trips by waleedlatif1 · Pull Request #8621 · simstudioai/sim · GitHub

Open Graph Title: perf(sandbox): grant the run_code session lease in the reconnect instead of extra E2B round trips by waleedlatif1 · Pull Request #8621 · simstudioai/sim

X Title: perf(sandbox): grant the run_code session lease in the reconnect instead of extra E2B round trips by waleedlatif1 · Pull Request #8621 · simstudioai/sim

Description: Summary Mothership run_code on a reused chat workbench makes 5 E2B control-plane requests per call: list and connect; then getInfo + setTimeout to extend the lease; then another getInfo on release. The acquire-time setTimeout always fires: the previous call left the deadline at about prev + 21 min, and the new lease asks for now + 21 min. In production each request is about 80–90 ms. A trivial reused call spends about 1.65 s in executeInSandbox (p50), mostly on serial remote round trips. This change grants the lease in the request that already happens, and trusts deadlines the handle itself requested: findSessionSandbox(key, { lifetimeMs }) connects with max(5 min, remaining, lease). That is the same final deadline the separate getInfo + setTimeout produced, in one request. create already granted the lease. E2BSandboxHandle records the deadline it requested (create, connect, or setTimeout). outlives() and extendLifetime() skip the provider while that lower bound covers the request. ensureSessionSandbox skips the post-acquisition extend when the granted lease covers the budget, which is anchored before acquisition. Release skips the idle refresh (session lock + getInfo) when the lease already covers the 20-minute idle window. Result: 5 → 2 control-plane requests per reused call, and 3 → 1 on create. That is about 0.25 s per call at production latency, out of a fixed cost of about 2 s. Why behavior is unchanged Same deadlines as before. After acquisition the deadline is max(previous, now + lease). After release it is ≥ 20 minutes of idle. A run that overruns its budget still falls through to the locked getInfo/setTimeout path. The recorded deadline is a valid lower bound. Session deadlines only move later. connect is given at least the remaining time. extendLifetime reads before it sets. Recovery connects preserve the deadline. No cross-call state. Handles are created per call, so nothing is cached and nothing needs invalidation. Unrequested deadlines are still read back. A reconnect without lifetimeMs, or a create without a lifetime, goes through getInfo exactly as before. Untouched: what user code sees, chat isolation, the session lock around allocation, provenance, and process supervision. Tests All 5 new tests fail on the previous code: e2b-session.test.ts › "E2B session lease": a stateful fake control plane (connect never shortens, setTimeout sets). It checks both the resulting deadline and the request count for four cases: a reused lease, a created lease, a later deadline from a parallel job, and a lease the handle did not grant. session-sandbox.test.ts: a reconnect that takes time to grant the lease still needs no extend at acquisition or release. This test also fails if the acquisition check is not anchored to the request time. Measurement The control-plane request count is covered by the tests above. The wall-clock before/after against real E2B needs keys. A benchmark script was written for that: N small Python executeInSandbox session calls, counting and timing control-plane vs envd requests. It will be run separately. Type of Change Performance improvement Testing bun run test lib/execution/remote-sandbox/e2b-session.test.ts lib/execution/remote-sandbox/session-sandbox.test.ts (72 passed), bun run check:audits, bun run type-check (apps/sim). Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing No new warnings introduced

Open Graph Description: Summary Mothership run_code on a reused chat workbench makes 5 E2B control-plane requests per call: list and connect; then getInfo + setTimeout to extend the lease; then another getInfo on release...

X Description: Summary Mothership run_code on a reused chat workbench makes 5 E2B control-plane requests per call: list and connect; then getInfo + setTimeout to extend the lease; then another getInfo on release...

Opengraph URL: https://github.com/simstudioai/sim/pull/8621

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:0e8d5f92-e39b-73e8-0330-c7064b090743
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idDF4C:3ED756:27FC61:37CE67:6AFB52CC
html-safe-nonce473b05182dee70bbd3f9cd8804cf0b87c56061512fb042a028afc262cdfae64e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERjRDOjNFRDc1NjoyN0ZDNjE6MzdDRTY3OjZBRkI1MkNDIiwidmlzaXRvcl9pZCI6IjY3OTA0MTgzMDgzNzQ2ODAyNjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac2e348060b92023fcf1695b41f7075386745bbe5094369fd4cf8f78ecb4e8cba8
hovercard-subject-tagpull_request:4743236717
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/8621/files
twitter:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
og:image:altSummary Mothership run_code on a reused chat workbench makes 5 E2B control-plane requests per call: list and connect; then getInfo + setTimeout to extend the lease; then another getInfo on release...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None7122bb414b542dba14d71a3f0b9f6fd2abce715b9f5912d082800563e6c806d1
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/simstudioai/sim git https://github.com/simstudioai/sim.git
octolytics-dimension-user_id199344406
octolytics-dimension-user_loginsimstudioai
octolytics-dimension-repository_id912559512
octolytics-dimension-repository_nwosimstudioai/sim
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id912559512
octolytics-dimension-repository_network_root_nwosimstudioai/sim
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasecbf66c024bb6d10e6955baa7413c54cf13a201bb
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/simstudioai/sim/pull/8621/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F8621%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F8621%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=simstudioai%2Fsim
Reloadhttps://github.com/simstudioai/sim/pull/8621/files
Reloadhttps://github.com/simstudioai/sim/pull/8621/files
Reloadhttps://github.com/simstudioai/sim/pull/8621/files
simstudioaihttps://github.com/simstudioai
simhttps://github.com/simstudioai/sim
Codehttps://github.com/simstudioai/sim
Issues129 (129)https://github.com/simstudioai/sim/issues
Pull requests197 (197)https://github.com/simstudioai/sim/pulls
Actionshttps://github.com/simstudioai/sim/actions
Projectshttps://github.com/simstudioai/sim/projects
Security and qualityhttps://github.com/simstudioai/sim/security
Insightshttps://github.com/simstudioai/sim/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
waleedlatif1https://github.com/waleedlatif1
staginghttps://github.com/simstudioai/sim/tree/staging
perf/run-code-overheadhttps://github.com/simstudioai/sim/tree/perf/run-code-overhead
Conversation 13 https://github.com/simstudioai/sim/pull/8621
Commits 2 https://github.com/simstudioai/sim/pull/8621/commits
Checks 32 https://github.com/simstudioai/sim/pull/8621/checks
Files changed https://github.com/simstudioai/sim/pull/8621/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/8621/files
perf(sandbox): grant the run_code session lease in the reconnect instead of extra E2B round trips https://github.com/simstudioai/sim/pull/8621/files#top
Show all changes 2 commits https://github.com/simstudioai/sim/pull/8621/files
7e8a23b perf(sandbox): grant the run_code session lease in the reconnect inst… waleedlatif1 Oct 5, 2026 https://github.com/simstudioai/sim/pull/8621/commits/7e8a23be51090925968a8959a9740334720c9300
3f5710c test(sandbox): model connect as setting the deadline so a dropped pre… waleedlatif1 Oct 5, 2026 https://github.com/simstudioai/sim/pull/8621/commits/3f5710c8cc061a440e8375cb81f889858c66ad82
Clear filters https://github.com/simstudioai/sim/pull/8621/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/8621/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/8621/files
e2b-session.test.ts https://github.com/simstudioai/sim/pull/8621/files#diff-3b81819062f839724f7a7e7103433cc0e7947cb627037cc397bdd9f44a90e015
e2b.ts https://github.com/simstudioai/sim/pull/8621/files#diff-f54663c69a136b10f426311853c9d3c7b9f328f0b85719ae7c23c0dd7030721d
index.ts https://github.com/simstudioai/sim/pull/8621/files#diff-45bb4d66958fbda0e750b34264c092e3ed4f472e7bff507cee5875a58b2d3ef4
session-sandbox.test.ts https://github.com/simstudioai/sim/pull/8621/files#diff-93993881944d4232c1cecf96599ad647e51ea63369e46347edab5f349eb6cfd2
session.ts https://github.com/simstudioai/sim/pull/8621/files#diff-59b70b1ae1c65db98eca284b97b9bf2609499ac134a3bfac6ffa4b641491062c
types.ts https://github.com/simstudioai/sim/pull/8621/files#diff-a956fe3fea088fe237d431cb20fe73201f4c5feb647827ce7021cc35a4eda2d8
apps/sim/lib/execution/remote-sandbox/e2b-session.test.tshttps://github.com/simstudioai/sim/pull/8621/files#diff-3b81819062f839724f7a7e7103433cc0e7947cb627037cc397bdd9f44a90e015
View file https://github.com/simstudioai/sim/blob/3f5710c8cc061a440e8375cb81f889858c66ad82/apps/sim/lib/execution/remote-sandbox/e2b-session.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/8621/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/8621/files#diff-3b81819062f839724f7a7e7103433cc0e7947cb627037cc397bdd9f44a90e015
apps/sim/lib/execution/remote-sandbox/e2b.tshttps://github.com/simstudioai/sim/pull/8621/files#diff-f54663c69a136b10f426311853c9d3c7b9f328f0b85719ae7c23c0dd7030721d
View file https://github.com/simstudioai/sim/blob/3f5710c8cc061a440e8375cb81f889858c66ad82/apps/sim/lib/execution/remote-sandbox/e2b.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/8621/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/8621/files#diff-f54663c69a136b10f426311853c9d3c7b9f328f0b85719ae7c23c0dd7030721d
https://github.com/simstudioai/sim/pull/8621/files#diff-f54663c69a136b10f426311853c9d3c7b9f328f0b85719ae7c23c0dd7030721d
https://github.com/simstudioai/sim/pull/8621/files#diff-f54663c69a136b10f426311853c9d3c7b9f328f0b85719ae7c23c0dd7030721d
https://github.com/simstudioai/sim/pull/8621/files#diff-f54663c69a136b10f426311853c9d3c7b9f328f0b85719ae7c23c0dd7030721d
apps/sim/lib/execution/remote-sandbox/index.tshttps://github.com/simstudioai/sim/pull/8621/files#diff-45bb4d66958fbda0e750b34264c092e3ed4f472e7bff507cee5875a58b2d3ef4
View file https://github.com/simstudioai/sim/blob/3f5710c8cc061a440e8375cb81f889858c66ad82/apps/sim/lib/execution/remote-sandbox/index.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/8621/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/8621/files#diff-45bb4d66958fbda0e750b34264c092e3ed4f472e7bff507cee5875a58b2d3ef4
https://github.com/simstudioai/sim/pull/8621/files#diff-45bb4d66958fbda0e750b34264c092e3ed4f472e7bff507cee5875a58b2d3ef4
apps/sim/lib/execution/remote-sandbox/session-sandbox.test.tshttps://github.com/simstudioai/sim/pull/8621/files#diff-93993881944d4232c1cecf96599ad647e51ea63369e46347edab5f349eb6cfd2
View file https://github.com/simstudioai/sim/blob/3f5710c8cc061a440e8375cb81f889858c66ad82/apps/sim/lib/execution/remote-sandbox/session-sandbox.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/8621/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/8621/files#diff-93993881944d4232c1cecf96599ad647e51ea63369e46347edab5f349eb6cfd2
https://github.com/simstudioai/sim/pull/8621/files#diff-93993881944d4232c1cecf96599ad647e51ea63369e46347edab5f349eb6cfd2
apps/sim/lib/execution/remote-sandbox/session.tshttps://github.com/simstudioai/sim/pull/8621/files#diff-59b70b1ae1c65db98eca284b97b9bf2609499ac134a3bfac6ffa4b641491062c
View file https://github.com/simstudioai/sim/blob/3f5710c8cc061a440e8375cb81f889858c66ad82/apps/sim/lib/execution/remote-sandbox/session.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/8621/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/8621/files#diff-59b70b1ae1c65db98eca284b97b9bf2609499ac134a3bfac6ffa4b641491062c
https://github.com/simstudioai/sim/pull/8621/files#diff-59b70b1ae1c65db98eca284b97b9bf2609499ac134a3bfac6ffa4b641491062c
https://github.com/simstudioai/sim/pull/8621/files#diff-59b70b1ae1c65db98eca284b97b9bf2609499ac134a3bfac6ffa4b641491062c
apps/sim/lib/execution/remote-sandbox/types.tshttps://github.com/simstudioai/sim/pull/8621/files#diff-a956fe3fea088fe237d431cb20fe73201f4c5feb647827ce7021cc35a4eda2d8
View file https://github.com/simstudioai/sim/blob/3f5710c8cc061a440e8375cb81f889858c66ad82/apps/sim/lib/execution/remote-sandbox/types.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/8621/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/8621/files#diff-a956fe3fea088fe237d431cb20fe73201f4c5feb647827ce7021cc35a4eda2d8
https://github.com/simstudioai/sim/pull/8621/files#diff-a956fe3fea088fe237d431cb20fe73201f4c5feb647827ce7021cc35a4eda2d8
https://github.com/simstudioai/sim/pull/8621/files#diff-a956fe3fea088fe237d431cb20fe73201f4c5feb647827ce7021cc35a4eda2d8
Please reload this pagehttps://github.com/simstudioai/sim/pull/8621/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.