faster alternative to memcpy?

后端 未结 16 1178
一生所求
一生所求 2020-11-29 21:27

I have a function that is doing memcpy, but it\'s taking up an enormous amount of cycles. Is there a faster alternative/approach than using memcpy to move a piece of memory?

16条回答
  •  臣服心动
    2020-11-29 21:48

    You may want to have a look at this:

    http://www.danielvik.com/2010/02/fast-memcpy-in-c.html

    Another idea I would try is to use COW techniques to duplicate the memory block and let the OS handle the copying on demand as soon as the page is written to. There are some hints here using mmap(): Can I do a copy-on-write memcpy in Linux?

提交回复
热议问题