ACE_TAO icon indicating copy to clipboard operation
ACE_TAO copied to clipboard

Avoid allocating buffer when printing log.

Open likema opened this issue 5 years ago • 5 comments

likema avatar Feb 28 '19 06:02 likema

With small embedded systems couldn't this lead faster to a stack overflow?

jwillemsen avatar Feb 28 '19 11:02 jwillemsen

The size of verbose buffer on stack is VERBOSE_LEN + 1 = 129.

Is it too large for embedded systems?

/// Size used by verbose mode.
/// 20 (date) + 15 (host_name) + 10 (pid) + 10 (type)
///           + 4 (@) ... + ? (progname)
VERBOSE_LEN = 128,

likema avatar Feb 28 '19 11:02 likema

I now see that you replaced MAXVERBOSELOGMSGLEN with VERBOSE_LEN which is much smaller, was that the intent?

jwillemsen avatar Feb 28 '19 11:02 jwillemsen

Yes. I separate a line of log message into a prefix (verbose buffer) and content so that only prefix needs a small buffer on stack.

likema avatar Feb 28 '19 11:02 likema

I find that

/// Size used by verbose mode.
/// 20 (date) + 15 (host_name) + 10 (pid) + 10 (type)
///           + 4 (@) ... + ? (progname)
VERBOSE_LEN = 128,

progname is not formatted into verbose buffer on stack. So VERBOSE_LEN can be reduce to 20 + 15 + 10 + 10 + 4 = 59

Please see also:

  • https://github.com/DOCGroup/ACE_TAO/blob/9468af00a2e1863ef63cd9610d2c8b55452b716e/ACE/ace/Log_Record.cpp#L250-L252

  • https://github.com/DOCGroup/ACE_TAO/blob/9468af00a2e1863ef63cd9610d2c8b55452b716e/ACE/ace/Log_Record.cpp#L270-L278

Am I right?

likema avatar Feb 28 '19 11:02 likema