Skip to content

Pre-load JavaScript kernel into memory for faster JS startup #139

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

Merged

Conversation

mishushakov
Copy link
Member

Benchmarks

Execution time

Before:
Python kernel time taken: 64.61 milliseconds
JavaScript kernel time taken: 256.47 milliseconds

After:
Python kernel time taken: 64.32 milliseconds
JavaScript kernel time taken: 67.80 milliseconds

Memory usage

Before/after loading JavaScript kernel into memory (idle)

Screenshot 2025-08-20 at 10 40 11

@mishushakov mishushakov self-assigned this Aug 20, 2025
@mishushakov mishushakov added the improvement Improvement for current functionality label Aug 20, 2025
Copy link

linear bot commented Aug 20, 2025

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: WebSocket Cleanup Fails on Initialization Error

A resource leak occurs if javascript_context creation fails. The python_context websocket, which was successfully created, is not cleaned up because the cleanup logic after yield is not reached when an exception occurs during initialization.

template/server/main.py#L37-L54

try:
python_context = await create_context(client, websockets, "python", "/home/user")
default_websockets["python"] = python_context.id
websockets["default"] = websockets[python_context.id]
javascript_context = await create_context(client, websockets, "javascript", "/home/user")
default_websockets["javascript"] = javascript_context.id
logger.info("Connected to default runtime")
yield
# Will cleanup after application shuts down
for ws in websockets.values():
await ws.close()
await client.aclose()
except Exception as e:

Fix in Cursor Fix in Web


Comment @cursor review or bugbot run to trigger another review on this PR

@mishushakov
Copy link
Member Author

I will be doing another PR for what Cursor said (although can be ignored)

@mishushakov
Copy link
Member Author

Currently blocked by
#140

@mishushakov mishushakov enabled auto-merge (squash) August 20, 2025 12:51
@mishushakov mishushakov merged commit d6f6695 into main Aug 20, 2025
10 of 11 checks passed
@mishushakov mishushakov deleted the pre-load-javascript-kernel-into-code-interpreter-e2b-2917 branch August 20, 2025 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement for current functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants