express-zod-api icon indicating copy to clipboard operation
express-zod-api copied to clipboard

Exp: Async logging

Open RobinTail opened this issue 9 months ago • 2 comments

This should be a major performance boost for the BuiltinLogger https://expressjs.com/en/advanced/best-practice-performance.html#do-logging-correctly

     name             hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · sync     248,537.46  0.0034  1.1198  0.0040  0.0037  0.0062  0.0078  0.0301  ±1.66%   124269
   · async  6,109,895.93  0.0001  1.0178  0.0002  0.0001  0.0020  0.0021  0.0026  ±0.83%  3055099   fastest

Problems:

  • maintaining queue ✅
    • setImmediate() seems to be doing it good enough, but:
  • purging the queue on termination ✅
    • using a proprietary stack and use setImmediate() only for printing from it
  • collaboration with a graceful shutdown ✅
    • modified installTerminationListener()
  • child loggers ✅
    • introducing a registry and the public dispose() method

RobinTail avatar Mar 27 '25 08:03 RobinTail

Coverage Status

coverage: 99.883% (-0.1%) from 100.0% when pulling 775b882d921d4851d82688a94f19b0f8b4a26228 on async-logger2 into 40822e65461e1bd429ba60bf2f1892e32dfd3c27 on master.

coveralls-official[bot] avatar Mar 27 '25 08:03 coveralls-official[bot]

this implementation does not make a dramatic difference, because the same thread is used for printing the same about of bytes to the sync stream of stdout. Instead, should try dedicated worker thread in another PR

RobinTail avatar Mar 29 '25 15:03 RobinTail