hashload/horse/horse-zero-allocation
Claude Code and agent skill by hashload/horse
- community
Checking that the SKILL.md file is still in the repository.
Guide for programming with Zero-Allocation principles in Horse, focusing on stack allocations, string slicing, object pooling, and avoiding lock contention.
Install
npx vskill@latest install hashload/horse/horse-zero-allocationSKILL.md
The same SKILL.md was published earlier as hashload/horse/horse-zero-allocation.
Horse Zero-Allocation Programming
To write custom routers, high-performance middlewares, or request handlers that scale under extreme concurrency, you must minimize or eliminate memory allocations on the dynamic heap. Heap allocations require global memory manager locks, which cause lock contention and page faults across multi-threaded applications.
1. Zero-Allocation String Slicing (Avoid String Copying)
Using functions like Copy(MyString, Start, Length) or string concatenation (+) allocates new string segments on the heap. Under heavy concurrency, this degrades performance.
- Rule: Use index/pointer boundaries (such as
PChar) or specialized slice types to perform string matches and parsing. - Idiomatic Example: Create or use a slice structure (like
THorseBufferSlicein the Horse RouterTree) to match paths without generating new sub-strings.
2. Using the Stack (Records and Static Arrays)
Avoid creating temporary class instances or dynamic arrays (array of Byte) inside loop structures or high-frequency handler routines. These require heap overhead and reference-counting locks.
- Stack Allocation (Records): Declare local data carriers as
recordrather thanclass. Records are allocated automatically on the fast thread stack and cleaned up instantly upon exit. - Static Arrays: For local buffers (such as socket buffers or event arrays), declare static arrays with fixed sizes:
3. Object and Request Recycling (Pooling)
Instead of instantiating helper objects (like database queries, parser buffers, or connection context blocks) for every HTTP request, utilize a thread-safe Object Pool (e.g. THorseContextPool).
- Padrão:
- Acquire a pre-allocated object from the pool at the start of the handler.
- Use the object.
- Reset the object's internal fields (clean/nullify references).
- Return the object to the pool in a
finallyblock.
4. Zero-Copy and Direct Encoding Handling
Avoid redundant string transcoding (e.g. converting UTF-8 response buffers back and forth to standard UnicodeString).
- Pass-through Buffer: Pass raw bytes and stream pointers directly to the socket API (like Windows HTTP.sys kernel API or FPC Epoll socket handles).
- Reference Clearing: Ensure references to pooled objects or structures (such as connection context structures) are explicitly nilled out/cleared immediately after request termination. This prevents the compiler's runtime from executing locking cleanup logic on worker threads.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingdoc/skills/horse-zero-allocation/SKILL.md
Popularity
- Repository stars
- 1,368
- Repository forks
- 244
- 7-day trend score
- 36
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/hashload/horse/horse-zero-allocation)