-
Notifications
You must be signed in to change notification settings - Fork 613
[PERFORMANCE]: Remove exc_info=True from Plugin Manager critical path #2064
Copy link
Copy link
Labels
performancePerformance related itemsPerformance related itemspluginspythonPython / backend development (FastAPI)Python / backend development (FastAPI)
Milestone
Description
Summary
Critical Finding: The plugin framework spends ~80% of execution time formatting exception tracebacks that are never thrown or displayed.
Impact: For a typical plugin hook invocation taking 0.207ms:
- 0.165ms (80%) - Exception/traceback formatting
- 0.042ms (20%) - Actual plugin execution
Root Cause: exc_info=True in logger.error() calls within exception handlers in hot path.
Tasks
Remove exc_info=True (CRITICAL - 6.7x speedup)
Change in mcpgateway/plugins/framework/manager.py:
Before (Lines 284, 288):
logger.error("Plugin %s failed with error: %s", hook_ref.plugin_ref.name, str(pe), exc_info=True)
logger.error("Plugin %s failed with error: %s", hook_ref.plugin_ref.name, str(e), exc_info=True)After:
logger.error("Plugin %s failed with error: %s", hook_ref.plugin_ref.name, str(pe))
logger.error("Plugin %s failed with error: %s", hook_ref.plugin_ref.name, str(e))Rationale:
- Exception details are already in the error message via
str(pe)andstr(e) - Full traceback is rarely needed for plugin errors
- If traceback is needed, it can be enabled via logging configuration
- Removes 80% of execution overhead
Expected Impact:
- Reduce hook execution time from ~0.207ms to ~0.047ms (4.4x faster)
- Improve throughput from ~4,800 hooks/sec to ~21,000 hooks/sec
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
performancePerformance related itemsPerformance related itemspluginspythonPython / backend development (FastAPI)Python / backend development (FastAPI)