snet-cli icon indicating copy to clipboard operation
snet-cli copied to clipboard

snet-cli is slow. Is it an issue?

Open astroseger opened this issue 6 years ago • 7 comments

In the current stage snet-cli adds ~1-0.7 sec overhead to each operation. for example:

time snet version

Should we consider it as a problem?

astroseger avatar Dec 05 '18 12:12 astroseger

IMO for this kind of tool it is ok. The web3 module by itself is heavy to be loaded.

arturgontijo avatar Dec 05 '18 12:12 arturgontijo

If we start use snet-cli as a basis for SDK it might be a problem, and there are different possible solutions...

astroseger avatar Dec 05 '18 13:12 astroseger

For example it is an issue for #108. We need to optimize "imports"...

astroseger avatar Dec 07 '18 09:12 astroseger

Agree. Maybe a good approach will be isolate functions that don't need web3 module in separated files. I'm not a fan of "import on demand", but it's a valid way to go too.

arturgontijo avatar Dec 07 '18 10:12 arturgontijo

This is particularly noticeable on lower power devices like raspberry pi:

$ time snet version
    version: 0.2.10


real	0m29.143s
user	0m27.907s
sys	0m1.162s

(Python shell starts relatively quickly and takes 0.5s to run a statement so it's not just python start up time.)

ferrouswheel avatar Mar 26 '19 01:03 ferrouswheel

@ferrouswheel yes. I guess (but it should be studied) the main problem is in relatively "heavy" libraries (as web3) which we use, so it simply takes time to import them.

What exactly would you like to do on raspberry pi? Only make a call?

astroseger avatar Mar 26 '19 08:03 astroseger

@astroseger Yeah just making calls, but still need to do the various setup calls for identity and channels.

I want to demonstrate our tooling works with raspberry pi and low-powered devices that can be used for IoT (or at least find out what hurdles there are!). More realistically I guess people would probably use the sdk, but it'd be nice if the commands only imported the libraries they needed, then local config and other things that don't need web3 would run faster.

If we did use conditional imports, then it'd be good to do imports after parsing command line arguments. That way if someone uses the wrong arguments they will get feedback immediately.

ferrouswheel avatar Mar 26 '19 21:03 ferrouswheel