-
Notifications
You must be signed in to change notification settings - Fork 15
feat: add new tab to Node page with thread pool statistics #2599
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
Conversation
Co-authored-by: adameat <34044711+adameat@users.noreply.github.com>
Co-authored-by: adameat <34044711+adameat@users.noreply.github.com>
Co-authored-by: adameat <34044711+adameat@users.noreply.github.com>
I forgot to tell you, that we need to change parameters for backend call for handler "sysinfo" for node page - we need to add parameter fields_required=-1 - so it will return Threads information. |
There was a problem hiding this 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 implements a comprehensive Threads tab for the Node page that displays detailed thread pool statistics including CPU usage visualization and thread state distribution. The implementation provides a complete UI solution with proper API integration patterns ready for backend connection.
- Adds thread pool table with columns for pool name, thread count, CPU usage, page faults, and thread states
- Implements visual components for CPU usage progress bars and thread state distribution charts
- Integrates with RTK Query for data fetching with auto-refresh and error handling
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/types/api/threads.ts | Defines TypeScript interfaces for thread pool data structure |
src/store/reducers/node/node.ts | Adds RTK Query endpoint with mock data for threads API |
src/services/api/viewer.ts | Implements API method for fetching thread data |
src/containers/Node/i18n/en.json | Adds internationalization for threads tab |
src/containers/Node/Threads/ | Complete threads component implementation with visual bars |
src/containers/Node/NodePages.ts | Registers threads tab in node page configuration |
src/containers/Node/Node.tsx | Integrates threads component into node page routing |
THREADS_IMPLEMENTATION.md | Comprehensive documentation of the implementation |
Comments suppressed due to low confidence (1)
src/types/api/threads.ts:59
- The enum value W_WAKE conflicts with the existing W value on line 51. Consider using a different name like WAKEKILL to distinguish from the deprecated PAGING state.
W_WAKE = 'W',
src/store/reducers/node/node.ts
Outdated
// TODO: Transform the data to extract detailed thread information | ||
// For now, return mock data matching the issue requirements | ||
const mockThreadData = { | ||
Threads: [ | ||
{ | ||
Name: 'AwsEventLoop', | ||
Threads: 64, | ||
SystemUsage: 0, | ||
UserUsage: 0, | ||
MinorPageFaults: 0, | ||
MajorPageFaults: 0, | ||
States: {S: 64}, | ||
}, | ||
{ | ||
Name: 'klktmr.IC', | ||
Threads: 3, | ||
SystemUsage: 0.2917210162, | ||
UserUsage: 0.470575124, | ||
MinorPageFaults: 0, | ||
MajorPageFaults: 0, | ||
States: {R: 2, S: 1}, | ||
}, | ||
{ | ||
Name: 'klktmr.IO', | ||
Threads: 1, | ||
SystemUsage: 0.001333074062, | ||
UserUsage: 0.001333074062, | ||
MinorPageFaults: 0, | ||
MajorPageFaults: 0, | ||
States: {S: 1}, | ||
}, | ||
] as TThreadPoolInfo[], | ||
ResponseTime: data.ResponseTime, | ||
ResponseDuration: data.ResponseDuration, | ||
}; | ||
return {data: mockThreadData}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mock data implementation should be clearly marked as temporary. Consider adding a more prominent TODO comment or conditional flag to ensure this mock data is replaced during backend integration.
// TODO: Transform the data to extract detailed thread information | |
// For now, return mock data matching the issue requirements | |
const mockThreadData = { | |
Threads: [ | |
{ | |
Name: 'AwsEventLoop', | |
Threads: 64, | |
SystemUsage: 0, | |
UserUsage: 0, | |
MinorPageFaults: 0, | |
MajorPageFaults: 0, | |
States: {S: 64}, | |
}, | |
{ | |
Name: 'klktmr.IC', | |
Threads: 3, | |
SystemUsage: 0.2917210162, | |
UserUsage: 0.470575124, | |
MinorPageFaults: 0, | |
MajorPageFaults: 0, | |
States: {R: 2, S: 1}, | |
}, | |
{ | |
Name: 'klktmr.IO', | |
Threads: 1, | |
SystemUsage: 0.001333074062, | |
UserUsage: 0.001333074062, | |
MinorPageFaults: 0, | |
MajorPageFaults: 0, | |
States: {S: 1}, | |
}, | |
] as TThreadPoolInfo[], | |
ResponseTime: data.ResponseTime, | |
ResponseDuration: data.ResponseDuration, | |
}; | |
return {data: mockThreadData}; | |
// TODO: Replace mock data with actual backend data during integration | |
if (USE_MOCK_DATA) { | |
const mockThreadData = { | |
Threads: [ | |
{ | |
Name: 'AwsEventLoop', | |
Threads: 64, | |
SystemUsage: 0, | |
UserUsage: 0, | |
MinorPageFaults: 0, | |
MajorPageFaults: 0, | |
States: {S: 64}, | |
}, | |
{ | |
Name: 'klktmr.IC', | |
Threads: 3, | |
SystemUsage: 0.2917210162, | |
UserUsage: 0.470575124, | |
MinorPageFaults: 0, | |
MajorPageFaults: 0, | |
States: {R: 2, S: 1}, | |
}, | |
{ | |
Name: 'klktmr.IO', | |
Threads: 1, | |
SystemUsage: 0.001333074062, | |
UserUsage: 0.001333074062, | |
MinorPageFaults: 0, | |
MajorPageFaults: 0, | |
States: {S: 1}, | |
}, | |
] as TThreadPoolInfo[], | |
ResponseTime: data.ResponseTime, | |
ResponseDuration: data.ResponseDuration, | |
}; | |
return {data: mockThreadData}; | |
} | |
// Transform the data to extract detailed thread information | |
return {data}; |
Copilot uses AI. Check for mistakes.
src/services/api/viewer.ts
Outdated
// TODO: This endpoint needs to be implemented in the YDB backend | ||
// For now, we'll use the existing sysinfo endpoint and extract thread data | ||
// In the future, this should be a dedicated /viewer/json/threads endpoint | ||
return this.get<TEvSystemStateResponse>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method returns TEvSystemStateResponse but should return TThreadPoolsResponse according to the expected threads data structure. This type mismatch will cause issues when real backend integration occurs.
Copilot uses AI. Check for mistakes.
if (totalUsage >= 1.0) { | ||
return 'danger'; | ||
} // 100% or more load | ||
if (totalUsage >= 0.8) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The magic numbers 1.0 and 0.8 should be extracted as named constants to improve maintainability and make the thresholds configurable.
if (totalUsage >= 1.0) { | |
return 'danger'; | |
} // 100% or more load | |
if (totalUsage >= 0.8) { | |
if (totalUsage >= MAX_LOAD_THRESHOLD) { | |
return 'danger'; | |
} // 100% or more load | |
if (totalUsage >= HIGH_LOAD_THRESHOLD) { |
Copilot uses AI. Check for mistakes.
Co-authored-by: adameat <34044711+adameat@users.noreply.github.com>
Updated the sysinfo API call to include
The threads component is ready to consume the real thread data once the backend returns it in the response. Commit: 9734099 |
Co-authored-by: adameat <34044711+adameat@users.noreply.github.com>
... Removed all mock data from the threads implementation. The API now always uses real backend data from the sysinfo response with |
please, fix and test with the real backend how it described in AGENTS.md file. |
- Remove duplicate getNodeThreads query that was calling the same API endpoint - Update Threads component to use existing getNodeInfo query data - Add Threads field to TSystemStateInfo interface to properly type the thread data - Threads tab now displays real backend data without duplicate API calls - Fixes both issues: no more duplicate sysinfo calls and threads data is properly displayed Co-authored-by: adameat <34044711+adameat@users.noreply.github.com>
... Fixed both issues:
The threads page now correctly displays real thread pool information from the YDB backend without any duplicate API calls. Tested with local YDB instance - all thread pools and their states are properly shown. Commit: 0020323 |
Stand
This PR implements a comprehensive Threads tab for the Node page in YDB Embedded UI, providing detailed thread pool information with visual representations of CPU usage and thread state distribution.
Features Added
Thread Pool Table
Visual Components
CpuUsageBar: Progress bar component with:
ThreadStatesBar: Thread state visualization with:
Technical Implementation
Files Added/Modified
New Components
src/containers/Node/Threads/Threads.tsx
- Main threads componentsrc/containers/Node/Threads/CpuUsageBar/
- CPU usage visualizationsrc/containers/Node/Threads/ThreadStatesBar/
- Thread states visualizationsrc/containers/Node/Threads/i18n/
- Internationalization supportsrc/types/api/threads.ts
- TypeScript type definitionsModified Files
src/containers/Node/Node.tsx
- Added threads tab supportsrc/containers/Node/NodePages.ts
- Added threads tab configurationsrc/containers/Node/i18n/en.json
- Added threads tab titlesrc/services/api/viewer.ts
- Added getNodeThreads API methodsrc/store/reducers/node/node.ts
- Added RTK Query endpointDocumentation
THREADS_IMPLEMENTATION.md
- Comprehensive implementation documentationBackend Integration Notes
The UI is complete and ready for backend integration. Currently uses mock data matching the expected format. The backend needs to provide detailed thread information through either:
/viewer/json/threads?node_id={nodeId}
/viewer/json/sysinfo
with detailed thread dataExpected data format:
Example Output
The implementation displays thread pool information as shown in the issue images:
Testing
Fixes #2051.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
CI Results
Test Status:⚠️ FLAKY
📊 Full Report
Test Changes Summary ⏭️2
⏭️ Skipped Tests (2)
Bundle Size: 🔺
Current: 85.26 MB | Main: 85.22 MB
Diff: +0.04 MB (0.04%)
ℹ️ CI Information