-
Notifications
You must be signed in to change notification settings - Fork 614
[BUG][PERFORMANCE]: Fix minor performance issues in llm-guard plugin #1961
Copy link
Copy link
Labels
SHOULDP2: Important but not vital; high-value items that are not crucial for the immediate releaseP2: Important but not vital; high-value items that are not crucial for the immediate releasebugSomething isn't workingSomething isn't workingperformancePerformance related itemsPerformance related itemspluginsreadyValidated, ready-to-work-on itemsValidated, ready-to-work-on items
Milestone
Description
🐞 Bug Summary
The LLM-Guard plugin has minor performance issues that contribute to overall latency. These are lower priority than #1960 but should be addressed for optimal performance.
🧩 Affected Component
-
mcpgateway- API -
mcpgateway- UI (admin panel) -
mcpgateway.wrapper- stdio wrapper - Federation or Transports
- CLI, Makefiles, or shell scripts
- Container setup (Docker/Podman/Compose)
- Other:
plugins/llm-guard
🔍 Performance Issues Identified
| Issue | Impact | Priority |
|---|---|---|
| Eager scanner initialization | Slow startup | P3 |
| Excessive logging overhead | I/O per request | P3 |
| Vault retrieval not optimized | Extra DB queries | P3 |
| Generic error handling | Poor debuggability | P4 |
| Missing metrics | No observability | P4 |
📋 Tasks
-
Lazy scanner initialization
- Initialize scanners on first use, not plugin load
- Implement scanner pool for reuse
- Add initialization timing metrics
-
Reduce logging overhead
- Use lazy log formatting
- Add log level guards
- Batch debug logs where possible
-
Optimize vault retrieval
- Cache vault lookups
- Batch vault queries
- Add vault cache invalidation on updates
-
Improve error handling specificity
- Add specific exception types
- Include context in error messages
- Add error categorization for metrics
-
Add comprehensive metrics
- Scanner initialization time
- Per-scanner execution time
- Error rates by type
- Vault operation latency
🎯 Success Criteria
- Plugin startup time reduced by 30%
- Logging overhead < 1ms per request
- Vault cache hit rate > 90%
- All errors have actionable messages
- Metrics available in Prometheus format
🔗 Related Issues
- Related: [BUG][PERFORMANCE]: Fix high-impact performance issues in llm-guard plugin #1960 (High-impact performance issues in llm-guard)
- Consider merging with [BUG][PERFORMANCE]: Fix high-impact performance issues in llm-guard plugin #1960 if implementing together
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
SHOULDP2: Important but not vital; high-value items that are not crucial for the immediate releaseP2: Important but not vital; high-value items that are not crucial for the immediate releasebugSomething isn't workingSomething isn't workingperformancePerformance related itemsPerformance related itemspluginsreadyValidated, ready-to-work-on itemsValidated, ready-to-work-on items