Understand Lean Language Server architecture
masterThe Lean Language Server uses a decoupled architecture to ensure stability:
- Watchdog Process: A single process that manages per-file worker processes, maintains minimal persistent state (like open file contents), and coordinates communication with the LSP client.
- Worker Processes: Per-file processes where the actual computation (elaboration,
#eval, autocompletion, etc.) occurs.
Key Benefits:
- Fault Isolation: If a user's metaprogram or
#evalstatement causes a crash (e.g., a stack overflow) in one file, only that specific worker process dies. The watchdog remains active, and other open files remain unaffected. - Memory Management: Workers can be restarted to safely free memory used by imported modules' compacted regions, which cannot be safely managed by the standard GC.