feat: implement signature caching to reduce CPU usage #422
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements a signature caching system to address the CPU bottleneck identified in pprof analysis where ring signature operations were consuming 50% of CPU time.
Problem
Solution
Implemented a comprehensive signature caching system with:
Key Components
1. Signature Cache Implementation
protocol/shannon/signature_cache.go: Core caching logicSessionID + SupplierAddr + AppAddr + PayloadHash2. Integration with Signer
protocol/shannon/signer.goto use cache3. Prometheus Metrics
shannon_signature_cache_hits_total: Cache hit countershannon_signature_cache_misses_total: Cache miss counter with reasonsshannon_signature_cache_size: Current cache size gaugeshannon_signature_cache_evictions_total: Eviction counter by reasonshannon_signature_cache_compute_time_seconds: Computation time histogram4. Comprehensive Testing
Memory Usage
Testing
Next Steps (Future PRs)
Review Notes
This is a draft PR for initial review. The implementation is complete and tested. We should monitor cache hit rates in production to determine actual effectiveness.