agilepool
High-performance adaptive goroutine pool for Go with auto-scaling via Little's Law, sliding-window rate statistics, chunked overflow buffer, multiple idle container backends (LinkedList/MinHeap/Slice/RingQueue), customizable spinlock, retry with exponential backoff, and context-aware submission
Install / Use
npx skills add Yiming1997/agilePool --skill skillsInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
Content & MediaSupported Platforms
Our assessment of agilepool
agilepool scores 79/100 on our quality scale, 1060th of 1,189 Content & Media skills we index.
Its SKILL.md is 9.8 KB long, well organised into 21 sections with 11 code examples: a thorough specification that gives an agent plenty to work with.
It has no GitHub stars yet, so there is no community track record; judge it on its content.
Maintenance, license and trust
- The repository was last updated 4 days ago, so agilepool is actively maintained.
- Our last check on 2026-09-05 found the source still online.
- No license is declared. By default that means all rights are reserved: you can read it, but reusing or redistributing it is not clearly permitted. Ask the author before building on it commercially.
- Its trust signals score 80/100, with 2 cautions from licensing, adoption, age or documentation. These come from repository metadata, not a code audit โ read the skill file before letting an agent act on it.
agilepool compared with similar skills
All 4 of these similar skills score higher than agilepool; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| agilepool (this skill)by Yiming1997 | 79 | 0 | 4d ago | SKILL.md |
| Agent-Reachby Panniantong | 100 | 102.9k | 1d ago | CLAUDE.md |
| headroomby headroomlabs-ai | 100 | 77.9k | 1d ago | CLAUDE.md |
| Scraplingby D4Vinci | 100 | 89.8k | 3d ago | MCP Server |
| crawl4aiby unclecode | 100 | 86.3k | 3d ago | MCP Server |
Frequently asked questions
- How do I install agilepool?
- Run
npx skills add Yiming1997/agilePool --skill agilepool. The install tabs above show the steps for each supported agent. - Which AI agents does agilepool work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is agilepool safe to use?
- It declares no license and scores 80/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is agilepool still maintained?
- The repository was last updated 4 days ago, so agilepool is actively maintained.
Skill content
View source on GitHubname: agilepool description: High-performance adaptive goroutine pool for Go with auto-scaling via Little's Law, sliding-window rate statistics, chunked overflow buffer, multiple idle container backends (LinkedList/MinHeap/Slice/RingQueue), customizable spinlock, retry with exponential backoff, and context-aware submission. Use when working with the github.com/Yiming1997/agilePool/v2 codebase โ adding features, fixing bugs, writing tests, or answering questions about pool internals and API usage.
agilePool โ Adaptive Goroutine Pool
Overview
Package agilepool (github.com/Yiming1997/agilePool/v2, Go 1.23.4) provides an adaptive goroutine pool that dynamically scales worker count using Little's Law. It features:
- Adaptive scaling: Median rate sampling over a sliding window โ
target = submitMedian ร runningWorkers / consumeMedian, with backlog-weighted boosting and exit-rate compensation. - Chunked overflow buffer: When the handoff channel is full, tasks spool into a linked-list of fixed-size chunks (4096 slots each). Soft cap at 100k total tasks; exceeding it blocks on the channel instead of growing unboundedly.
- Multiple idle containers:
LinkedListType(default FIFO),MinHeapType,SliceType,RingQueueTypeโ pluggable via config. - Configurable locking:
muIdlelock can besync.Mutex(default) or a customspinLock(three-phase: CAS โ exponential backoff โ Gosched). - Task variants:
Taskinterface,TaskFunc(bare func),TaskWithRetry(exponential backoff), context-aware viaSubmitCtx, timeout viaSubmitBefore. - Panic-safe: Workers recover from panics and continue processing.
- Graceful shutdown:
Close()+Wait()pattern.
Quick Start
import agilepool "github.com/Yiming1997/agilePool/v2"
pool := agilepool.NewPool(agilepool.NewConfig(
agilepool.WithWorkerNumCapacity(1000),
agilepool.WithTaskQueueSize(10000),
))
defer pool.Close()
pool.Submit(agilepool.TaskFunc(func() error {
// your work here
return nil
}))
pool.Wait()
API Reference
Pool Creation
pool := agilepool.NewPool(config *Config)
NewPool(nil) uses defaults (unlimited workers, LinkedListType, MutexLock).
Task Interface and Types
// Core interface
type Task interface {
Process()
}
// Simple function adapter
type TaskFunc func() error // func() error โ TaskFunc โ Task
pool.Submit(agilepool.TaskFunc(func() error { return nil }))
// Retry with backoff
pool.Submit(&agilepool.TaskWithRetry{
MinBackOff: 1 * time.Second,
MaxBackOff: 200 * time.Second,
RetryNum: 3, // retries on error, so total attempts = RetryNum + 1
BackOffStrategy: nil, // nil โ default exponential: min * 2^retryNum, capped at max
Task: func() error { return errors.New("fail") },
})
Submission Methods
| Method | Behavior |
|--------|----------|
| pool.Submit(task) | Enqueues task; no-op on nil. Returns void. |
| pool.TrySubmit(task) bool | Returns false if rejected (pool closed, nil task, or NONBLOCK mode queue full). |
| pool.SubmitCtx(ctx, task) | Wraps task with context; skips execution if ctx.Err() != nil at dequeue time. |
| pool.SubmitBefore(task, timeout) | Skips task if not started within timeout. |
Shutdown
pool.Close() // Idempotent. Stops cleaner/scaler. New submits become no-ops.
pool.Wait() // Blocks until all in-flight tasks complete.
// Always: Close() first, then Wait().
Critical: Call Close() before Wait(). Calling Wait() alone blocks forever because the background goroutines never exit.
Query Methods
pool.GetRunningWorkersNum() int64 // currently active goroutines
pool.GetWorkerCreateCount() int64 // lifetime sync.Pool allocations
pool.GetIdleWorkerCount() int64 // parked in idle container
pool.GetTaskQueueLen() int // len(taskQueue) โ does NOT include chunked buffer
pool.GetCapacity() int64 // max worker limit
agilepool.GetDefaultPool() *Pool // most recently created pool (nil after Close)
Logger
pool.SetLogger(l Logger) // interface { Printf(string, ...interface{}); Println(...interface{}) }
// Pass *log.Logger, zap.SugaredLogger, etc.
Configuration Options
All via functional options pattern:
agilepool.NewConfig(
agilepool.WithCleanPeriod(500 * time.Millisecond), // expired worker cleanup interval
agilepool.WithTaskQueueSize(10000), // handoff channel capacity
agilepool.WithWorkerNumCapacity(20000), // max concurrent workers
agilepool.WithBlockMode(agilepool.BLOCK), // BLOCK (default) or NONBLOCK
agilepool.WithIdleContainerType(agilepool.LinkedListType), // LinkedList/MinHeap/Slice/RingQueue
agilepool.WithLockType(agilepool.SpinLock), // MutexLock (default) or SpinLock
agilepool.WithStatsSamplePeriod(100 * time.Millisecond), // rate sampling interval
agilepool.WithStatsWindowSize(10), // sliding window count for median
agilepool.WithScalerPeriod(10 * time.Millisecond), // scaler tick interval
agilepool.WithBacklogDecayFactor(0.3), // queue backlog weight in scaler (0-1)
)
WorkMode
- BLOCK (default):
Submitblocks until the task is accepted (channel or chunked buffer). - NONBLOCK:
Submitdrops the task when the handoff channel is full. UseTrySubmitto detect rejection.
IdleContainerType
| Type | Add | Pop | Best for |
|------|-----|-----|----------|
| LinkedListType | O(1) | O(1) | General purpose (default) |
| MinHeapType | O(log n) | O(log n) | Ordered by lastActiveAt |
| SliceType | O(1) | O(n) | Simple, small pools |
| RingQueueType | O(1) | O(1) | High-frequency Pop; works well with SpinLock |
Common Patterns
Graceful Shutdown
pool := agilepool.NewPool(config)
defer pool.Close() // 1. Stop accepting new work
// ... submit tasks ...
pool.Wait() // 2. Wait for completion
Producer-Consumer
pool := agilepool.NewPool(agilepool.NewConfig(
agilepool.WithWorkerNumCapacity(runtime.NumCPU() * 2),
))
defer pool.Close()
var wg sync.WaitGroup
for _, item := range items {
wg.Add(1)
it := item
pool.Submit(agilepool.TaskFunc(func() error {
defer wg.Done()
process(it)
return nil
}))
}
wg.Wait()
pool.Wait()
Context-Aware with Cancellation
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
pool.SubmitCtx(ctx, agilepool.TaskFunc(func() error {
select {
case <-ctx.Done():
return ctx.Err()
default:
return doWork()
}
}))
Anti-Patterns & Pitfalls
-
Don't call
Wait()beforeClose()โ the pool has background goroutines (cleaner, scaler, sampler).Wait()withoutClose()blocks forever. -
Don't
Close()from within a task without defer โClose()stops the cleaner goroutine, causing idle workers to accumulate. Closing inside a task is safe but usedefer pool.Close()only at the outer scope. -
Nil
*TaskWithRetrypanics โisNilTaskchecks*TaskWithRetry == nilbut not itsTaskfield. EnsureTaskis non-nil. -
SubmitCtxwithnilcontext โ automatically usescontext.Background(). An already-canceled context causes the task to be silently dropped. -
GetTaskQueueLen()is incomplete โ it only reportslen(taskQueue), not the chunked overflow buffer. For true backlog, check your own metrics. -
Task closure capture โ Go loop variable capture applies. Always copy:
for _, v := range items { v := v pool.Submit(agilepool.TaskFunc(func() error { use(v); return nil })) }
Testing
Tests use package agilepool_test (external test package) โ import github.com/Yiming1997/agilePool/v2 and use the public API. Use testing.Short() guards for heavy benchmarks:
if testing.Short() {
taskCount = 20000 // reduced
}
Internal Architecture (when modifying code)
pool.go: Core Pool struct, NewPool, Submit path (channel โ chunked buffer โ backpressure), scaler withscaleIfNeeded(), Close/Wait.config.go:Configstruct andWith*functional options.worker.go:worker.run()โ three-phase task acquisition loop: (1) channel receive, (2) chunked buffer batch (up to 8 per lock), (3) second channel check before parking.task.go:Taskinterface,TaskFunc,TaskWithRetry(exponential backoff default:min ร 2^retryNum, capped atmax).idle_container.go:IdleWorkerContainerinterface +IdleContainerTypeenum.idle_linkedlist.go/idle_heap.go/idle_slice.go/idle_ring_queue.go: Concrete implementations.histogram.go: Fixed-bucket sliding-window histogram for rate sampling. Used by scaler to compute median submit/consume/exit rates.spinlock.go: Three-phase spin lock implementingsync.Locker. Used formuIdlewhenWithLockType(SpinLock).stack_trace.go:Stack(skip)for panic recovery โ reads source files, so not for production hot paths.
Code Modification Notes
pendingTasksis atomic โ decremented inpool.done(), incremented on submit. It covers submitters blocked on the channel, giving the scaler full visibility.- Workers are pooled via
sync.Pool. Do NOTworkerPool.Put(w)when the worker is also inidleWorksโ that causes dual ownership and data races. - The scaler runs every
scalerPeriod(default 10ms). It reads median rates from histograms, computes target via Little's Law with backlog-weighted boosting. taskMuprotects the chunked buffer. Workers batch-pop up to 8 tasks per lock acquisition to amortize contention.- The spinlock does NOT call into the kernel โ optimal when hold times are <1ยตs (e.g., RingQueue index swaps). Use
MutexLockfor longer or unpredictable hold times.
Related Skills
Agent-Reach
102.9kGive your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu โ one CLI, zero API fees.
headroom
77.9kCompress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
Scrapling
89.8k๐ท๏ธ A Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev
crawl4ai
86.3kOpen-source web crawler and scraper for LLMs and AI agents: any website into clean, LLM-ready Markdown. Run it yourself, or use Crawl4AI Cloud with one key. Join our Discord https://discord.gg/VuxzM8mtf
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit โ see the Safety scan above for what the skill file itself contains.
