Implementing Lambda with Capture support makes Metaspace fills LambdaForms$BMH class
Wenlei Xie
wenlei.xie at gmail.com
Tue May 2 20:22:36 UTC 2017
Hi Remi,
Thank you for the prompt response!!
Consider the following query:
SELECT transform(arr, x->x + value)
FROM test_table
The underlying table is
arr | value
--------------------------------
[1, 2] | 1
[7, 8, 9] | 2
The expected output is
[2, 3]
[9, 10, 11]
Now our implementation is first to generate a MethodHandle mh that takes
two argument and output the sum. During the query processing, for each row,
we first call
capturedMh = mh.bindTo(value)
And then use capturedMh for each value in the array.
That's why we are having a different method handle for each row.
Best,
Wenlei
On Tue, May 2, 2017 at 1:02 PM, Remi Forax <forax at univ-mlv.fr> wrote:
> Hi Wenei,
> The idea of bindTo()/insertArguments is that you are requesting a partial
> evaluation, so you are asking the VM/JIT to specialize the method handle if
> the method handle is used often.
> So compiling a method handle to a bytecode snippet in that case is the
> expected behavior, not a bug.
>
> What i do not understand is why you need to have a different method handle
> for each row ?
>
> Did you try to use invokeWithArguments instead of bindTo().invokeExact() ?
>
> cheers,
> Rémi
>
> ------------------------------
>
> *De: *"Wenlei Xie" <wenlei.xie at gmail.com>
> *À: *mlvm-dev at openjdk.java.net
> *Envoyé: *Mardi 2 Mai 2017 21:29:38
> *Objet: *Implementing Lambda with Capture support makes Metaspace fills
> LambdaForms$BMH class
>
> Hi,
> We are implementing Lambda function with capture support in a SQL Engine.
> We currently implement by compiling user-written Lambda Expression into a
> MethodHandle. And use bindTo to captured fields. Thus for each row we will
> have a Bound Method Handle.
>
> However, we found JVM will generate the byte code Bound Method Handle once
> it's invoked more than 128 times. This cause in some cases (when the table
> has large arrays), the Metaspace fills with generated LambdaForm$BMH class.
>
> Here is the simple code to reproduce the issue: https://github.com/
> wenleix/BMHTest . It looks we cannot increase
> java.lang.invoke.MethodHandle.CUSTOMIZE_THRESHOLD beyond 128. Any
> suggestions to implement Lambda with Capture Support on JVM?
>
> Thank you !!
>
> Best,
> Wenlei
>
>
>
>
> _______________________________________________
> mlvm-dev mailing list
> mlvm-dev at openjdk.java.net
> http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
>
>
> _______________________________________________
> mlvm-dev mailing list
> mlvm-dev at openjdk.java.net
> http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
>
>
--
Best Regards,
Wenlei Xie (谢文磊)
Email: wenlei.xie at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/mlvm-dev/attachments/20170502/b978d67a/attachment.html>
More information about the mlvm-dev
mailing list