Skip to content

Make thread monitoring opt-in, harden ThreadMonitor, and remove sleep from async backoff handler#39

Open
Thunderrock424242 wants to merge 1 commit intomainfrom
codex/identify-performance-issues-with-mod
Open

Make thread monitoring opt-in, harden ThreadMonitor, and remove sleep from async backoff handler#39
Thunderrock424242 wants to merge 1 commit intomainfrom
codex/identify-performance-issues-with-mod

Conversation

@Thunderrock424242
Copy link
Copy Markdown
Owner

Motivation

  • Reduce noise and runtime overhead by making the thread monitor conditional on configuration and by avoiding needless sleeps in the async backoff path.
  • Improve robustness of the thread monitor so it won't spawn multiple instances and will stop cleanly on shutdown.

Description

  • Wrapped ThreadMonitor.startMonitoring() in NovaAPI with a guard based on NovaAPIConfig.isMemoryThreadLogsEnabled() so monitoring only starts when enabled.
  • Reworked ThreadMonitor to prevent multiple monitor instances, run the monitor thread as a daemon, handle interruptions cleanly, and stop via a running flag in stopMonitoring().
  • Optimized ThreadMonitor.logAllThreads() to use ThreadMXBean for a lightweight thread count and only gather per-thread stack traces when trace logging is enabled, and to respect NovaAPIConfig.isMemoryThreadLogsEnabled().
  • Enhanced deadlock detection in ThreadMonitor.checkForDeadlocks() using ThreadMXBean.findDeadlockedThreads() and improved logging of detected deadlocks.
  • Removed the 5ms Thread.sleep backoff from the callerRunsWithBackoff handler in AsyncTaskManager so caller-run fallback executes immediately without sleeping.

Testing

  • Ran ./gradlew test and ./gradlew build as the project automated checks, and the build and test suite completed successfully.
  • Verified the code compiles and the modified classes load in the test environment without runtime exceptions during startup.
  • Automated unit tests covering async executor behavior and thread utilities passed (no failures).

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c1cdc48c89

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +140 to +142
if (NovaAPIConfig.isMemoryThreadLogsEnabled()) {
ThreadMonitor.startMonitoring();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Start monitor when thread-log config is toggled on

Gating ThreadMonitor.startMonitoring() to server startup means enableMemoryThreadLogs can no longer be enabled dynamically: with the default false, the monitor thread never starts, and onConfigReload (same file) does not start it later, so thread/deadlock monitoring remains disabled until a full server restart. Before this change, the monitor was already running and the config flag took effect on the next cycle.

Useful? React with 👍 / 👎.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant