Skip to content
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

Wolfram Engineering: How to pass large data between JVM and Wolfram efficiently? #113

Open
holyjak opened this issue Sep 10, 2024 · 0 comments
Labels
question Further information is requested Wolfram Eng Need help/advice from Wolfram Engineering

Comments

@holyjak
Copy link
Member

holyjak commented Sep 10, 2024

How to pass large data between JVM and Wolfram efficiently? The Clojure - Python bridge uses direct memory sharing for passing of (large primitive) data efficiently. Turning 100k rows of data into JLink Expressions and then back is likely highly inefficient for that. Is there a better way, through memory or some efficient shared file format? (E.g. Parquet, though Wolfram doesn't seem to support that yet?)

The J/Link guide mentions in Speeding Up Sending Large Arrays:

You can send and receive arrays of most "primitive" Java types (e.g. byte, short, int, float, double) nearly as fast as in a C-language program. The set of types that can be passed quickly corresponds to the set of types for which the WSTP C API has single functions to put arrays. The Java types long (these are 64 bits), boolean, and String do not have fast WSTP functions, and so sending or receiving these types is much slower. Try to avoid using extremely large arrays of these types (say, more than 100,000 elements) if possible.

Setting $RelaxedTypeChecking may also be sometimes relevant for the return value (Wolfram → JVM), perhaps...

Note: It seems arrays are always sent by copy:

Unlike the C WSTP API, there are no methods for "releasing" strings or arrays because this is not necessary. When you read a string or array off the link, your program gets its own copy of the data, so you can write into it if you desire (although Java strings are immutable).

@holyjak holyjak added question Further information is requested Wolfram Eng Need help/advice from Wolfram Engineering labels Sep 10, 2024
@holyjak holyjak changed the title Question: How to pass large data between JVM and Wolfram efficiently? Wolfram Engineering: How to pass large data between JVM and Wolfram efficiently? Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Wolfram Eng Need help/advice from Wolfram Engineering
Projects
None yet
Development

No branches or pull requests

1 participant