-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
ffi: working with struct fields is slow #43142
Comments
Similarly if I do the code below I expect 0 calls to be left in the graph: void rawIncrement(int value) {
_impl.cast<Int64>().value += value;
} However I get 4 calls:
though I think everything here is intrinsified so overall performance is not that bad. However it can probably be made N times better. |
@mraleph Perhaps we could add a cache before loadClass, lookUpFunction in |
@lfkdsk I think we should treat the code in I remember now that
|
If I force inline
We should probably change |
That is correct. Edit: Alternatively we can also optimize the call sites for which we know the type statically and leave the dynamic call sites slow. However, that will not solve the tree shaking. |
Given the code like this:
I expect
Counter.increment
to translate into a small number of direct memory operations on the value of_impl
pointer.However instead I see a very large graph with three calls - one of which
_loadStruct
, if I am not mistaken, bottoms in the runtime call doing really complex stuff - at least I can't find IL optimization rules that would specialise_loadStruct
for known arguments.This ends up being around 50x slower then calling a C function through FFI to do the same increment.
/cc @mkustermann
The text was updated successfully, but these errors were encountered: