Performance and Caching

Performance and Caching

The data cache

Algolang caches downloaded market data locally in ~/.algolang/cache. The cache dramatically speeds up repeated backtests.

Cache management

# Show cache statistics
algo cache

# List cached entries
algo cache -l

# Flush specific entries
algo cache -F @ES*

# Flush all entries
algo cache -F

# Rebuild the cache index
algo cache -I

Parallel execution

Multi-symbol and multi-parameter runs are parallelised across CPU cores:

# Run with 8 parallel workers
algo run --strategy kbt --symbols <all --parallel 8

# Sequential execution (useful for debugging)
algo run --strategy kbt --symbols @ES --parallel 0

Shared bar data across strategies

When running multi-strategy configs (e.g., three strategies trading the same 65 symbols), Algolang automatically shares bar data across engines that use the same symbol with matching parameters. Instead of loading and mapping bar data 195 times (3 x 65), the data is loaded once per unique symbol+parameter combination and shared by reference across all strategy engines that need it.

This optimisation is transparent – no configuration is required. It applies to both main session bars and shadow bars (used for out-of-session order evaluation). The result is significantly reduced memory usage and faster startup times for multi-strategy configs.

Sharing occurs when strategies match on all of: symbol, bar interval, session hours, session days, timezone, bar building mode, and date range.

Test deduplication

During optimisation, Algolang automatically detects and skips parameter combinations that would produce identical results, reducing total test count.

Profiling

Generate CPU and heap profiles for performance analysis:

algo run --strategy kbt --symbols @ES --profile ./prof

This creates CPU and heap profile files that can be analysed with go tool pprof.