Repository navigation
Developer Guide Performance Tips
TokenPrint pushes the limits of what browsers can render by displaying millions of data points and complex geometries at 60fps. If you are adding features, you must write highly optimized code.
If the frame rate drops below 30fps, the cinematic camera glides become jarring, and the sense of observing a fluid mathematical process is ruined.
Never put high-frequency data (like camera coordinates or the current millisecond timestamp) in a useState hook at the top of the tree. Use Zustand (useStore.getState()) and read it directly inside R3F useFrame loops.
If you need to render 100 identical shapes (like attention blades), do not map over an array and return 100 <mesh> components. Use <instancedMesh> and update a THREE.InstancedBufferAttribute. This reduces 100 draw calls to 1.
When users switch from Architecture Explorer to Live Inference, the massive TensorCloud must be destroyed. Three.js does not automatically garbage collect WebGL buffers. You must explicitly call .dispose() on unused BufferGeometry and Material objects to prevent memory leaks.
The WS /ws/generate backend endpoint must not send the full vocabulary probability distribution (top_k (e.g., 10 floats) before sending the JSON frame.
flowchart TD
subgraph Bad Practice
State[React useState(cameraPos)] --> Render[Trigger App Re-render]
Render --> Slow[FPS Drops]
end
subgraph Good Practice
Zustand[Zustand Store] --> useFrame[R3F useFrame loop]
useFrame --> Mutate[Directly mutate mesh.position]
Mutate --> Fast[60 FPS]
end
| Previous | Home | Next |
|---|---|---|
| Debugging | Home | API Reference |
TokenPrint Wiki | Home | Getting Started | User Guide | Concepts | Architecture | API | GitHub
TokenPrint is an interactive 3D visualization platform for exploring transformer architectures, tensors, and real-time LLM inference.
- User Guide
- Architecture Explorer
- Live Inference
- Tensor Inspector
- Camera Controls
- HUD
- Timeline
- Scene Navigation
- Transformer Concepts
- Tokenization
- Embeddings
- Positional Encoding
- RoPE
- Multi-Head Attention
- KV Cache
- LayerNorm
- Feed Forward Network
- Residual Connections
- Logits
- Softmax
- Sampling
- Autoregressive Generation
- Visualization System
- Scene Graph
- Geometry
- Materials
- Animation System
- Color Mapping
- Camera System
- Interaction Model
- Architecture
- Overall Architecture
- Frontend
- Backend
- WebSocket Protocol
- Data Pipeline
- Renderer
- Event System