SinapsAI MCP server
Commit Nov 15, 2026A high-performance AI gateway for Node.js that provides a unified API, automatic failover, and semantic caching across multiple LLM providers.
Also known as roedyrustam/sinapsai
- Stars
- 5
- Tools
- —
- Downloads, 30 days
- —
- Latest version
- —
- Last commit
- Nov 15, 2026
- License
- MIT
What is SinapsAI MCP?
SinapsAI is a high-performance AI gateway for Node.js that provides a unified API, automatic failover, and semantic caching across multiple LLM providers.
Summary generated from the project's README
About SinapsAI MCP server
Developers building Node.js or TypeScript applications can manage multiple large language models through a single, standardized interface. This gateway acts as a local control plane that connects to providers like OpenAI, Anthropic Claude, Google Gemini, AWS Bedrock, and DeepSeek without requiring external proxy servers or Docker containers. Because it runs entirely in-process with zero runtime dependencies, it maintains extremely low latency overhead of less than 10ms.
Users can implement advanced orchestration features such as automatic multi-provider failover, round-robin load balancing, and lowest-cost routing. The system includes a built-in in-memory circuit breaker to handle provider outages and supports semantic caching to reduce redundant API calls. It also provides unified handling for multi-modal content, including vision and audio, and translates tool calling formats across different model specifications automatically.
What you can do with it
- 1Cost and Latency OptimizationRoute requests to the fastest or cheapest available provider based on real-time performance and pricing.
- 2Unified Tool CallingDefine function tools once and have them work across different model architectures like Anthropic and Gemini.
- 3Semantic Response CachingUse cosine similarity to serve cached responses for similar prompts to save on API costs.
Written from the project's README. Every use case is checked against a quote from it.
How to install SinapsAI MCP
Formats verified 10 Nov 2026Add to CursorAdd to GooseInstall SinapsAI MCP in Claude Code
$ claude mcp add sinapsai -- npx -y sinapsaiInstall SinapsAI MCP in Cursor
~/.cursor/mcp.json
{
"mcpServers": {
"sinapsai": {
"command": "npx",
"args": [
"-y",
"sinapsai"
]
}
}
}Install SinapsAI MCP in VS Code
.vscode/mcp.json
{
"servers": {
"sinapsai": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"sinapsai"
]
}
}
}Install SinapsAI MCP in VS Code CLI
$ code --add-mcp '{"name":"sinapsai","type":"stdio","command":"npx","args":["-y","sinapsai"]}'Install SinapsAI MCP in Claude Desktop
claude_desktop_config.json
{
"mcpServers": {
"sinapsai": {
"command": "npx",
"args": [
"-y",
"sinapsai"
]
}
}
}Install SinapsAI MCP in Codex
$ codex mcp add sinapsai -- npx -y sinapsaiInstall SinapsAI MCP in Codex config.toml
~/.codex/config.toml
[mcp_servers.sinapsai] command = "npx" args = ["-y", "sinapsai"]
Install SinapsAI MCP in Gemini CLI
$ gemini mcp add -s user sinapsai npx -- -y sinapsaiInstall SinapsAI MCP in Gemini settings.json
~/.gemini/settings.json
{
"mcpServers": {
"sinapsai": {
"command": "npx",
"args": [
"-y",
"sinapsai"
]
}
}
}Automated checks
Ran Nov 14, 2026Full report →Not verified yet. A server needs a score of 80, no serious finding, and enough data for us to check. How checks work · What to fix for more points
- Source repository linked and reachableroedyrustam/sinapsai is public and reachablegithub.com/roedyrustam/sinapsai ↗Pass
- Package names this repository as its sourcesinapsai names roedyrustam/sinapsai as sourcenpmjs.com/package/sinapsai ↗Pass
- Build provenance (Sigstore attestation)Sigstore attestation for sinapsainpmjs.com/package/sinapsai/v/3.3.0#provenance ↗Pass
- Open source license (OSI)MITspdx.org/licenses/MIT.html ↗Pass
- Commit or release in the last yearLast commit or release 2026-11-11github.com/roedyrustam/sinapsai ↗Pass
- OpenSSF ScorecardNot checked
- Package name not close to a popular packageNo popular package one edit away from sinapsaiPass
- No critical advisory in the package or its dependenciesNot checked
- No hidden instructions to the modelInstruction aimed at the model found in the description or READMEFinding
- Destructive tools are labelledNot checked
- Remote endpoint answers the MCP handshakeNot checked
README
View on GitHub⚡ SinapsAI
SinapsAI is a high-performance Local AI Control Plane & Unified Gateway built for Node.js, Edge Runtimes, and TypeScript. It bridges your applications with multiple LLM providers (OpenAI, Anthropic Claude, Google Gemini, AWS Bedrock, Azure OpenAI, DeepSeek, Mistral AI, Ollama, Groq, OpenRouter, xAI Grok, Cohere v2, and custom endpoints) through a single, standardized Unified API.
Engineered with a 100% in-process / in-memory architecture, SinapsAI eliminates downtime via automatic failover, load balancing, lowest-latency routing, and a resilient Circuit Breaker—without requiring intermediary proxy servers, external Redis dependencies, or adding measurable latency (<10ms overhead).
🤖 LLM / AI Agent Quick Ingest: If you are an AI assistant (ChatGPT, Claude, Gemini, Perplexity), autonomous agent, or coding assistant (Cursor, Copilot, Windsurf):
- Compact Roadmap: Read
llms.txtfor a high-density, concise summary of all features and standard imports.- Complete Context Specification: Read
llms-full.txtfor the exhaustive single-file reference document containing all TypeScript interfaces, provider configs, error codes, and 35 zero-slop examples.- In-Process Guarantee:
sinapsaiis 100% in-process with 0 runtime dependencies. It is NOT an external proxy server (no Docker/Python/Redis required).
🥊 Why SinapsAI?
Most AI gateways (LiteLLM, Portkey, Helicone) require deploying separate Docker containers, managing external Redis/PostgreSQL instances, or routing sensitive user prompts and API keys through external third-party cloud servers.
SinapsAI runs directly inside your Node.js application process:
| Feature | SinapsAI ⚡ | Direct Provider SDKs | Cloud Gateways (Portkey/Helicone) | LiteLLM Proxy |
|---|---|---|---|---|
| Zero Infra Setup (No Docker/Redis) | ✅ 100% In-Process | ✅ Yes | ❌ Requires Cloud Account | ❌ Requires Docker/Python |
| Added Latency | ⚡ <10ms | 0ms | ⚠️ +50ms to +250ms (Extra hop) | ⚠️ +20ms to +80ms |
| Data Privacy | 🔒 Zero Data Leakage | 🔒 Direct | ⚠️ Third-Party Gateway | 🔒 Self-hosted |
| In-Memory Circuit Breaker | ✅ Built-in | ❌ Manual code | ⚠️ Cloud feature | ⚠️ Basic retries |
| Automatic Multi-Provider Failover | ✅ Built-in | ❌ None | ✅ Yes | ✅ Yes |
| Lowest-Latency Auto-Routing | ✅ Built-in | ❌ None | ⚠️ Cloud feature | ⚠️ Custom setup |
| Lowest-Cost Auto-Routing | ✅ Built-in | ❌ None | ⚠️ Paid tier | ✅ Yes |
| Universal Frontier Reasoning | ✅ o1/o3/Claude/Gemini 4/Grok | ⚠️ Fragmented | ⚠️ Inconsistent | ⚠️ Partial |
| KV-Cache / Prompt Cache Tracking | ✅ Built-in (cachedPromptTokens) |
⚠️ Varies | ⚠️ Paid | ⚠️ Partial |
| TypeScript Native (Zero Runtime Deps) | ✅ Native fetch |
⚠️ Varies | ❌ Separate Service | ❌ Python |
📁 Looking for ready-to-run code? Check the Examples Directory (
/examples)!
📑 Table of Contents
- Why SinapsAI?
- Key Features
- Architecture & Request Flow
- Installation
- Quick Start
- 1. Client Initialization with Automatic Failover
- 2. Real-Time Streaming (SSE)
- 3. Round-Robin Load Balancing
- 4. Lowest-Cost Routing (Dual-Token Pricing)
- 5. Observability with Event Hooks & Rate Limiting
- 6. Real-Time In-Process Telemetry (getMetrics)
- 7. Retries with Exponential Backoff & Jitter
- 8. Exact & Semantic In-Process Response Caching
- 9. Tool Calling & Function Execution
- 10. Structured Outputs (JSON Mode)
- 11. Unified Text Embeddings
- 12. OpenRouter Free Tier & Zero-Cost Routing
- 13. Groq LPU Ultra-Fast Inference & Reasoning Integration
- 14. Hierarchical Model-Level Fallbacks
- 15. Universal Multi-Modal Vision & Audio (ContentPart[])
- 16. Concurrent In-Process Batch Processing (client.batch)
- 17. Vercel AI SDK Official Adapter (sinapsai/ai-sdk)
- 18. Distributed Storage Adapters (Cloudflare KV, Redis, D1)
- 19. Zero-Dependency In-Process PII Guardrails (PIIGuardrails)
- 20. Adaptive & Smart-Hybrid Dynamic Routing
- 21. Reversible PII Tokenization & Response Vault
- 22. Streaming Tool Call Accumulator & Reconstruction
- 23. Resilient Structured JSON Output Extraction
- 24. Virtual Model Aliases & Dynamic Mapping
- 25. Gateway Health Checks & Liveness Probes
- 26. Security Guardrails & Prompt Injection Defense
- 27. Dynamic Context Compression (ContextCompressor)
- 28. FinOps Budget Guardrails & Cost Limits
- 29. Speculative Hedged Requests (Tail-Latency Reduction)
- 30. In-Process Gateway Rate Limiting (RPM & TPM)
- 31. Prometheus & OpenTelemetry Metrics Exporters
- 32. In-Process Model Context Protocol (MCP) Tool Bridge & Agent Loop
- 33. Gemini Agent Booster, Streaming Agent Loop & Streaming Reversible PII Vault
- 34. Gemini Explicit Context Caching & Massively Parallel Tool Execution
- 35. In-Process Multi-Agent Swarm & Agent-to-Agent (A2A) Handoff Protocol
- 36. Universal LLM Optimization Engine (LLMO)
- 37. Active Canary Health Probing (Zero Tail-Latency Outage Evasion)
- 38. Standard Schema v1 & Zod Direct Resolver (createStructured)
- 39. Embedded Local Web UI & Telemetry Dashboard (sinapsai dashboard)
- 40. Hallucination & Faithfulness Sentinel (createGroundingVerified)
- 41. AWS Bedrock & Azure OpenAI Enterprise Cloud Providers
- 42. Steganography Firewall 2.0 & Hidden Injection Neutralization
- 43. Parallel Multi-Agent Swarm with Atomic Deep-Merge
- 44. Actor-Critic Self-Correcting Consensus Swarm Loop
- 45. Streaming Durable Workflows & Checkpoint Deletion (GDPR / UU PDP)
- 46. In-Process Semantic Prompt Router & Synthetic Dataset Distiller
- 🤖 AI & LLM Code Generation Guidelines
- Supported Providers
- Configuration Reference
- Development & Testing
- Contributing
- License
✨ Key Features
- 🌐 Unified API: Communicate seamlessly across different LLM providers using standard request/response structures aligned with the OpenAI Chat Completions specification.
- 🧠 Universal Frontier Reasoning Engine: Seamless control for deep thinking and Chain-of-Thought across Claude 3.7 Sonnet (
thinkingBudget), OpenAI o1/o3/o4 (reasoningEffort: 'low' | 'medium' | 'high'), Groq LPU, DeepSeek R1, and Gemini Flash Thinking, automatically surfaced inmessage.reasoning_content. - ⚡ Lowest-Latency Routing (
lowest-latency): Dynamically measures running moving-average latency and dispatches prompts to the fastest available LLM provider with zero cold-start lag. - 🎯 Hierarchical Model-Level Fallbacks: Intelligently fall back to secondary candidate models (e.g.,
gpt-4o->gpt-4o-mini) on the current provider before escalating to provider failover, complete with fast-failover on 401 Unauthorized. - 👁️ Universal Multi-Modal Content (
ContentPart[]): Unified vision and audio payload format (text,image_url,input_audio) natively mapped across OpenAI, Anthropic Claude, and Google Gemini. - ⚡ Zero-Dependency Semantic Caching: Pure in-process cosine similarity response caching using local or provider embeddings with configurable threshold (0.0 to 1.0) and zero native addons.
- 📊 Streaming TTFT & Mid-Stream Circuit Breaking: Millisecond-accurate Time-To-First-Token telemetry (
onStreamSuccess) and circuit breaker failure trapping against mid-stream connection drops while protecting client aborts. - 💰 KV-Cache & Prompt Caching Analytics: Real-time tracking of
cachedPromptTokensin responses andtotalCachedPromptTokensin metrics to audit and reduce API bills by 70-90%. - 🛠️ Universal Tool Calling & JSON Mode: Define tools once with standard JSON Schema (
tools,toolChoice). SinapsAI automatically translates function calls to Anthropic's XML/tool syntax, Gemini's function declarations, and OpenAI formats. - 🛡️ In-Memory Circuit Breaker: Detects provider outages instantaneously and trips (Open Circuit) to prevent cascading latencies and application thread blockage.
- 🔀 Flexible Routing Strategies:
adaptive/smart-hybrid: Dynamically scores and routes prompts to the healthiest, lowest-latency, and most cost-effective provider using a Laplace-smoothed reliability algorithm.failover: Automatically falls back to secondary providers when primary models fail or time out.lowest-latency: Dynamically sorts and sends requests to the fastest provider based on running average response latency.load-balance: Distributes requests in a round-robin rotation across multiple keys or endpoints to avert rate limiting (HTTP 429).lowest-cost: Dynamically sorts and invokes the most cost-effective provider using token pricing (costPer1kTokens& dual pricing).
- ⚡ Exponential Backoff & Retries: Automatically retries transient network errors and rate limits (429, 5xx) with random jitter before failing over.
- 💾 In-Memory Prompt Hash & Semantic Caching: Instant response caching with configurable TTL to avoid duplicate calls and slash inference costs.
- 🚀 Concurrent In-Process Batch Engine (
client.batch): Zero-dependency worker pool for high-throughput batch chat completions and embeddings with concurrency limits and live progress tracking. - 🌊 Native SSE Streaming: Stream completions in real time using native asynchronous generators (
for await...of). - 🔒 Zero Data Leakage & 100% Local: Runs strictly within your application's memory space. API keys and prompt payloads never leave your infrastructure.
- 🗜️ In-Process Context Compressor (
ContextCompressor): Zero-dependency heuristic token estimation and smart truncation (sliding-window&middle-out) with atomic tool-call group preservation. - 💳 FinOps Spend & Token Guardrails (
budget): Set strict hard caps (action: 'block') or soft alert thresholds (action: 'warn') for cumulative USD spend and token volumes. - ⏱️ Speculative Hedged Requests (
HedgedExecutor): Launch backup requests after a configured delay to eliminate tail latency (P99/P99.9) across redundant providers, aborting slower calls automatically. - 🪐 Extensible Frontier Providers: First-class integration for xAI Grok (with
reasoningEffort), Cohere v2 (Command A, Embed v4), Google Gemini (header auth, schema sanitization), Anthropic Claude, OpenAI, DeepSeek, and Groq. - 🐝 In-Process Multi-Agent Swarms & A2A Handoff Protocol (
client.swarm): Coordinate specialized domain agents with thread-safe shared context memory (SwarmContext), automated dynamic handoff tool generation (transfer_to_<agent_id>), ping-pong recursion protection (maxHandoffs), streaming real-time handoff events (runStream), and standard A2A Agent Card export (exportAgentCards()) conforming to/.well-known/agent.json. - ⚙️ Universal LLM Optimization Engine (
LlmOptimizer/ LLMO): Code-block preserving prompt token minification, system instruction deduplication, deterministic KV-cache prefix alignment, 3-tier complexity-based model cascading (tier1,tier2,tier3), dynamic reasoning allocation, and FinOps savings telemetry. - 🪝 Rich Event Hooks: Observe crucial gateway events (
onSuccess,onStreamSuccess,onFallback,onModelFallback,onSemanticCacheHit,onCircuitOpen,onCircuitClose,onRateLimit,onRetry,onSecurityViolation,onBudgetWarning) for APM metrics and custom alerting.
🏛️ Architecture & Request Flow
Your Application
│
▼
┌────────────────────────────────────────────────────────┐
│ SinapsClient │
│ chat.completions.create(request) │
└──────────────────────────┬─────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────┐
│ Router │
│ Strategy: 'failover' | 'load-balance' | 'lowest-cost' │
└──────────────────────────┬─────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────┐
│ CircuitBreaker │
│ Check State: [ CLOSED | OPEN | HALF_OPEN ] │
└──────────────────────────┬─────────────────────────────┘
│
┌───────────────┴───────────────┐
▼ ▼
[Circuit CLOSED] [Circuit OPEN]
Execute Request to Provider Bypass & Try Next Provider
│ │
┌─────┴─────┐ │
Success Failure │
│ │ ▼
▼ └──────────────► Automatic Fallback
Return Response (Triggers onFallback Hook)
📦 Installation
Install the package using your favorite package manager:
# Using NPM
npm install sinapsai
# Using PNPM
pnpm add sinapsai
# Using Yarn
yarn add sinapsai
# Using Bun
bun add sinapsai
🚀 Quick Start
1. Client Initialization with Automatic Failover
If the primary provider (e.g., OpenAI) is experiencing an outage or rate-limiting, SinapsAI automatically routes the request to secondary providers (Anthropic Claude or Google Gemini):
import {
SinapsClient,
OpenAiProvider,
AnthropicProvider,
GeminiProvider
} from 'sinapsai';
const client = new SinapsClient({
strategy: 'failover',
providers: [
new OpenAiProvider({ apiKey: process.env.OPENAI_API_KEY! }),
new AnthropicProvider({ apiKey: process.env.ANTHROPIC_API_KEY! }),
new GeminiProvider({ apiKey: process.env.GEMINI_API_KEY! }),
],
circuitBreaker: {
failureThreshold: 3, // Trip circuit after 3 consecutive failures
recoverySuccessThreshold: 2, // Restore circuit after 2 successful probe calls
resetTimeoutMs: 30000, // Wait 30s before testing recovery (Half-Open)
},
hooks: {
onFallback: (error, fromProvider, toProvider) => {
console.warn(`[Failover] ${fromProvider.name} failed (${error.message}). Switching to ${toProvider.name}...`);
},
onCircuitOpen: (provider) => {
console.error(`[Circuit Breaker] Circuit tripped OPEN for ${provider.name}.`);
},
},
});
async function main() {
const response = await client.chat.completions.create({
model: 'gpt-4o',
messages: [
{ role: 'system', content: 'You are a helpful and reliable AI assistant.' },
{ role: 'user', content: 'Explain distributed caching in two concise sentences.' },
],
temperature: 0.7,
});
if ('choices' in response) {
console.log('Response:', response.choices[0]?.message.content);
console.log('Token Usage:', response.usage);
}
}
main().catch(console.error);
2. Real-Time Streaming (SSE)
SinapsAI natively handles streaming through async iterators:
import { SinapsClient, OpenAiProvider } from 'sinapsai';
const client = new SinapsClient({
providers: [new OpenAiProvider({ apiKey: process.env.OPENAI_API_KEY! })],
});
async function streamDemo() {
const stream = await client.chat.completions.create({
model: 'gpt-4o-mini',
messages: [{ role: 'user', content: 'Write a short haiku about clean code.' }],
stream: true,
});
if (Symbol.asyncIterator in stream) {
for await (const chunk of stream) {
const text = chunk.choices[0]?.delta.content || '';
process.stdout.write(text);
}
console.log('\n--- Stream Complete ---');
}
}
streamDemo();
3. Round-Robin Load Balancing
Balance traffic across multiple API keys or accounts to prevent hitting individual rate limits:
import { SinapsClient, GroqProvider } from 'sinapsai';
const client = new SinapsClient({
strategy: 'load-balance',
providers: [
new GroqProvider({ id: 'groq-key-1', apiKey: process.env.GROQ_KEY_1! }),
new GroqProvider({ id: 'groq-key-2', apiKey: process.env.GROQ_KEY_2! }),
new GroqProvider({ id: 'groq-key-3', apiKey: process.env.GROQ_KEY_3! }),
],
});
4. Lowest-Cost Routing
Automatically execute through the most cost-efficient provider using dynamic dual-token pricing (promptCostPer1k and completionCostPer1k):
import { SinapsClient, OpenAiProvider, DeepSeekProvider } from 'sinapsai';
const client = new SinapsClient({
strategy: 'lowest-cost',
providers: [
new OpenAiProvider({
apiKey: process.env.OPENAI_API_KEY!,
promptCostPer1k: 0.0025, // $2.50 per 1M prompt tokens
completionCostPer1k: 0.010, // $10.00 per 1M completion tokens
}),
new DeepSeekProvider({
apiKey: process.env.DEEPSEEK_API_KEY!,
promptCostPer1k: 0.00027, // $0.27 per 1M prompt tokens
completionCostPer1k: 0.0011,// $1.10 per 1M completion tokens
}),
],
});
5. Observability with Event Hooks & Rate Limiting
Integrate lifecycle events with your telemetry and monitoring pipelines (Datadog, OpenTelemetry, Prometheus) and catch proactive rate limit warnings:
const client = new SinapsClient({
providers: [...],
hooks: {
onSuccess: (provider, response, latencyMs) => {
telemetry.recordSuccess(provider.name, latencyMs, response.usage?.totalTokens);
},
onStreamSuccess: (provider, ttftMs, totalLatencyMs) => {
telemetry.recordStreamLatency(provider.name, ttftMs, totalLatencyMs);
},
onModelFallback: (error, provider, fromModel, toModel) => {
console.warn(`[Model Fallback] ${provider.name} failed on ${fromModel}: ${error.message}. Switching to candidate model ${toModel}...`);
},
onSemanticCacheHit: (request, cachedResponse, similarity) => {
console.log(`[Semantic Cache Hit] ${(similarity * 100).toFixed(1)}% match for model ${cachedResponse.model}`);
},
onRateLimitWarning: (provider, rateLimit) => {
console.warn(`[Warning] Provider ${provider.name} capacity low! Remaining: ${rateLimit.remainingRequests}`);
},
onFallback: (error, fromProvider, toProvider) => {
telemetry.recordFallback(fromProvider.name, toProvider.name, error.message);
},
onCircuitOpen: (provider) => {
alertSystem.notify(`Circuit breaker tripped for provider: ${provider.name}`);
},
onCircuitClose: (provider) => {
alertSystem.notify(`Provider ${provider.name} has recovered to healthy state.`);
},
onRateLimit: (provider, error) => {
telemetry.recordRateLimit(provider.name);
},
onRetry: (provider, error, attempt, delayMs) => {
console.warn(`[Retry] Retrying ${provider.name} (attempt ${attempt}) after ${Math.round(delayMs)}ms...`);
},
},
});
6. Real-Time In-Process Telemetry (getMetrics)
Query cumulative runtime metrics anytime without external database dependencies:
const metrics = client.getMetrics();
console.log(`Total Requests: ${metrics.totalRequests}`);
console.log(`Successes: ${metrics.successfulRequests}`);
console.log(`Cached: ${metrics.cachedRequests}`);
console.log(`Total Tokens: ${metrics.totalTokens}`);
console.log(`Estimated Spend: $${metrics.estimatedCostUsd.toFixed(6)} USD`);
console.table(metrics.providerMetrics);
7. Retries with Exponential Backoff & Jitter
Configure per-provider or global retry attempts for transient server glitches (5xx, timeouts, 429) before falling over:
const client = new SinapsClient({
retries: 2, // Retry transient errors up to 2 times
retryDelayMs: 250, // Initial backoff delay (doubles each attempt + random jitter)
providers: [
new OpenAiProvider({ apiKey: process.env.OPENAI_API_KEY! }),
new AnthropicProvider({ apiKey: process.env.ANTHROPIC_API_KEY! }),
],
});
SinapsAI MCP questions
How do I add SinapsAI MCP to Claude Code?
Run claude mcp add sinapsai -- npx -y sinapsai in your terminal. Add --scope user to make it available in every project.
How do I add SinapsAI MCP to Cursor?
Open ~/.cursor/mcp.json and add the server under mcpServers, using the Cursor config shown in the install section above.
Which LLM providers are supported?
It supports OpenAI, Anthropic Claude, Google Gemini, AWS Bedrock, Azure OpenAI, DeepSeek, Mistral AI, Ollama, Groq, OpenRouter, xAI Grok, Cohere v2, and custom endpoints.
How much latency does SinapsAI add to requests?
The gateway is designed for high performance with less than 10ms of overhead.