Skip to content

Conversation

@future-xy
Copy link
Member

This PR introduces better control over test result storage, visualization options, and fixes critical race conditions in the request handling system.

Changes

Enhanced CLI Options

  • Add --output-dir parameter to control where results are stored (defaults to tracestorm_results/{timestamp}/)
  • Add --plot flag to make visualization optional (off by default)
  • All results are now automatically saved as JSON in the configured directory

Improved Stability

  • Fix timeout handling in IPC queue collection by properly catching queue.Empty exceptions
  • Add an intelligent timeout recovery that continues collection if processes are still running
  • Refactor async dispatch loop to avoid busy-waiting and ensure clean shutdown
  • Add safety check to abort collection when all trace player subprocesses have terminated

Added Test Coverage

  • Added comprehensive tests for new CLI parameters and output directory handling
  • Added tests for the IPC queue timeout handling with multiple scenarios
  • Added tests for the improved asynchronous worker queue handling

Testing

  • All unit tests pass, including new tests for the modified components
  • Manual testing confirms successful result storage to custom and default directories
  • Verified timeout handling correctly continues waiting while processes are active
  • Confirmed plots are only generated when explicitly requested with --plot

These improvements make the system more robust when handling slow or unresponsive API endpoints, provide better control over where results are stored, and make plot generation optional to support automated testing environments.

…ispatch loop

- core: import and catch `queue.Empty` on `ipc_queue.get(timeout)`, log a warning on timeout and continue until subprocesses finish
- trace-player: replace `asyncio.wait_for(..., timeout=0.1)` with non‐blocking `get_nowait()`, catch `asyncio.QueueEmpty`, sleep briefly, and cleanly exit on shutdown flag
- introduce `--output-dir` option (defaults to `tracestorm_results/{timestamp}`) for customizable result storage
- add `--plot` flag (disabled by default) to control generation of performance plots
- ensure raw results JSON is always saved to the specified output directory
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the system’s robustness and usability by enhancing result handling, introducing new CLI options, and expanding test coverage. Key changes include:

  • Overhauled request dispatching in TracePlayer to eliminate busy-waiting and enable graceful shutdown.
  • Improved IPC queue timeout handling in run_load_test with enhanced logging.
  • Addition of new CLI options (--output-dir, --plot) and associated tests.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tracestorm/trace_player.py Refactored sender_worker and schedule_requests logic for better async flow
tracestorm/core.py Updated exception handling to improve timeout recovery in result collection
tracestorm/cli.py Added new CLI options for output directory and plotting, with directory setup
tests/test_replayer.py Introduced tests for sender_worker behavior under varying queue conditions
tests/test_cli.py Added tests validating the behavior of CLI options including custom output dir and plotting

- Added `--include-raw-results` flag to control whether raw results are saved
Copy link
Collaborator

@XuehengWang XuehengWang left a comment

Choose a reason for hiding this comment

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

I tried some tests and everything works

@future-xy future-xy merged commit f9e9468 into main May 21, 2025
2 checks passed
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.

3 participants