-
Notifications
You must be signed in to change notification settings - Fork 323
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
Wasting 100MB by Standard.Image
: Implement polyglot/lib
#11483
Comments
Extracting anything from a |
Standard.Image
library Standard.Image
: Implement polyglot/lib
Pavel Marek reports a new STANDUP for today (2024-12-16): Progress: - Started with creating a separate |
Pavel Marek reports a new STANDUP for today (2024-12-17): Progress: - Reverting separate HostClassLoader per project - it was a mistake - #11874 (comment).
|
+1, there already is work on class loader/layer per library in #10714 |
Pavel Marek reports a new STANDUP for today (2024-12-18): Progress: - Convincing sbt build script to extract native libraries from
|
Pavel Marek reports a new STANDUP for today (2024-12-20): Progress: - Fixing problems with running Image_Tests on native image.
|
Pavel Marek reports a new STANDUP for today (2024-12-23): Progress: - sbt correctly extracts native libs from
|
Pavel Marek reports a new STANDUP for today (2024-12-27): Progress: - Trying other suggested alternatives to find and load
|
Pavel Marek reports a new STANDUP for today (2024-12-31): Progress: - Many failed attempts to include
|
I've just checked sizes of various libraries inside of Enso distribution:
e.g. the
Standard.Image
library occupies 118MB! Why? Because itsopencv.jar
internally contains various ~10MB huge binaries for each supported platform.If we, remove these native libraries and keep just a single one for the platform we build the distribution for we:
Specification
The solution is to enhance HostClassLoader and override its findLibrary method to perform native library search. We will adhere to the NetBeans specification - we are using it anyway in when building enso4igv as the libraries layout is:
You may place the native libraries (DLL or shared-object) beneath a
polyglot/lib
directory of an Enso Library with Polyglot Java libraries. If your native library file names for different architectures or operating systems clash, you may create subdirectories underpolyglot/lib
for each supported platform and nested subdirectories for each supported operating system. The directory names must matchSystem.getProperty("os.arch")
andSystem.getProperty("os.name").replaceAll(" .*$", "").toLowerCase(Locale.ENGLISH)
respectively. TheSystem.loadLibrary
call originating from the library code will try to locate the library file in the following order of directories:so you may place e.g. 64-bit Linux version of a
foo
library in a filepolyglot/lib/amd64/linux/libfoo.so
and 64-bit Windows version inpolyglot/lib/amd64/windows/foo.dll
(or alsopolyglot/lib/amd64/foo.dll
and of course inpolyglot/lib/foo.dll
).Justification
The OpenCV SharedLoader seems to be using
System.loadLibrary
and thus, if ourHostClassLoader
supportsfindLibrary
, it should load it frompolyglot/lib
directory rather than extracting it to temporary location on each startup.Tasks
The text was updated successfully, but these errors were encountered: