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: Make sure the integration is robust and performs well #35

Open
holyjak opened this issue Feb 2, 2024 · 0 comments
Labels
Wolfram Eng Need help/advice from Wolfram Engineering

Comments

@holyjak
Copy link
Member

holyjak commented Feb 2, 2024

One thing we wonder about is whether we use JLink and the kernel correctly, and in the most efficient way. #34 describes how we start the kernel and evaluate expressions (translated from Clojure):

// Start the kernel/link:
  MathLinkFactory.createKernelLink({"-linkmode", "launch", "-linkname",
     "\"//Applications/Wolfram Engine.app/Contents/Resources/Wolfram Player.app/Contents/MacOS/MathKernel\" -mathlink"})
    .discardAnswer();

// Eval
KernelLink link = ''';
/*...jlink.*/Expr expr = ''';
link.evaluate(expr).waitForAnswer();
return link.getExpr();

The expression is constructed using its various constructors, such as new Expr(Expr.SYMBOL, "someName") and (type signature) Expr(Expr head, Expr[] tail), though in a few cases, as a fallback, we use a loopback link:

var input = ...;   // input could be a Long, a jlink Expr (which seems unnecessary?!), object array; String, long array
var link = MathLinkFactory.createLoopbackLink();
link.put(input); link.endPacket();
return link.getExpr();

Is this the right way? I believe we never "release" the expressions, if that concept exists. Is that ok?

On parallelism and concurrency

Also, find out about concurrency vs. parallelism: how many kernels can we run in parallel? Is it a good idea? And what if we submit expressions from multiple threads to a single kernel - I assume the kernel is single-threaded and executes them one by one, is it so? And is it faster or slower than if we serialize these requests on our side before sending any to the kernel?

@holyjak holyjak added the Wolfram Eng Need help/advice from Wolfram Engineering label May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Wolfram Eng Need help/advice from Wolfram Engineering
Projects
None yet
Development

No branches or pull requests

1 participant