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

Do we need a memcpy opcode? #977

Closed
juj opened this issue Feb 2, 2017 · 4 comments
Closed

Do we need a memcpy opcode? #977

juj opened this issue Feb 2, 2017 · 4 comments

Comments

@juj
Copy link

juj commented Feb 2, 2017

In a number of game engines I've been optimizing and benchmarking, interestingly the performance of memcpy() does show up relatively high in profiles. (~2%-5% of total execution time)

I did a recent optimization to memcpy in Emscripten, and added some benchmarks. See emscripten-core/emscripten#4127 (especially http://clb.demon.fi/emcc/memcpy_test/results.html)

The result there was that asm.js+SIMD memcpys are at worst ~3x slower than native at aligned copy sizes around 4k - 16k bytes, and Wasm memcpys are at worst ~6x slower than native at aligned copy sizes around the same size.

It is not immediately obvious to me how much we can close this gap e.g. by further optimizing the memcpy implementation in Emscripten, and optimizing Wasm implementations in browsers, which raises the question of whether it would make sense to have a memcpy (and probably as extension, memset) opcode directly in wasm?

Currently in Emscripten very large memcpys round trip to HEAP8.set(), but it has a drawback of generating temporary garbage.

@juj
Copy link
Author

juj commented Feb 2, 2017

@lukewagner lukewagner added this to the Future Features milestone Feb 2, 2017
@lukewagner
Copy link
Member

(Copying over from the bugzilla comment) I think it would make sense to add a page-unit mempcy operator to our finer-grained control over memory list. Having page units means wasm can assume the caller is doing all the small-memcpy() optimizations (inlining, unrolling, peeling, etc) and then simply call out to the C++ memcpy() (which presumably then does all the fancy stuff).

@jfbastien
Copy link
Member

Dup #236 ?

@lukewagner
Copy link
Member

Hah, 2015... seems so long ago. (It'd be nice to get it listed in FutureFeatures.md, though.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants