Skip to content

Comments

Optimize bytes copying after receiving a message from zmq#158

Open
hxzrx wants to merge 1 commit intorigetti:masterfrom
hxzrx:master
Open

Optimize bytes copying after receiving a message from zmq#158
hxzrx wants to merge 1 commit intorigetti:masterfrom
hxzrx:master

Conversation

@hxzrx
Copy link

@hxzrx hxzrx commented May 30, 2023

The utility function unpack-foreign-msg-to-bytes uses cffi:foreign-array-to-lisp to copy zmq message to a lisp vector, this is very slow for large messages since cffi:foreign-array-to-lisp sets the lisp vector byte-to-byte in a loop.

In this PR, memcpy is used instead of cffi:foreign-array-to-lisp to copy zmq message to the lisp vector in one pass, and the result is very close to that of the C version of zmq.

@hxzrx hxzrx requested a review from a team as a code owner May 30, 2023 07:17
@stylewarning
Copy link
Contributor

This looks good and safe to me. MEMCPY will definitely be faster.

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

Successfully merging this pull request may close these issues.

2 participants