Skip to content

Add TPS monitoring tool #2

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

Open
wants to merge 43 commits into
base: master
Choose a base branch
from

Conversation

Vsevolod-Rusinskiy
Copy link
Collaborator

@Vsevolod-Rusinskiy Vsevolod-Rusinskiy commented Jul 18, 2025

@Vsevolod-Rusinskiy Vsevolod-Rusinskiy requested a review from zotho July 21, 2025 08:06

showStats() {
const runtime = (Date.now() - this.startTime) / 1000
const avgBlockTime = this.calculateAverageBlockTime()
Copy link
Member

Choose a reason for hiding this comment

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

Why do we call calculateAverageBlockTime() second time?

Comment on lines 1 to 3
block,timestamp,total_transactions,our_transactions,total_tps,our_tps
28826,2025-07-18T12:01:20.631Z,0,0,0.00,0.00
28827,2025-07-18T12:01:20.717Z,0,0,0.00,0.00
Copy link
Member

Choose a reason for hiding this comment

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

Should we delete this file?

And zero TPS looks concerning. Is this usual results?

Comment on lines 81 to 83



Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

…ethod in TPSMonitor class by reusing pre-calculated average block time
- Split code into separate components
- Eliminate code duplication
- Fix calculateAverageBlockTime() performance issue
- Improve address tracking
- Rename src/orchestrator/ → src/dashboard/ for better clarity
- Update package.json scripts to use dashboard paths
- Update documentation with new naming convention
- Mark Phase 1 as completed (30% progress)
- Dashboard CLI commands working correctly
✨ New Features:
- Add Winston-based logging system (src/shared/logger.js)
- Multiple transports: files + console with colors
- Log levels: error, warn, info, debug, trace
- File rotation: 5MB max, separate files per module
- Backwards compatible: logger.log() works like console.log()

🔄 Migrations:
- Replace 5 console.log in api-connector.js with structured logging
- Update utils.js logAddressList() with optional logger parameter
- Keep backwards compatibility for existing code

✅ Verified:
- Monitor CLI works correctly
- Sender CLI works correctly
- No breaking changes to core functionality

Phase 3a: Shared modules logging migration complete
Next: Phase 3b (monitor modules) or Phase 3c (sender modules)
Phase 3b progress: Core modules migration complete
- tps-calculator.js: 5 console.log → Winston with structured data
- csv-exporter.js: 1 console.log → Winston with metadata
- index.js: 6 console.log → Winston with context data

Improvements:
- Added structured metadata for better log analysis
- Created child loggers for module separation
- Enhanced error reporting with stack traces
- Maintained backwards compatibility

Verified: Both monitor and sender CLI working correctly
Next: statistics-reporter.js and block-analyzer.js migration
Phase 3b progress: Statistics Reporter complete
- statistics-reporter.js: 33 console.log → Winston structured logging
- Consolidated multiple console.log calls into single structured events
- Added comprehensive metadata for all log events
- Enhanced initialization, block processing, and statistics reporting
- Integrated with Utils.logAddressList for address tracking

Key improvements:
- Structured data for TUI dashboard consumption
- Better error context and debugging information
- Reduced log noise while preserving all information
- Prepared for real-time log aggregation

Remaining: block-analyzer.js (26 logs) to complete Phase 3b
- Migrated all 71 console.log statements to Winston structured logging
- Eliminated logging duplication in block-analyzer.js
- Added comprehensive metadata for TUI dashboard integration
- All monitor functionality preserved and tested
- Migrated all 43 console.log statements to Winston structured logging
- Added comprehensive metadata for transaction lifecycle tracking
- All sender functionality preserved and enhanced for TUI integration
- Change maxsize from 5242880 to 20971520 (5MB -> 20MB)
- Reduce maxFiles to 2 for better disk space management
- Allow longer testing sessions without log rotation issues
Copy link
Member

@khssnv khssnv left a comment

Choose a reason for hiding this comment

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

Please apply some auto formatting to add new line in the end of files.


*.log
.DS_Store
package-lock.json
Copy link
Member

Choose a reason for hiding this comment

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

Why?


## 🔧 Requirements

- Node.js >= 16.0.0
Copy link
Member

Choose a reason for hiding this comment

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

Please add .nvmrc.

Comment on lines 168 to 177
## 📈 Gradual Load Increase

```bash
# Start with low load
node src/transaction_sender.js -n ws://localhost:9944 -s "//Alice" --rate 1

# In interactive mode, gradually increase:
# 1 → 5 → 10 → 20 → 50...
# Until you find the bottleneck
```
Copy link
Member

Choose a reason for hiding this comment

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

Cool! Does it detect saturation and stop increasing the send rate?

Copy link
Member

Choose a reason for hiding this comment

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

I didn't find this in the source code by the way.

@@ -0,0 +1,39 @@
{
"name": "tps-real",
"version": "1.0.0",
Copy link
Member

Choose a reason for hiding this comment

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

0.1.0?

.name('tps_monitor')
.description('TPS monitor for blockchain')
.version('1.0.0')
.option('-n, --node <url>', 'Node URL', 'ws://localhost:9944')
Copy link
Member

Choose a reason for hiding this comment

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

--ws please instead of -n, --node.

}

// Initialize all components
async initialize(nodeUrl, senderSeed, recipientSeed, amount, rate) {
Copy link
Member

Choose a reason for hiding this comment

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

Not necessary for this version, but in some future version this can utilize dependency injection accepting already configured ApiConnector, KeyringManager, RateController.


async startMonitoring() {
this.unsubscribe = await this.apiConnector.subscribeNewHeads((header) => {
this.processNewBlock(header.hash)
Copy link
Member

Choose a reason for hiding this comment

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

Does this work with 100ms block time without an explicit sequencing? If not this may put the block to the queue and process the queue later utilizing producer-consumer approach.


// Update timing for TPS calculations
const currentTime = Date.now()
this.tpsCalculator.addBlockTime(currentTime)
Copy link
Member

Choose a reason for hiding this comment

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

True block time is available in the pallet-timestamp state.

- Introduced file logging for console.log and console.error to capture logs in debug.log
- Enhanced logging functionality to improve debugging and monitoring capabilities
- Added console.warn logging to the existing file-based logging system
- Enhanced logging capabilities for better monitoring and debugging
… with a placeholder

- Removed the general update loop for rendering in TUIDashboard
- Updated TPSGraphComponent to return a placeholder message indicating the graph is temporarily disabled for debugging
- Implemented memory usage logging every 5 seconds to monitor RSS and heap memory
- Added cleanup for memory logging interval in the destroy method to prevent memory leaks
…lity

- Changed comments in index.js and event-log.js to improve clarity and consistency
- Updated language from Russian to English for better understanding
- Updated main entry point to "src/simple-monitor.js"
- Removed unnecessary dashboard-related files and components to streamline the project
- Simplified package.json by removing unused dependencies and scripts
- Updated package.json to replace 'monitor' and 'sender' scripts with 'start'
- Deleted unnecessary files related to transaction sending and monitoring to streamline the project
- Added docs/problem-analysis.md with comprehensive analysis of legacy script issues and solutions
- Added 'git/' to .gitignore to prevent tracking of git-related files in the repository
- Removed unused 'simple' script from package.json to streamline scripts
- Updated README to reflect changes in tool functionality and usage instructions
- Translated features and usage sections to Russian for better accessibility
…enhance README content

- Changed author name to "Simple TPS Monitor Team" and updated license to "UNLICENSED" in package.json
- Translated README content to English for broader accessibility
- Improved clarity and consistency in usage instructions and features section
…or load testing

- Changed main entry point to "src/index.js" in package.json
- Added new scripts for load testing: "sub-flood" and "build"
- Updated dependencies and devDependencies in package.json and package-lock.json
- Enhanced error handling in load-testing/index.ts by specifying error type
…ckage-lock.json

- Removed unused 'ts-node' dependency from package.json and package-lock.json
- Updated versions of several dependencies in package-lock.json for better compatibility
- Cleaned up package-lock.json by removing unnecessary entries to streamline the file
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