kcl-lang / kpm

KCL Package Manager
https://kcl-lang.io
Apache License 2.0
27 stars 44 forks source link

KCL drastically slows down when #328

Closed dennybaa closed 4 months ago

dennybaa commented 4 months ago

Hello @Peefy, seems I've run into an odd operational bug...

When kcl is invoked from a sub-directory sourcing the k file which hops over the module kcl.mod directory... It slows down drastically. Here's my scenario:

1) kcl.mod is at git root.
2) cd a/b/c jump into 3rd level

When on on the 3rd level:

time kcl -dY kcl.yaml ../../../bootstrap.k
hello:
  world: 1234
kcl -dY kcl.yaml ../../../bootstrap.k  0.09s user 0.03s system 1% cpu 9.267 total

Moving the same file but not reaching the root we get expected result:

hello:
  world: 1234
kcl -dY kcl.yaml ../../bootstrap.k  0.05s user 0.01s system 98% cpu 0.064 total

kcl starts doing networking, including querying DNS. This is clearly seen from strace. All this is not seen when we don't hop over the directory with the kcl.mod file...

Thank you!

dennybaa commented 4 months ago

probably should have opened the issue in https://github.com/kcl-lang/kcl ...

Peefy commented 4 months ago

Hello. Thanks for the feedback.

This is a known problem about this issue: https://github.com/kcl-lang/kpm/issues/324. This is due to the calculation of file hashing causing the runtime to slow down in the presence of kcl. mod and external dependencies. @zong-zhe is working on this to fix it https://github.com/kcl-lang/kpm/pull/314