babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
2020-11-12T10:17:28.280200Z

Hi babashkackerz ! On the README, I read "Interop with commonly used classes (System, File, java.time., java.nio.)", so apart from these Java classes we can't use any other like org.freedesktop.dbus.DBusInterface for example, right?

borkdude 2020-11-12T10:18:27.281Z

That is correct, unless it is explicitly added in the babashka binary

👍 1
2020-11-12T10:19:30.281500Z

I was wondering if we could do without Python for this kind of script for example. http://blog.muhuk.com/2015/09/09/displaying_clojure_test_results_in_taskbar.html

#!/usr/bin/env python

import dbus
import sys


def notify(summary, body='', app_name='', app_icon='',
        timeout=5000, actions=[], hints=[], replaces_id=0):
    _bus_name = 'org.freedesktop.Notifications'
    _object_path = '/org/freedesktop/Notifications'
    _interface_name = _bus_name

    session_bus = dbus.SessionBus()
    obj = session_bus.get_object(_bus_name, _object_path)
    interface = dbus.Interface(obj, _interface_name)
    interface.Notify(app_name, replaces_id, app_icon,
            summary, body, actions, hints, timeout)


if __name__ == '__main__':
    notify(*sys.argv[1:])

2020-11-12T10:20:08.282300Z

Thank you for confirmation @borkdude

borkdude 2020-11-12T10:21:07.283300Z

@admin055 The ways to interact with classes not inside babashka are currently: - shelling out to another CLI that can do it - via a pod that is designed for this use case (which is also kind of a CLI but nicer integration code-wise)

borkdude 2020-11-12T10:25:01.284200Z

@admin055 So if this is a frequent use case, you could invest in building a pod for it

2020-11-12T10:27:24.284800Z

Yes pods are excellent feature, I had toying a little bit with pod-jaydeesimon-jsoup and it was nice ! I also plan to take some time soon to install the Graalvm toolchains and attempt to contribute with pods etc.

borkdude 2020-11-12T10:28:11.284900Z

Maybe this also works: http://www.kaizou.org/2014/06/dbus-command-line.html

2020-11-12T10:30:00.285100Z

@borkdude Yes I will. Thanks the CLI solution could a simplified first approach, thanks for the tip.

borkdude 2020-11-12T10:35:15.287200Z

I want to simplify installing pods so you can put some config in a babashka.edn and the pod will be automatically downloaded and resolved by babashka.pods/load-pod (or maybe (babashka.pods/require 'foo.bar) since a pod management system could also list which namespaces belong to which pods). I hope that this will improve the adoption of pods. I already made something like this: https://github.com/borkdude/glam, but I think I will make something specific for pods in babashka to download the pods into a cache, etc.

2020-11-12T10:38:00.288100Z

Yeah, great idea! 👍

Jakub HolĂ˝ 2020-11-12T11:27:53.289400Z

@borkdude docker build --target BASE -t bb-builder . on the latest master fails for me during RUN ./script/uberjar due to > Retrieving borkdude/sci.impl.reflector/0.0.1-java11/sci.impl.reflector-0.0.1-java11.jar from clojars > OpenJDK 64-Bit Server VM warning: forcing TieredStopAtLevel to full optimization because JVMCI is enabled > Syntax error (ClassNotFoundException) compiling at (/tmp/form-init12305127242809915869.clj:1:74). > org.yaml.snakeyaml.error.YAMLException > ... > Error encountered performing task 'do' with profile(s): 'base,system,user,provided,dev,transit,reflection' Building outside docker seems OK. Any idea why / how to fix or troubleshoot? Is BABASHKA_FEATURE_YAML actually required?

borkdude 2020-11-12T11:29:07.290800Z

This seems an error related to the feature flag. It will only try to load the yaml class if BABASHKA_FEATURE_YAML=true, or at least, it should.

Jakub HolĂ˝ 2020-11-12T11:29:08.290900Z

I should mentioned I changed Dockerfile, setting all BABASHKA_FEATURE_* to false

borkdude 2020-11-12T11:29:50.291600Z

@holyjak You can use BABASHKA_LEAN to accomplish the same thing. But you should set the flag for both the uberjar and compilation step

Jakub HolĂ˝ 2020-11-12T11:33:20.292300Z

OK, thanks! BTW I have noticed https://github.com/borkdude/babashka/blob/master/script/compile#L73 includes most features but datascript and lanterna., Is that intentional or a mistake?

borkdude 2020-11-12T11:34:00.292700Z

lanterna and datascript aren't enabled by default, so they are already set to false

borkdude 2020-11-12T11:36:16.293900Z

Btw, the Github action JVM tests aren't working anymore, while everything on CircleCI works flawlessly. My experience with Github actions so far has been that it can be pretty flakey... If someone knows a solution, I'm open to suggestions.

Jakub HolĂ˝ 2020-11-12T11:36:59.294400Z

But the same is true for JDBC and postgres yet they are on the list 🙂

borkdude 2020-11-12T11:37:33.295600Z

That's probably because postgres and JDBC were part of babashka during one release, but I removed it in the next release

👍 1
Jakub HolĂ˝ 2020-11-12T11:38:34.296800Z

What if I want to build bb as lean as possible but with some selected features (namely csv, jdbc, oracle)? Then I cannot use LEAN. I could set all the other default features to false but then I will run into the problem ☝️ that yaml somehow is required anyway... But it is no big deal, I suppose they do not add that much to the size anyway.

borkdude 2020-11-12T11:39:58.297200Z

@holyjak That is a bug which I cannot reproduce locally

borkdude 2020-11-12T11:40:33.297600Z

We could make LEAN take into account variables that are set explicitly

borkdude 2020-11-12T11:40:41.297900Z

I'm open for suggestions and PRs in this area

👍 1
borkdude 2020-11-12T11:41:15.298500Z

I'm also considering moving to the clojure CLI for compilation at one point, but that takes some refactoring to aliases for features

Jakub HolĂ˝ 2020-11-12T11:42:18.298600Z

I added

ENV BABASHKA_FEATURE_CORE_ASYNC=false
ENV BABASHKA_FEATURE_CSV=false
ENV BABASHKA_FEATURE_JAVA_NIO=false
ENV BABASHKA_FEATURE_JAVA_TIME=false
ENV BABAHSKA_FEATURE_TRANSIT=false
ENV BABASHKA_FEATURE_XML=false
ENV BABASHKA_FEATURE_YAML=false
ENV BABASHKA_FEATURE_HTTPKIT_CLIENT=false
ENV BABASHKA_FEATURE_HTTPKIT_SERVER=false
ENV BABASHKA_FEATURE_JDBC=false
ENV BABASHKA_FEATURE_POSTGRESQL=false
ENV BABASHKA_FEATURE_HSQLDB=false
ENV BABASHKA_FEATURE_ORACLEDB=false
ENV BABASHKA_FEATURE_DATASCRIPT=false
ENV BABASHKA_FEATURE_LANTERNA=false
to the Dockerfile before uberjar and run docker build .

borkdude 2020-11-12T11:45:13.298800Z

let me try that locally

borkdude 2020-11-12T11:47:33.299Z

export BABASHKA_FEATURE_CORE_ASYNC=false
export BABASHKA_FEATURE_CSV=false
export BABASHKA_FEATURE_JAVA_NIO=false
export BABASHKA_FEATURE_JAVA_TIME=false
export BABAHSKA_FEATURE_TRANSIT=false
export BABASHKA_FEATURE_XML=false
export BABASHKA_FEATURE_YAML=false
export BABASHKA_FEATURE_HTTPKIT_CLIENT=false
export BABASHKA_FEATURE_HTTPKIT_SERVER=false
export BABASHKA_FEATURE_JDBC=false
export BABASHKA_FEATURE_POSTGRESQL=false
export BABASHKA_FEATURE_HSQLDB=false
export BABASHKA_FEATURE_ORACLEDB=false
export BABASHKA_FEATURE_DATASCRIPT=false
export BABASHKA_FEATURE_LANTERNA=false
script/uberjar && script/compile
No problems

borkdude 2020-11-12T11:50:16.299200Z

Can you maybe print the value of BABASHKA_FEATURE_YAML in the script

borkdude 2020-11-12T11:50:18.299400Z

to debug

Jakub HolĂ˝ 2020-11-12T11:50:36.299600Z

ok, nevermind then. Thanks for trying! I will get back if it turns out to be a problem again.

borkdude 2020-11-12T12:07:28.300200Z

😎 https://twitter.com/borkdude/status/1326858985094471681

❤️ 2
Jakub HolĂ˝ 2020-11-12T12:10:16.301500Z

Any tips for troubleshooting when compile inside docker fails with

...
[bb:58]     (clinit):  20,613.49 ms,  2.03 GB
[bb:58]   (typeflow): 223,789.23 ms,  2.03 GB
[bb:58]    (objects): 936,796.65 ms,  2.03 GB
[bb:58]   (features):  21,151.56 ms,  2.03 GB
[bb:58]     analysis: 1,262,818.93 ms,  2.03 GB
[bb:58]     universe:  71,729.57 ms,  2.03 GB
Error: Image build request failed with exit status 137
com.oracle.svm.driver.NativeImage$NativeImageError: Image build request failed with exit status 137
	at com.oracle.svm.driver.NativeImage.showError(NativeImage.java:1558)
	at com.oracle.svm.driver.NativeImage.build(NativeImage.java:1308)
	at com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1269)
	at com.oracle.svm.driver.NativeImage.main(NativeImage.java:1228)
	at com.oracle.svm.driver.NativeImage$JDK9Plus.main(NativeImage.java:1740)
The command '/bin/sh -c ./script/compile' returned a non-zero code: 137
? There are no details that would say why it failed 😞

borkdude 2020-11-12T12:10:57.302200Z

This is an out of memory error. Bump BABASHKA_XMX by setting it to -J-Xmx8g or whatever amount you have available. Could also be a Docker setting

Jakub HolĂ˝ 2020-11-12T12:11:23.302300Z

thanks a lot!!!

Jakub HolĂ˝ 2020-11-12T12:32:11.302500Z

I have now run with --build-arg BABASHKA_XMX=-J-Xmx8g and still getting the error 😢

borkdude 2020-11-12T12:36:49.302700Z

@holyjak Could it be that your docker doesn't have enough memory?

borkdude 2020-11-12T12:37:12.302900Z

What os are you on?

Jakub HolĂ˝ 2020-11-12T12:41:26.303100Z

Could be. OSXm 16GB mem in total.

borkdude 2020-11-12T12:41:57.303300Z

Go to preferences and then resources

borkdude 2020-11-12T12:42:15.303500Z

in your Docker Desktop

Jakub HolĂ˝ 2020-11-12T12:42:18.303900Z

According to Activity Monitor Docker uses under 4GB so it would seem to be the problem

borkdude 2020-11-12T12:43:00.304100Z

Note that you should not set BABASHKA_XMX higher than the total available memory minus some overhead, else you will get the same error

borkdude 2020-11-12T12:44:32.304300Z

so if you set Docker memory to let's say 5GB, set BABASHKA_XMX to 4500m max

Jakub HolĂ˝ 2020-11-12T12:46:08.304500Z

thanks a lot!

Jakub HolĂ˝ 2020-11-12T14:21:23.304700Z

I have made some progress with -Xmx8575549440 : > Exception in thread "native-image pid watcher" java.lang.OutOfMemoryError: GC overhead limit exceeded 😢 I suspect that too much docker memory was on swap and thus too slow.

borkdude 2020-11-12T14:28:52.304900Z

To how much have you set your docker memory

Jakub HolĂ˝ 2020-11-12T14:45:01.305100Z

10GB

borkdude 2020-11-12T14:49:40.305300Z

How much is 8 575.54944. Isn't that 8 megabytes?

borkdude 2020-11-12T14:50:08.305500Z

Maybe you should supply a unit

borkdude 2020-11-12T14:51:16.305700Z

Also, how are you providing BABASHKA_XMX? Can you post the entire Dockerfile setup?

borkdude 2020-11-12T14:51:38.305900Z

You can also peek at the babashka docker build on circleci to get some ideas

Jakub HolĂ˝ 2020-11-12T14:51:41.306100Z

this was printed in the stdout, I did run it with 8g

borkdude 2020-11-12T14:52:31.306300Z

aha

borkdude 2020-11-12T14:53:16.306500Z

Can you try to compile without the Oracle driver, to see if that is the culprit?

Jakub HolĂ˝ 2020-11-12T14:54:17.306700Z

I was running docker build --build-arg BABASHKA_XMX=-J-Xmx3g and in the Dockerfile I had ARG BABASHKA_XMX="-J-Xmx8g" I will wait until the osx build of bb finishes, which takes forever, then try again with Docker max 5g and build max 4500m, making sure Docker has enough memory available not to be swapped out

borkdude 2020-11-12T14:56:07.306900Z

3g is too little

borkdude 2020-11-12T15:01:56.307100Z

Somewhere between 4 and 5 gb is probably the minimal requirement

borkdude 2020-11-12T16:07:53.307300Z

Any luck?

Jakub HolĂ˝ 2020-11-12T17:52:41.308700Z

@borkdude I have managed to replicate the missing YAML error. When you run uberjar from https://github.com/borkdude/babashka/pull/641 with

BABASHKA_FEATURE_CSV=true
BABASHKA_FEATURE_JDBC=true
BABASHKA_FEATURE_ORACLEDB=true
BABASHKA_LEAN=true
BABASHKA_FEATURE_YAML=true
then it works but if I remove YAML it fails with ClassNotFoundException org.yaml.snakeyaml.error.YAMLException

Jakub HolĂ˝ 2020-11-12T17:54:56.309600Z

BTW the loooong compile times and OOM errors seem to have been caused by me adding a few more functions and namespaces from next.jdbc.

borkdude 2020-11-12T18:21:07.309700Z

@holyjak Is 641 good for merge?

borkdude 2020-11-12T18:22:00.309900Z

It would be worth checking into which function(s) cause this. Sometimes it's related to a run-time resolve. I have forked my share of code to make it well suited for GraalVM

borkdude 2020-11-12T18:25:24.310100Z

Thanks for looking into it. I was just seeing the PR

Jakub HolĂ˝ 2020-11-12T18:28:06.310300Z

yes

Jakub HolĂ˝ 2020-11-12T18:28:55.310500Z

yes, I plan to try to find out which function(s) cause this

borkdude 2020-11-12T18:52:59.310700Z

fwiw, the babashka pods compile in minutes on CircleCI. I'm not sure if those have an up to date next.jdbc version

borkdude 2020-11-12T19:07:35.311100Z

I compared the next.jdbc version in the pods to babashka, it's the same

Jakub HolĂ˝ 2020-11-12T19:20:06.311300Z

I upgraded it from.. 10 to... 13 AND added more stuff from it. Running experiments...

borkdude 2020-11-12T20:16:38.311900Z

The functions in the babashka-sql-pods should work fine, I have tested those with GraalVM. So maybe you could start with those, to confirm you get the same results. See the binary build here: https://app.circleci.com/pipelines/github/babashka/babashka-sql-pods/83/workflows/c154eb40-ad4f-4c05-8c8f-07be42b4895e/jobs/251 A little over 1 minute.

borkdude 2020-11-12T20:17:18.312100Z

Keep me posted :)

Jakub HolĂ˝ 2020-11-12T20:29:48.312300Z

FYI building latest master with only ..JDBC=true takes 451s, JDBC+Oracle takes 581s, with no extra features 421s, LEAN fails with ClassNotFoundException YAMLException

borkdude 2020-11-12T20:39:35.312600Z

This is in Docker right?

Jakub HolĂ˝ 2020-11-12T20:50:57.312800Z

no, on my 4y old maskin