kernel: make btck_LogEntry opaque #36584

Manually merged
stickies-v merged 1 commit from 2026-10/kernel-logentry-opaque into master 2026-11-03 12:40:09 +00:00 AGit
stickies-v commented 2026-10-20 14:51:57 +00:00 (Migrated from github.com)

Makes btck_LogEntry an opaque type with btck_log_entry_get_* accessors, instead of a public struct. This allows adding or changing fields without breaking the ABI, and is consistent with ~all other kernel objects. Follow-up to https://github.com/bitcoin/bitcoin/pull/34374#discussion_r4207440088.

I added a benchmark in https://github.com/bitcoin/bitcoin/compare/master...stickies-v:bitcoin:2026-10/kernel-logentry-bench, and found that performance is not meaningfully impacted either way. Some results below.

Performance stats

Performance

Fields are now converted only when read, at the cost of a library call per field. The benchmark measures a kernel log statement up to and including the callback (Apple M4 Pro, static library, -O2, median of 2×25 interleaved runs):

Callback reads master PR Delta
no fields 57.4 ns 55.2 ns −1.6 to −2.5 ns
message only 57.8 ns 56.0 ns −1.4 to −2.0 ns
all 9 fields 57.9 ns 62.7 ns +4.8 to +5.4 ns

Break-even is at 2-3 fields. Either way, the difference is small next to the ~50 ns the log statement costs before the callback, and to what a consumer typically does with the entry (formatting, I/O).

Makes `btck_LogEntry` an opaque type with `btck_log_entry_get_*` accessors, instead of a public struct. This allows adding or changing fields without breaking the ABI, and is consistent with ~all other kernel objects. Follow-up to https://github.com/bitcoin/bitcoin/pull/34374#discussion_r4207440088. I added a benchmark in https://github.com/bitcoin/bitcoin/compare/master...stickies-v:bitcoin:2026-10/kernel-logentry-bench, and found that performance is not meaningfully impacted either way. Some results below. <details> <summary>Performance stats</summary> ### Performance Fields are now converted only when read, at the cost of a library call per field. The [benchmark](https://github.com/bitcoin/bitcoin/compare/master...stickies-v:bitcoin:2026-10/kernel-logentry-bench) measures a kernel log statement up to and including the callback (Apple M4 Pro, static library, `-O2`, median of 2×25 interleaved runs): | Callback reads | master | PR | Delta | |---|---:|---:|---:| | no fields | 57.4 ns | 55.2 ns | −1.6 to −2.5 ns | | message only | 57.8 ns | 56.0 ns | −1.4 to −2.0 ns | | all 9 fields | 57.9 ns | 62.7 ns | +4.8 to +5.4 ns | Break-even is at 2-3 fields. Either way, the difference is small next to the ~50 ns the log statement costs before the callback, and to what a consumer typically does with the entry (formatting, I/O). </details>
DrahtBot commented 2026-10-20 14:52:08 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK sedited, musaHaruna, pzafonte, nervana21

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #34775 (kernel: allow only one global logging connection by stickies-v)

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.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36584 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36584.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36584#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [sedited](https://github.com/bitcoin/bitcoin/pull/36584#pullrequestreview-5598238408), [musaHaruna](https://github.com/bitcoin/bitcoin/pull/36584#pullrequestreview-5598343723), [pzafonte](https://github.com/bitcoin/bitcoin/pull/36584#issuecomment-6567625368), [nervana21](https://github.com/bitcoin/bitcoin/pull/36584#issuecomment-6567951512) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#34775](https://github.com/bitcoin/bitcoin/pull/34775) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34775.svg"></sub> (kernel: allow only one global logging connection by stickies-v) 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. <!--5faf32d7da4f0f540f40219e4f7537a3-->
First-time contributor

Base: f86c614e69256b9814c27b0dd096ee46daa71aa3
Head: b2c077394a585a4155bd9d7a28b9b7c7553c9dc5

No verified findings are available from this review.

Review coverage was incomplete.

Review limitations
  • verifier: Model API request timed out.

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:0c398e5fd579cb8b00b6b62f2903ad741ac3f867996353a69082cd6ac57373b5:9d9e25a7349f2e108262b6ed44577d47304e975faf1917f1972defa0a828ae3d --> Base: `f86c614e69256b9814c27b0dd096ee46daa71aa3` Head: `b2c077394a585a4155bd9d7a28b9b7c7553c9dc5` No verified findings are available from this review. Review coverage was incomplete. <details> <summary>Review limitations</summary> - verifier: Model API request timed out. </details> [Full review report](<https://review.fish.foo/traces/36584-b2c077394a585a4155bd9d7a28b9b7c7553c9dc5-986-2.html>)
sedited (Migrated from github.com) approved these changes 2026-10-21 10:21:23 +00:00
sedited (Migrated from github.com) left a comment
ACK b2c077394a585a4155bd9d7a28b9b7c7553c9dc5
sedited (Migrated from github.com) commented 2026-10-21 10:21:12 +00:00

Might a one-line /// description be better for these trivial getters?

Might a one-line `///` description be better for these trivial getters?
stickies-v (Migrated from github.com) reviewed 2026-10-21 10:27:32 +00:00
stickies-v (Migrated from github.com) commented 2026-10-21 10:27:32 +00:00

I personally prefer the consistency of using doxygen docstrings for all public functions, but don't care too strongly either way, so happy to change if that's what people prefer. Will leave as-is until more people chime in.

I personally prefer the consistency of using doxygen docstrings for all public functions, but don't care too strongly either way, so happy to change if that's what people prefer. Will leave as-is until more people chime in.
musaHaruna (Migrated from github.com) reviewed 2026-10-21 10:31:07 +00:00
musaHaruna (Migrated from github.com) left a comment

Code Review ACK b2c0773

Tested locally, including calling all nine getters from the logging callback and checking the message, timestamp, source location, level, and category for the connection and disconnection messages.

Code Review ACK [b2c0773](https://github.com/bitcoin/bitcoin/pull/36584/changes/b2c077394a585a4155bd9d7a28b9b7c7553c9dc5) Tested locally, including calling all nine getters from the logging callback and checking the message, timestamp, source location, level, and category for the connection and disconnection messages.
pzafonte commented 2026-11-02 02:29:22 +00:00 (Migrated from github.com)

Code review and tested ACK b2c077394a

Code review and tested ACK b2c077394a585a4155bd9d7a28b9b7c7553c9dc5
nervana21 commented 2026-11-02 02:57:12 +00:00 (Migrated from github.com)

tACK b2c077394a

tACK b2c077394a585a4155bd9d7a28b9b7c7553c9dc5
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36584
No description provided.