Reduce MAX_SIZE in LogEscape to 100 #190

issue ismaelsadeeq openend this issue on July 17, 2025
  1. ismaelsadeeq commented at 5:09 pm on July 17, 2025: member

    Coming from https://github.com/bitcoin/bitcoin/pull/30437

    The original logs are overly verbose and difficult to read due to the large escaped binary blobs:

    02025-07-17T16:43:26Z [ipc] {bitcoin-mine-66147/53663537} IPC client recv BlockTemplate.getBlock$Results (result = "\\000\\000\\000 M\\207\\372Sq\\353$\\326\\373\\341!\\032\\256#\\234\\327Y\\347\\0253\\024\\rc\\351\\303V\\322p\\r\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000.(yh\\000\\005\\025\\035\\000\\000\\000\\000\\375\\b\\001\\002\\000\\000\\000\\000\\001\\001\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\377\\377\\377\\377\\005\\003\\274\\373\\003\\000\\376\\377\\377\\377\\002K\\215\\017\\225\\000\\000\\000\\000\\001Q\\000\\000\\000\\000\\000\\000\\000\\000&j$\\252!\\251\\355\\233\\276L$\\b\\277S\\037L\\230\\235\\216\\214\\226O\\226\\230\\220\\245\\224\\244\\315\\263\\232\\\\(F=\\021D\\376\\365\\001 \\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\...
    12025-07-17T16:44:24Z [ipc] {bitcoin-mine-66147/53663537} IPC client send BlockTemplate.getCoinbaseTx$Params (context = (thread = <external capability>, callbackThread = <external capability>))
    22025-07-17T16:44:24Z [ipc] {bitcoin-mine-66147/53663537} IPC client recv BlockTemplate.getCoinbaseTx$Results (result = "\\002\\000\\000\\000\\000\\001\\001\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\377\\377\\377\\377\\005\\003\\274\\373\\003\\000\\376\\377\\377\\377\\002K\\215\\017\\225\\000\\000\\000\\000\\001Q\\000\\000\\000\\000\\000\\000\\000\\000&j$\\252!\\251\\355\\233\\276L$\\b\\277S\\037L\\230\\235\\216\\214\\226O\\226\\230\\220\\245\\224\\244\\315\\263\\232\\\\(F=\\021D\\376\\365\\001 \\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\273\\373\\003\\000")
    32025-07-17T16:44:24Z [ipc] {bitcoin-mine-66147/53663537} IPC client send BlockTemplate.submitSolution$Params (context = (thread = <external capability>, callbackThread = <external capability>), version = 536870912, timestamp = 1752770606, nonce = 100305557, coinbase = "\\002\\000\\000\\000\\000\\001\\001\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\377\\377\\377\\377\\005\\003\\274\\373\\003\\000\\376\\377\\377\\377\\002K\\215\\017\\225\\000\\000\\000\\000\\001Q\\000\\000\\000\\000\\000\\000\\000\\000&j$\\252!\\251\\355\\233\\276L$\\b\\277S\\037L\\230\\235\\216\\214\\226O\\226\\230\\220\\245\\224\\244\\315\\263\\232\\\\(F=\\021D\\376\\365\\001 \\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\273\\373\\003\\000")
    

    To improve readability, it might be better to reduce MAX_SIZE from 1000 to 100 in the LogEscape function.

    The new logs after reducing MAX_SIZE is more readable.

     02025-07-17T17:06:18Z [ipc] {bitcoin-mine-67959/53683226} IPC client recv BlockTemplate.getBlock$Results (result = "\\000\\000\\000 \\n\\263:\\354z\\377\\020\\243AT\\322m>\\261\\255\\240)b\\r\\206\\027\\020...
     12025-07-17T17:06:30Z [ipc] {bitcoin-mine-67959/53683226} IPC client send BlockTemplate.getCoinbaseTx$Params (context = (thread = <external capability>, callbackThread = <external capability>))
     22025-07-17T17:06:30Z [ipc] {bitcoin-mine-67959/53683226} IPC client recv BlockTemplate.getCoinbaseTx$Results (result = "\\002\\000\\000\\000\\000\\001\\001\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000...
     32025-07-17T17:06:30Z [ipc] {bitcoin-mine-67959/53683226} IPC client send BlockTemplate.submitSolution$Params (context = (thread = <external capability>, callbackThread = <external capability>), version = 536870...
     42025-07-17T17:06:30Z [ipc] {bitcoin-mine-67959/53683226} IPC client recv BlockTemplate.submitSolution$Results (result = false)
     52025-07-17T17:06:30Z [ipc] {bitcoin-mine-67959/53683226} IPC client send Mining.getTip$Params (context = (thread = <external capability>, callbackThread = <external capability>))
     62025-07-17T17:06:30Z [ipc] {bitcoin-mine-67959/53683226} IPC client recv Mining.getTip$Results (result = (hash = "\\n\\263:\\354z\\377\\020\\243AT\\322m>\\261\\255\\240)b\\r\\206\\027\\020\\3754/\\...
     7Failed to mine a block in 9223372036854775807 iterations. Try again.
     82025-07-17T17:06:30Z [ipc] {bitcoin-mine-67959/53683226} IPC client destroy N2mp11ProxyClientIN3ipc5capnp8messages13BlockTemplateEEE
     92025-07-17T17:06:30Z [ipc] {bitcoin-mine-67959/53683226} IPC client send BlockTemplate.destroy$Params (context = (thread = <external capability>, callbackThread = <external capability>))
    102025-07-17T17:06:30Z [ipc] {bitcoin-mine-67959/53683226} IPC client recv BlockTemplate.destroy$Results ()
    112025-07-17T17:06:30Z [ipc] {bitcoin-mine-67959/53683226} IPC client destroy N2mp11ProxyClientIN3ipc5capnp8messages6MiningEEE
    122025-07-17T17:06:30Z [ipc] {bitcoin-mine-67959/53683226} IPC client destroy N2mp11ProxyClientIN3ipc5capnp8messages4InitEEE
    132025-07-17T17:06:30Z [ipc] {bitcoin-mine-67959/b-capnp-loop-53683227} EventLoop::loop done, cancelling event listeners.
    142025-07-17T17:06:30Z [ipc] {bitcoin-mine-67959/b-capnp-loop-53683227} EventLoop::loop by
    
  2. ryanofsky commented at 6:42 pm on July 24, 2025: collaborator

    Thanks! I agree we could reduce the length of these messages and maybe 100 characters could be sufficient. I also think the messages are logged at the wrong level in bitcoin core and LogDebug should probably be replaced by LogTrace.

    I do think longer log messages do tend to be useful when there are race conditions or other factors that make bugs difficult to reproduce, and having a full trace can give a clear picture of the steps leading up to the issue. Reducing the size could making debugging harder in these cases, but I’m ok with experimenting and seeing if 100 characters is any worse in practice.

    It would be nice if the size was configurable, too. This could be implemented by replacing the EventLoop::m_log_fn member:

    https://github.com/bitcoin-core/libmultiprocess/blob/a11e6905c238dc35a8bbef995190296bc6329d49/include/mp/proxy-io.h#L258-L259

    with LogOptions m_log where LogOptions is defined as something like:

    0struct LogOptions {
    1    //! External logging callback. 
    2    LogFn log_fn; 
    3
    4    //! Maximum number of characters to use when representing
    5    //! request and response structs as strings.
    6    int max_struct_chars{100};
    7};
    

    Would happily review PRs trying these things or changing logging other ways.

  3. ismaelsadeeq commented at 3:56 pm on September 2, 2025: member

    I took your suggestion and opened an initial PR for this #200

    I also think the messages are logged at the wrong level in bitcoin core and LogDebug should probably be replaced by LogTrace.

    I think Debug log level is fine, and would help in parsing C.I logs and figuring out the root cause of a failure?

    I do think longer log messages do tend to be useful when there are race conditions or other factors that make bugs difficult to reproduce, and having a full trace can give a clear picture of the steps leading up to the issue. Reducing the size could making debugging harder in these cases, but I’m ok with experimenting and seeing if 100 characters is any worse in practice.

    Fair in the PR I used 200 as the default instead.

  4. ryanofsky closed this on Sep 5, 2025

  5. fanquake referenced this in commit 72dce11864 on Sep 8, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/libmultiprocess. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-12-04 19:30 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me