Skip to content

Commit 607e668

Browse files
Jonathen AdkinsJonathen Adkins
authored andcommitted
Add guide on low-latency AI dev loops
Signed-off-by: Jonathen Adkins <jon@Jonathens-MacBook-Air.local>
1 parent df97ac5 commit 607e668

1 file changed

Lines changed: 205 additions & 0 deletions

File tree

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
---
2+
title: 'From Code to Compute in 200ms'
3+
description: 'Why low-latency developer loops matter for AI teams, and how Daytona helps you measure and shrink the time from code change to runnable compute.'
4+
date: 2026-05-31
5+
author: 'Johnnie Oduro Jnr'
6+
tags: ['daytona', 'ai-development', 'latency', 'devcontainers', 'performance']
7+
---
8+
9+
# From Code to Compute in 200ms
10+
11+
## Introduction
12+
13+
In AI development, the expensive part is often not the model itself — it is the time between an idea and a trustworthy result.
14+
15+
Every extra minute spent waiting on environment setup, dependency installs, or a slow restart interrupts the feedback loop. When an engineer or agent changes code and then has to wait for a fresh environment to boot, the work stops feeling interactive and starts feeling batch-oriented.
16+
17+
That is why speed matters. A fast path from code to compute keeps humans in flow, keeps agents productive, and reduces the cost of experimentation.
18+
19+
In a world where teams are using [Daytona workspace](</definitions/20240819_definition_daytona workspace.md>) environments to run AI workloads, the goal is not just reproducibility — it is reproducibility that is fast enough to use repeatedly without friction.
20+
21+
This guide shows how to think about the 200ms target, how to measure the handoff from code to runnable compute, and how to design a Daytona-based workflow that gets as close as possible to instant feedback without sacrificing consistency.
22+
23+
## TL;DR
24+
25+
- **Speed is a product feature**: faster loops mean more experiments, quicker debugging, and less context switching.
26+
- **200ms is a mindset**: the goal is a near-instant handoff to ready compute, not a fresh container build every time.
27+
- **Daytona helps by making environments reproducible and shareable**: use [development containers](</definitions/20240819_definition_development container.md>), caching, and prebuilt workspaces to cut startup time.
28+
- **Measure before you optimize**: track create time, attach time, and time-to-first-command.
29+
- **Trade-offs are real**: the fastest setups usually require more discipline around images, dependencies, and platform choices.
30+
31+
## Why 200ms Matters for AI Development
32+
33+
Two hundred milliseconds is roughly the threshold where software begins to feel immediate to a user.
34+
35+
In AI development, that “user” may be a developer, a reviewer, or an agent that needs to validate a patch before moving on to the next step. If the loop is fast, the next action feels natural. If it is slow, the developer starts batching changes, and the agent starts losing momentum.
36+
37+
There are three places where latency hurts most:
38+
39+
1. **Human iteration** — a developer wants to change a prompt, rerun a notebook, and see the effect before the idea gets cold.
40+
2. **Agentic workflows** — an AI agent may need to edit code, execute it, inspect logs, and choose the next step several times in a row.
41+
3. **Team onboarding** — new engineers should contribute quickly; if the environment takes half a day to settle, velocity drops before the first pull request.
42+
43+
That is why the real goal is not “faster for its own sake.” The goal is to shrink the time between edit and evidence. If your environment is reproducible but slow, it still gets in the way. Speed and correctness need to travel together.
44+
45+
## Step 1: Build for Fast Starts, Not Just Clean Starts
46+
47+
A Daytona workflow begins with a [daytona workspace](</definitions/20240819_definition_daytona workspace.md>) backed by a [development container](</definitions/20240819_definition_development container.md>). To keep startup time low, make the container image small and the post-create work minimal.
48+
49+
Here is a lean `devcontainer.json` example:
50+
51+
```json
52+
{
53+
"name": "ai-fast-loop",
54+
"image": "mcr.microsoft.com/devcontainers/python:3.12-bookworm",
55+
"features": {
56+
"ghcr.io/devcontainers/features/git:1": {},
57+
"ghcr.io/devcontainers/features/python:1": {}
58+
},
59+
"customizations": {
60+
"vscode": {
61+
"extensions": [
62+
"ms-python.python",
63+
"ms-toolsai.jupyter"
64+
]
65+
}
66+
},
67+
"forwardPorts": [8000],
68+
"postCreateCommand": "pip install -r requirements.txt"
69+
}
70+
```
71+
72+
A few practical rules keep this fast:
73+
74+
- Use a base image that already contains most of what you need.
75+
- Keep `postCreateCommand` short; move expensive installs into a cached layer.
76+
- Forward only the ports you actually need.
77+
- Avoid heavy extension bundles unless they are part of the workflow.
78+
- Pin dependencies so the cache stays valid across rebuilds.
79+
80+
In other words, the environment should be opinionated, but not bloated.
81+
82+
## Step 2: Start Daytona and Measure the Handoff
83+
84+
The best way to improve latency is to measure it. Daytona makes it easy to create a reproducible workspace; your job is to instrument the path from “code changed” to “compute ready.”
85+
86+
Start the server and create the workspace:
87+
88+
```bash
89+
# Start the Daytona server
90+
daytona server
91+
92+
# In another terminal, create the workspace from the current repo
93+
daytona create . --name ai-fast-loop
94+
```
95+
96+
Now measure the startup path with a simple shell benchmark:
97+
98+
```bash
99+
python3 - <<'PY'
100+
import subprocess
101+
import time
102+
103+
workspace_name = "ai-fast-loop"
104+
start = time.perf_counter()
105+
subprocess.run(["daytona", "create", ".", "--name", workspace_name], check=True)
106+
elapsed_ms = (time.perf_counter() - start) * 1000
107+
print(f"Workspace '{workspace_name}' was ready in {elapsed_ms:.1f} ms")
108+
PY
109+
```
110+
111+
This script gives you a baseline for cold-start behavior. If the number is too high, do not try to “fix” it with wishful thinking. Reduce the amount of work the environment performs during creation.
112+
113+
A useful rule of thumb:
114+
115+
- **Cold start**: everything is built, installed, and initialized from scratch.
116+
- **Warm start**: the workspace already exists and only needs to be attached or resumed.
117+
- **Ready state**: the environment is waiting for the first meaningful command, not still assembling itself.
118+
119+
The 200ms target usually belongs to the warm or ready state, not the first-ever build. That distinction matters.
120+
121+
## Step 3: Tune Daytona for a Faster Loop
122+
123+
Once you have a baseline, focus on the highest-impact changes first.
124+
125+
### 1. Cache the expensive parts
126+
127+
Package installs, model weights, wheel builds, and language toolchains are the usual culprits. Cache them in layers or volumes so every new run does not repeat the same work.
128+
129+
### 2. Keep the workspace close to the code
130+
131+
A Daytona environment is most useful when the code and runtime are already aligned. That means no ad hoc setup scripts, no manual dependency hunts, and no one-off edits on the host machine. The more declarative the environment, the faster it can be recreated.
132+
133+
### 3. Use prebuilds for repeatable branches
134+
135+
If your team frequently opens feature branches or pull requests, prebuild the workspace before someone asks for it. This is where Daytona shines: a ready-to-use environment is much faster than a fresh environment assembled under pressure.
136+
137+
### 4. Avoid “just in case” tools
138+
139+
Every extra CLI, language runtime, or service adds time to setup, validation, and troubleshooting. If a tool is not part of the critical path, leave it out until you need it.
140+
141+
## Step 4: Compare the Trade-offs
142+
143+
No solution wins on every axis. The right choice depends on whether your team values control, simplicity, portability, or raw speed.
144+
145+
| Approach | Strengths | Trade-offs |
146+
| --- | --- | --- |
147+
| Manual local setup | Familiar and flexible | Slow onboarding, drift, and machine-to-machine inconsistency |
148+
| GitHub Codespaces | Easy cloud provisioning and strong editor integration | Tied to GitHub workflows and less flexible for self-hosted control |
149+
| Persistent VM tools such as ForeverVM-style setups | Very fast warm resumes and stable state | More ops burden and the risk of environment snowflakes |
150+
| Daytona workspaces | Reproducible, portable, and fast when tuned with caches and prebuilds | Requires disciplined container design and a little platform knowledge |
151+
152+
The fastest environments are usually the ones that do the least work at startup. Daytona helps because it gives you a structured way to remove unnecessary work instead of hiding it behind a custom machine image.
153+
154+
## Real-World Scenarios Where Speed Pays Off
155+
156+
### AI pair programming and agent loops
157+
158+
An AI agent that edits code, runs tests, reads logs, and patches the same file multiple times benefits from short feedback cycles.
159+
160+
The longer the environment takes to respond, the less effective the agent becomes. A fast Daytona workspace keeps the loop tight enough that the agent can test an idea before the next reasoning step becomes stale.
161+
162+
### Prompt iteration for model applications
163+
164+
Prompt changes are small, but their effects can be surprisingly large. If the environment is ready in near real time, a developer can compare several prompt variants in one sitting instead of spreading them across the afternoon.
165+
166+
### Onboarding new engineers
167+
168+
A new teammate should be able to start from the repository and arrive at a working AI environment quickly. That is a direct productivity gain, but it is also a morale win. Fast onboarding makes the codebase feel alive instead of fragile.
169+
170+
### Team demos and incident response
171+
172+
When a customer issue or internal incident requires immediate reproduction, every minute matters. A ready Daytona workspace makes it easier to inspect the problem, rerun the workload, and ship a fix before the context disappears.
173+
174+
## What to Measure Next
175+
176+
If you want to keep improving, measure three separate numbers:
177+
178+
- **Create time**: how long it takes to build the workspace.
179+
- **Attach time**: how long it takes to connect after the workspace already exists.
180+
- **Time to first useful command**: how long until the environment can run the exact command you care about.
181+
182+
The last metric is usually the most honest. A workspace is not truly fast if it opens quickly but still needs several manual steps before the real work can begin.
183+
184+
## Conclusion
185+
186+
Speed matters in AI development because feedback is the real currency of iteration.
187+
188+
A reproducible environment is good, but a reproducible environment that is also fast is far better. Daytona gives teams the structure to build that kind of workflow.
189+
190+
Consistent [workspaces](</definitions/20240819_definition_daytona workspace.md>), portable [development containers](</definitions/20240819_definition_development container.md>), and a path to low-friction [onboarding](</definitions/20240819_definition_onboarding.md>)
191+
192+
Together, they make that speed practical at team scale.
193+
194+
If your current setup still feels like “wait, then work,” start measuring the handoff time and trim the steps that do not belong in the critical path.
195+
196+
The closer you get to the 200ms mindset, the easier it becomes for humans and agents to keep moving.
197+
198+
## References
199+
200+
- [Daytona documentation](https://www.daytona.io/docs)
201+
- [Daytona workspace definition](</definitions/20240819_definition_daytona workspace.md>)
202+
- [Development container definition](</definitions/20240819_definition_development container.md>)
203+
- [Onboarding definition](</definitions/20240819_definition_onboarding.md>)
204+
- [Dev Containers documentation](https://containers.dev/)
205+
- [GitHub Codespaces documentation](https://docs.github.com/en/codespaces)

0 commit comments

Comments
 (0)