kuzzleio / kuzzle

Open-source Back-end, self-hostable & ready to use - Real-time, storage, advanced search - Web, Apps, Mobile, IoT -
https://kuzzle.io
Apache License 2.0
1.43k stars 123 forks source link

Kuzzle binary taking a lot of time for nothing #787

Closed ghost closed 7 years ago

ghost commented 7 years ago

Even with the help option, which should do nearly nothing, kuzzle binary takes several seconds to answer :

$ time bin/kuzzle reset --help
real    0m3.434s
ballinette commented 7 years ago

After a first analysis, it's the require command that takes time... Should try to refactor the command tool with best performance file inclusions...

samniisan commented 7 years ago

@ballinette More specificaly the require('../../lib/api/kuzzle') The cli doesn't use all the features of Kuzzle, should be able to export specific parts to the cli to improve performance

scottinet commented 7 years ago

It appears to be a bit more complicated.

I added some debug messages and activated all debug messages, including PM2.

Here is the log of bin/kuzzle --version:

  foobar registering createFirstAdmin +4ms
  pm2:paths pm2 home resolved to /root/.pm2 /root +543ms
  pm2:conf Using 2 parallelism (CONCURRENT_ACTIONS) +2ms
  pm2:client Using RPC file /root/.pm2/rpc.sock +113ms
  pm2:client Using PUB file /root/.pm2/pub.sock +0ms
  pm2:interface:daemon Getting interaction info +0ms
  pm2:interface:daemon [PING INTERACTOR] Trying to connect to Interactor daemon +1ms
  axon:sock connect attempt null:/root/.pm2/interactor.sock +0ms
  foobar registering clearCache +122ms
  foobar registering reset +2ms
  foobar registering shutdown +1ms
  foobar registering start +1ms
  foobar registering dump +1ms
  foobar parsing +1ms
  foobar done +1ms

I'm looking into this. I find it weird that PM2 client is started when running the CLI, there is no obvious call to it, even when instantiating a new Kuzzle instance.

scottinet commented 7 years ago

lol@pm2:

$ DEBUG='*' node
> const pm2 = require('pm2');
  pm2:paths pm2 home resolved to /root/.pm2 /root +0ms
  pm2:conf Using 2 parallelism (CONCURRENT_ACTIONS) +7ms
  pm2:client Using RPC file /root/.pm2/rpc.sock +134ms
  pm2:client Using PUB file /root/.pm2/pub.sock +0ms
  pm2:interface:daemon Getting interaction info +0ms
  pm2:interface:daemon [PING INTERACTOR] Trying to connect to Interactor daemon +1ms
  axon:sock connect attempt null:/root/.pm2/interactor.sock +0ms
undefined
>   axon:sock error ENOENT +5ms
  axon:sock ignored ENOENT +0ms
  axon:sock attempting reconnect +100ms
  axon:sock closing +1ms
  axon:sock closing 0 connections +0ms
  pm2:interface:daemon Interactor Daemon not launched +107ms
  axon:sock connect attempt null:/root/.pm2/interactor.sock +0ms
  axon:sock error ENOENT +1ms
  axon:sock ignored ENOENT +0ms

>