-
Notifications
You must be signed in to change notification settings - Fork 30
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
extremely inefficient usage of memcpy
host function
#102
Comments
Further breakdown required before actionable |
I don't see we interfere clang somewhere whether to use |
working on identifying the C++ code that creates these memcpy calls. Once we identify these sections of code, we can identify some options and solutions. This work will require additional investigation. |
cdt generates extremely inefficient calls to the
memcpy
host function. It will create wasm such asIn this case the compiler wants to copy a fixed 8 bytes, but generates a call to the
memcpy
host function to perform that copy. Compared to a simple WASM load & store, this bloats what should effectively be (at most) 2 machine instructions (with EOS VM OC anyways) to probably at least a hundred machine instructions including a bunch of branches.A look at the eosio.token contract shows that 37 of the 39
memcpy
host function calls in eosio.token is similar to the above: a fixed 8 bytememcpy
host function call. For a more complex contract, say the EOS EVM contract, 526 of the 585memcpy
calls are for a fixed byte size. Though, for EOS EVM, there is considerably more variety in the fixed byte size.breakdown of EOS EVM constant size `memcpy` host function calls
The current performance impact of this inefficient code generation is likely over 5% on a chain like WAX with EOS VM OC enabled. That is, on WAX, with EOS VM OC enabled, over 5% of the main thread time today is dealing with
memcpy
host function calls (many of which I suspect are these fixed size variants due to how invasive they are, but I don't have proof of that).cdt should, minimally, have an optimization pass that squashes these small fixed size
memcpy
andmemset
calls to simple wasm load & stores.The text was updated successfully, but these errors were encountered: