Skip to content

Conversation

@neithanmo
Copy link
Collaborator

@neithanmo neithanmo commented Apr 27, 2025

This PR implements comprehensive profiling support for the indexer service to help identify performance bottlenecks.

Changes

  • Added embedded continuous profiling using pprof with feature flags profiling
  • Implemented Docker container support for profiling tools
  • Added Just commands for easy profiling management
  • Support for both embedded profiling and external tools:
    • Embedded pprof (continuous flamegraphs)
    • Valgrind (memory profiling)
    • Callgrind (CPU profiling)
    • Strace (system call tracing)

Why embedded profiler

  • Because local testnet relies on docker containers, some linux profiling tools do not work well when containerized
  • cargo flamegraph, ptrace did not work

as a result, embedding the profiler was the best option and it worked out of the box

Note

Profiler is disabled even during testing(unit and integration rust tests), because of a weird timing issue, it seems that spawning and setting up profiling threads caused issues with the test_thawing_deposit_process test. But this is still useful for end to end testing where it works just fine without huge side effects(as long as tests take into account the delay caused by the profiler during service startup).

Next step is to prepare a test to run services under heavy load and see how they behave and look for possible bottlenecks.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 27, 2025

Pull Request Test Coverage Report for Build 14718771698

Details

  • 0 of 161 (0.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-1.0%) to 73.05%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/tap-agent/src/main.rs 0 14 0.0%
crates/service/src/main.rs 0 17 0.0%
crates/profiler/src/lib.rs 0 130 0.0%
Totals Coverage Status
Change from base Build 14718391259: -1.0%
Covered Lines: 8766
Relevant Lines: 12000

💛 - Coveralls

@neithanmo neithanmo changed the title Feat/profiling Add Profiling Support for Indexer/tap-agent services Apr 27, 2025
@neithanmo neithanmo marked this pull request as ready for review April 27, 2025 22:58
suchapalaver
suchapalaver previously approved these changes Apr 28, 2025
Copy link
Collaborator

@suchapalaver suchapalaver left a comment

Choose a reason for hiding this comment

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

Awesome :)

…al tools

- Embedded continuous profiling using pprof in Rust code
- External tools: flamegraph, valgrind, callgrind, strace
- Docker support for all profiling methods
- Just commands for easy profiling management

Flamegraphs and profiles are saved to contrib/profiling/output.
Move duplicated profiling functionality from multiple crates into a single
shared 'profiler' crate.

Key changes:
- Create new 'profiler' crate with optimized implementation
- Use AtomicU64 instead of Mutex for snapshot counter
- Add proper error handling with thiserror
- Ensure proper directory structure for profiling output
- Make profiling opt-in via a feature flag
@neithanmo neithanmo merged commit efbf7fc into main Apr 28, 2025
10 checks passed
@neithanmo neithanmo deleted the feat/profiling branch April 28, 2025 23:04
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