thomvaill / log4brains

✍️ Log and publish your architecture decisions (ADR)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CLI performance (long startup time) due to ESM

thomvaill opened this issue · comments

Bug Report

Description

For any call to the CLI, there is a constant startup time of ~3 sec, whatever the command is. Even a very simple one like log4brains --version.
After a quick debug, it looks like this is due to esm package we use to provide on-the-fly ESM imports capabilities.
My doubts are reinforced by this issue: standard-things/esm#844

Steps to reproduce

log4brains --version

Expected Behavior

log4brains --version (and the majority of other commands) should be instant.

Possible Solution

Either fix the esm package or get rid of it by compiling to commonJS all of our packages... (like the core one).

The problem is even more pronounced here (8+s, see below), making the tool almost unusable.
How much effort would it be to fix this? I unfortunately have only minimal JS/TS knowledge.

❯ time log4brains --version
1.0.0-beta.11
log4brains --version  8,42s user 0,60s system 139% cpu 6,460 total

❯ node --version
v16.15.0

❯ cat /etc/lsb-release     
  DISTRIB_ID=Ubuntu
  DISTRIB_RELEASE=20.04
  DISTRIB_CODENAME=focal
  DISTRIB_DESCRIPTION="Ubuntu 20.04.4 LTS"
  • Hardware: ryzen7 4800h, 32G RAM, M.2 SSD
  • nodejs installed as snap

The performance is terrible... This should be wicked fast as its not doing a lot... Any progress on this?

Note: The last commit on standard-things/esm was on 26 Sep 2019, so I'm quite pessimistic that esm will be fixed any time soon.