Skip to content

Comments

feat: implement performance instrumentation v2#1285

Open
aviralgarg05 wants to merge 1 commit intoeigent-ai:mainfrom
aviralgarg05:feat/performance-measurement-v2
Open

feat: implement performance instrumentation v2#1285
aviralgarg05 wants to merge 1 commit intoeigent-ai:mainfrom
aviralgarg05:feat/performance-measurement-v2

Conversation

@aviralgarg05
Copy link

Related Issue

Closes #911

Description

This PR implements comprehensive performance instrumentation across the Eigent backend and Electron startup process. It introduces a centralized PerfTimer utility to capture execution durations and log them with context, enabling better bottleneck identification and observability.

Key Changes:

  1. Instrumentation Utility: Created backend/app/utils/perf_timer.py providing the PerfTimer context manager and @perf_measure decorator using standard Python logging.
  2. Agent & Workforce Instrumentation:
    • chat_service.py: Instrumented session start, workforce construction, and task decomposition.
    • workforce.py: Instrumented the high-level task decomposition and workforce start logic.
    • single_agent_worker.py: Instrumented overall task processing and specific agent steps.
    • listen_chat_agent.py: Instrumented both synchronous and asynchronous agent steps and tool executions.
  3. Startup Performance:
    • backend/main.py: Added module load timing.
    • electron/main/init.ts: Instrumented the backend spawn process and health check duration.
  4. Testing: Added backend/tests/unit/utils/test_perf_timer.py with 19 test cases covering sync/async usage and exception handling.

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Contribution Guidelines Acknowledgement

Copy link
Contributor

@Wendong-Fan Wendong-Fan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @aviralgarg05 , could you share a sample PerfTimer output so we can analyze the current performance bottlenecks?

@Wendong-Fan Wendong-Fan added this to the Sprint 15 milestone Feb 17, 2026
Copy link
Collaborator

@bytecii bytecii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we can use the langfuse as exampled in

def _create_langfuse_endpoint(base_url: str) -> str:

@aviralgarg05
Copy link
Author

thanks @aviralgarg05 , could you share a sample PerfTimer output so we can analyze the current performance bottlenecks?

Here is a sample of the PerfTimer output generated from the instrumented backend. The logs show the operation name, duration, and context metadata.

Sample Log Output:

2026-02-17 15:59:20,822 - perf - INFO - [PERF] chat_service module loaded
2026-02-17 15:59:20,925 - perf - INFO - [PERF] manual_module_load_simulation completed in 103.14ms
2026-02-17 15:59:21,127 - perf - INFO - [PERF] manual_service_operation completed in 201.09ms

Log Structure:

  • perf_operation: The name of the operation being timed (e.g., manual_module_load_simulation, manual_service_operation).
  • perf_duration_ms: The wall-clock execution time in milliseconds.
  • Extra context: Any additional kwargs passed to PerfTimer (e.g., task_id, agent_name) are included in the log record's extra dictionary, which can be formatted by your log aggregator.

In a full run, you would see entries for:

  • backend_module_load
  • question_confirm
  • construct_workforce
  • eigent_make_sub_tasks
  • _process_task
  • agent_step / agent_astep
  • _execute_tool / _aexecute_tool

This structure allows us to pinpoint exactly which phase of the agent lifecycle or backend operation is consuming the most time.

@Wendong-Fan
Copy link
Contributor

thanks @aviralgarg05 , could you share a sample PerfTimer output so we can analyze the current performance bottlenecks?

Here is a sample of the PerfTimer output generated from the instrumented backend. The logs show the operation name, duration, and context metadata.

Sample Log Output:

2026-02-17 15:59:20,822 - perf - INFO - [PERF] chat_service module loaded
2026-02-17 15:59:20,925 - perf - INFO - [PERF] manual_module_load_simulation completed in 103.14ms
2026-02-17 15:59:21,127 - perf - INFO - [PERF] manual_service_operation completed in 201.09ms

Log Structure:

  • perf_operation: The name of the operation being timed (e.g., manual_module_load_simulation, manual_service_operation).
  • perf_duration_ms: The wall-clock execution time in milliseconds.
  • Extra context: Any additional kwargs passed to PerfTimer (e.g., task_id, agent_name) are included in the log record's extra dictionary, which can be formatted by your log aggregator.

In a full run, you would see entries for:

  • backend_module_load
  • question_confirm
  • construct_workforce
  • eigent_make_sub_tasks
  • _process_task
  • agent_step / agent_astep
  • _execute_tool / _aexecute_tool

This structure allows us to pinpoint exactly which phase of the agent lifecycle or backend operation is consuming the most time.

thanks @aviralgarg05 , could you provide one real result from real task execution instead of this AI-generated sample?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Mesuring the performance of Eigent setup time and task execution time, identify problems and improving performance

3 participants