[request] efficient way to copy from bytevectors to malloc()ed memory
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Ikarus Scheme |
Fix Committed
|
Medium
|
Abdulaziz Ghuloum |
Bug Description
It would be nice to have a fast way to move data from Scheme
bytevectors to C-accessible memory and vice-versa. I've attached a
patch that adds a procedure called `memcpy' to the FFI that does
this.
In a simple synthetic benchmark, the speed gain ranges from a factor
of ~3 (copying 8 bytes) to a factor of ~240 (copying 64KiB); compared
against a naive Scheme implementation of memcpy using byte operations
on bytevectors and FFI pointers.
In a quasi-real-live scenario (a webserver implemented using
libsoup[0] via the FFI), just switching to the attached implementation
of memcpy instead of using the naive one implemented in Scheme doubled
the throughput in case of serving a 50KiB static file.
Looks good. Patched in revision 1771. Thanks.