torrust-tracker
torrust-tracker copied to clipboard
Profiling for the UDP Tracker
Use valgrind and kcachegrind to do profiling of the UDP tracker.
We've implemented several torrent repository implementations but before continue improving further I would like to have some metrics.
The main function:
I've added a new binary for profiling. What I'm doing to profile is:
- Run the tracker for 60 seconds
- At the same time run the Aquatic UDP load test
The problem is we use threads and functions inside threads don't appear in the kcachegrind graphs. I have not been able to extract interesting conclusions from the report yet.
There are other alternatives for profiling async applications in Rust. There are some ideas in this talk by @bravit:
https://www.youtube.com/watch?v=8FAdY_0DpkM
Some alternatives are:
- Just print time in the code in the functions we want to profile.
- Use futures_diagnose, a crate to profile async functions.
- Use tokio-console, an application to monitor what happens inside tokio-spawned tasks.
I think I'm going to try option 1. I want to confirm that the main bottleneck is the torrust repository.
cc @da2ce7
Main function
Process valid request
Some potential conclusions (not sure)
From the graphs above it seems:
- 17.9% of the effective time processing a request is dedicated to allocating and freeing memory.
- 14.66% if for
entryandgetBTreeMap functions. - The cookie builder for connections takes 11.55% of the time processing requests probably due to the hash algorithm.
- It's strange that only 54.75% of the time if processing request :-/
I accidentally changed the number of active requests from 50 to 1000 while I was doing some tests with different parameters:
#[derive(Default)]
struct ActiveRequests {
rb: StaticRb<AbortHandle, 50>, // the number of requests we handle at the same time.
}
Zooming in on the part tho handle the announce request: