-
Notifications
You must be signed in to change notification settings - Fork 38.7k
tracing: network connection tracepoints #25832
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
tracing: network connection tracepoints #25832
Conversation
|
nice, utACK 7252c60
|
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/25832. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones: If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
Note to self: might be worth checking if we can also pass AS information and not only the net_group. |
7252c60 to
8528781
Compare
This is possible by accessing the CNodeStats, but don't think we should do that in the tracepoint. We have the IP and can lookup the AS in a tracing scirpt, if necessary. Fixed up the linter complains and rebased. This is ready for further review. |
|
Concept ACK |
8528781 to
ac438b1
Compare
ac438b1 to
6de4fc7
Compare
|
The linter started complaining about "E275 missing whitespace after keyword". Fixed this up in the individual commits. ac438b1 -> 6de4fc7 (2022-05-connection-tracepoints.pr.1 -> 2022-05-connection-tracepoints.pr.2; compare) |
|
ACK 6de4fc7 Code reviewed tracepoints, tests, and demo script. Tracepoint placement looks good, so do tests. Successfully ran functional tests and the demo script. Some points:
|
|
Using BIP155 network IDs is a good idea! Planning to address #25832 (comment) in a followup. |
|
|
|
I implemented both the BIP155 NetworkID approach (0xB10C@72133f3) and the Network as string approach from #25832 (comment) (0xB10C@39102d4). The BIP155 approach is a bit more involved with making The network name as string approach exposes NET_UNROUTABLE as I have a slight preference on BIP155 NetworkIDs over keeping-as-is or network name as string. |
Agree. Strings are sensitive to typos, and require extra effort for matching when doing statistics. i think even the current enumeration is better than that. BIP155 is a good suggestion, but as you have to make up non-standard values, and handle NET_UNROUTABLE differently i'm not entirely sure. The purpose of tracing is to gain insight into internal state so logging the actual values makes more sense than thinking up a new convention. The internal enumeration is likely stable enough to warrant being a (semi-)stable interface. |
Given that BIP155 network IDs are uint8_t's, I think it suffices to pick a value outside of that range for unreachable. For example, 0x100, or 0xffffffff for a Using 0 works too of course, and I guess it won't get assigned in future extensions, but using something outside of the range might be even more future-proof. |
I tend to agree. A few toughs:
Unless there are strong opinions on needing a follow up, I'll plan to leave this as is. |
| for closed_connection in closed_connections: | ||
| assert closed_connection.conn.id > 0 | ||
| assert_equal("inbound", closed_connection.conn.conn_type.decode('utf-8')) | ||
| assert_equal(0, closed_connection.conn.network) |
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.
This should have been
- assert_equal(0, closed_connection.conn.network)
+ assert_equal(NETWORK_TYPE_UNROUTABLE, closed_connection.conn.network)
This adds five new tracepoints with documentation and tests for network connections:
net:inbound_connectionandnet:outbound_connectionnet:closed_connnectionnet:evicted_inbound_connectionnet:misbehaving_connectionI've been using these tracepoints for a few months now to monitor connection lifetimes, re-connection frequency by IP and netgroup, misbehavior, peer discouragement, and eviction and more. Together with the two existing P2P message tracepoints they allow for a good overview of local P2P network activity. Also sort-of addresses #22006 (comment).
I've been back and forth on which arguments to include. For example,
net:evicted_connectioncould also include some of the eviction metrics like e.g.last_block_time,min_ping_time, ... but I've left them out for now. If wanted, this can be added here or in a follow-up. I've tried to minimize a potential performance impact by measuring executed instructions withgdbwhere possible (method described here). I don't think a few hundred extra instructions are too crucial, as connection opens/closes aren't too frequent (compared to e.g. P2P messages). Note: e.g.CreateNodeFromAcceptedSocket()usually executes between 80k and 90k instructions for each new inbound connection.Also added a bpftrace (tested with v0.14.1)
log_p2p_connections.btexample script that produces output similar to: