-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replace jsonnet with go-jsonnet #144
Comments
can you explain about this problem statement? |
@mithil2311 We are currently using the direct Python library which uses the C++ version of jsonnet. To increase the speed of jsonnet compilation, we need to move to the Go version https://github.com/google/go-jsonnet and create Python bindings for it. |
(Jsonnet dev here) FYI basic C bindings for go-jsonnet are probably going to be merged soon (PR: google/go-jsonnet#257). The main missing part is the support for native functions. Other than that it's a drop-in replacement. My understanding is that the Python bindings just use C bindings internally, so no changes outside of |
HI @sbarzowski, Please excuse my lack of understanding. Could you kindly explain what you mean by
|
Sure. I meant that this function from the libjsonnet.h is not implemented yet in the bindings:
Native extensions are a feature which allows calling your own C function from Jsonnet - I can see that Kapitan uses it for a few functions (https://github.com/deepmind/kapitan/blob/master/kapitan/lib/kapitan.libjsonnet). The The other missing parts unrelated to native functions are evaluation variants Just to be clear, we definitely intend to have all of these implemented on |
@sbarzowski |
@yoshi-1224 Can I take this issue for SoC if you aren't planning to work on it full time? |
Hi @vaibhavk |
These have now been fixed google/go-jsonnet#322 google/go-jsonnet#323 |
@alldroll ctypes should work just fine - however the second approach is ideal, in which case, I agree that that it makes sense to add it to |
Hello, is there any progress on this front? The optimisations of go-jsonnet are badly needed in some contexts. |
Progress is being made and some bugs and issues are being found along the
way. Unfortunately at the moment I don't have a fully working version of it
yet.
…On Wed, Apr 8, 2020 at 5:18 PM francoisj ***@***.***> wrote:
Hello, is there any progress on this front? The optimisations of
go-jsonnet are badly needed in some contexts.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#144 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEFAADOUJOXLZSEW6AOAJLRLSPWRANCNFSM4FS5L3WQ>
.
|
if needed we can help. If you have some work in progress somewhere we can take a look at it. |
@ramaro We are trying to integrate gojsonnet with Kapitan, as we need it to improve our compile time (our usage of Kapitan is growing every weeks). Our work is available here. After some research, I deduce that these "deadlocks" are due to the way python handles multiprocessing by using Unfortunately, I didn't have time to do more investigation and I'm not sure if I'm on the right way (I'm begining in Python). EDIT: I am a teammate of @joulaud |
Hey @xunleii great to hear you're using Kapitan!
That pretty much sums my findings and I started working improving multiprocessing but ran into exactly the same issues, but unfortunately haven't finalised it yet. |
Could it have something to do with this: google/jsonnet#814? (It's not yet ported to go-jsonnet.) |
GIL handling was ported to go-jsonnet in last release |
Yes. Unfortunately, it seems we still have some elusive deadlock issues: google/go-jsonnet#484. I wasn't able to dig deeply enough into it yet. If anyone can share an idea about what that might be about, it will be really appreciated! |
When I took a stack-trace on the deadlock produced by @xunleii test-case above I find the exact same stack than in go-jsonnet ticket including Go After digging a little I was arriving to the same conclusion as @githubaccount888 on google/go-jsonnet#484 (comment). What are the real blockers to make this work? @xunleii you say there is some missing global variables in the spawn cases. Do you know what they are? Would it be difficult to add them to the "worker" closure created by "functools.partial" at https://github.com/deepmind/kapitan/blob/master/kapitan/targets.py#L101-L108 ? EDIT: typo s/being of/being a/ |
Unfortunately, I need to investigate another time to found them. |
I tried to advance on this once again. I just bypassed the whole multiprocessing thing in order to test with diff --git a/kapitan/targets.py b/kapitan/targets.py
index bb952b0..9d3adbd 100644
--- a/kapitan/targets.py
+++ b/kapitan/targets.py
@@ -123,7 +125,9 @@ def compile_targets(
# compile_target() returns None on success
# so p is only not None when raising an exception
- [p.get() for p in pool.imap_unordered(worker, target_objs) if p]
+ for x in target_objs:
+ worker(x)
os.makedirs(compile_path, exist_ok=True)
and it mostly works with a lot of performance improvements. On my test case target compilation itself is around 10 to 25 times faster with go-jsonnet than with cpp-jsonnet (my typical target takes around 5s to 20s with cpp-jsonnet and arount 0.10s to 0.80s with go-jsonnet). This means than even disabling multiprocessing when launching
This is not the case on single target compile as there seems to be some heavier startup time. Note: I have problem with the |
Hey @joulaud happy new year! I have very similar observations - disabling multiprocessing for compilation is actually faster and having it enabled hangs compilation when using I have committed my latest changes for go-jsonnet support at https://github.com/ramaro/kapitan/tree/gojsonnet Let me know if this works for you! |
Hi @ramaro! Thank you very much for this New Years gift. I have been using it for a week and it works pretty well. The compilation works much better than before (16s to 0.50s on average), without making any changes after compilation. EDIT: It's a misconfiguration on my side (I have both kapitan and for the largest one, I've used the "old" kapitan) |
I repeat the thanks to @ramaro This change is a life-saver for our daily workflow and we just migrated fully to your branch. What would be the next step to make this branch in state of being mergeable for next release of kapitan? |
@joulaud @uZer @xunleii hey apologies, I haven't been able to look at this further. I did spent sometime a few weeks ago on this and on my current infra (~140 jsonnet targets), kapitan with go-jsonnet seems to run out of memory. |
If you come across anything that can be reproduced with go-jsonnet (either the command or the Python bindings), please let me know! |
I did just try to compile 25 full kube-prometheus stacks and didn't notice any unbound increase in memory usage. The memory usage climb around 500MB in 4 or 5 runs and then remain at this level until end of compilation. This is with golang 1.16 and default gojsonnet release (pip install gojsonnet).
That would be a great way to let more people experiment with it. |
@ramaro It would be great to get the option to use go-jsonnet. I'm currently in the progress of adding kube-prometheus to our stack to replace the old prometheus install, but I'm not to happy about the 2 minute extra compile time. I tested it and it solves my issue at least. Can I help you by forking your branch and make it automatically import gojsonnet over jsonnet if available so we can get it merged and release? |
resolved by #753 |
No description provided.
The text was updated successfully, but these errors were encountered: