express-zod-api
express-zod-api copied to clipboard
Exp: Async logging
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
- using a proprietary stack and use
- collaboration with a graceful shutdown ✅
- modified
installTerminationListener()
- modified
- child loggers ✅
- introducing a registry and the public
dispose()method
- introducing a registry and the public
coverage: 99.883% (-0.1%) from 100.0% when pulling 775b882d921d4851d82688a94f19b0f8b4a26228 on async-logger2 into 40822e65461e1bd429ba60bf2f1892e32dfd3c27 on master.
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