Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Measuring node main thread occupancy #6223

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

arafatkatze
Copy link
Collaborator

@arafatkatze arafatkatze commented Nov 29, 2024

Linear Issue

This pull request introduces a new feature to monitor the Node.js main thread occupancy within the VSCode extension. The feature aims to provide insights into the extension's performance by measuring CPU usage and emitting telemetry data.

Key Changes

  • ThreadOccupancyMonitor Class: A new class is added to measure the main thread's CPU usage at regular intervals. It calculates the occupancy percentage and maintains a rolling average. The ThreadOccupancyMonitor is initialized and started during the extension's activation process. It is also properly disposed of during deactivation to ensure clean resource management.

  • Proactive Alerts: Potential to set up alerts based on occupancy data to detect and address performance issues proactively.

Test plan

Tested in the Cody DEbugger that runs locally or you can use console.log to see the output of this
NOTE: This stuff is fairly straightforward so I assume I don't need any unit testing for this etc.

Changelog

}

private emitTelemetry(occupancy: number): void {
telemetryRecorder.recordEvent('cody.performance', 'threadOccupancy', {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@akalia25 Would doing something like this be acceptable from the frame of reference of the data team? Basically it will emit a telemetry event every 1 minute of usage. Is that something we can handle?

Copy link
Contributor

@akalia25 akalia25 Dec 2, 2024

Choose a reason for hiding this comment

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

Hey @arafatkatze, thanks for checking in with us! This could be a lot of events. When you say usage, is this active usage? Or does it still record when the IDE is idle?

It seems like this telemetry will be used for monitoring CPU usage (correct me if I'm wrong). I'd love to explore options on how we can limit this to ~1M events a day, if possible. :) ~ If this data is super important and will unlock a lot for us, let me know, and we can make it work with the current load.

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.

2 participants