-
Notifications
You must be signed in to change notification settings - Fork 780
Description
Feature Request
Summary
Currently we spend lots of RAM allocation in Debug logs across votes. Here are some profiles of a query serving full node in its operation over 1-2 hours. We see:
addVote's StringShort calls taking 5GB of allocation (compared to the state machines total 48GB):

These are both debug line calls:
cometbft/internal/consensus/state.go
Line 2289 in d27732a
cs.Logger.Debug("added vote to last precommits", "last_commit", cs.LastCommit.StringShort()) cometbft/internal/consensus/state.go
Line 2378 in d27732a
cs.Logger.Debug("added vote to prevote", "vote", vote, "prevotes", prevotes.StringShort())
Peerstate.setHasVote taking 15.4GB, this is entirely in debug logging:
cometbft/internal/consensus/reactor.go
Lines 1444 to 1449 in d27732a
| ps.logger.Debug("setHasVote", | |
| "peerH/R", | |
| log.NewLazySprintf("%d/%d", ps.PRS.Height, ps.PRS.Round), | |
| "H/R", | |
| log.NewLazySprintf("%d/%d", height, round), | |
| "type", voteType, "index", index) |
Problem Definition
This is certainly adding notable load to the system, and its not even providing utility most of the time!
Proposal
I'm not sure what the most well abstracted way to do the logic for "if debug mode, run this log logic" is. Just wanted to point out that there is a lot were paying right now