|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: mirage + ocaml4
On 12 Dec 2012, at 13:43, Pierre Chambart <pierre.chambart@xxxxxxxxxxxx> wrote:
> Le Wed, 12 Dec 2012 11:34:04 +0000,
> Anil Madhavapeddy <anil@xxxxxxxxxx> a écrit :
>
>> One performance crime that I noticed is the Cstruct.blit_string
>> function, which does a byte-by-byte copy from a string to a
>> Bigarray. Pierre, do you have any thoughts on how to improve this?
>> A faster blit between them would be quite useful.
>
> Of course it is possible to do a memcopy like for copy_string. I can do
> this patch later today.
Thanks! I think that's the last of the very bad byte-by-byte cases in
cstruct; it's pretty decent now.
> I noticed that the type t is public. This may be a good idea to make it
> private in the mli to avoid dangerous usage. And you should then add
> with that a cast function checking that the bounds are effectively
> correct.
>
> type t = private {
> buffer: buffer;
> off : int;
> len : int;
> }
>
> val check: buffer -> off:int -> len:int -> t
Right; this is actually in the TODO as well. What I want is a way to
attach a bigarray and have it bounds checked *once* (for the total size
of the cstruct that has been declared), and then have all the various
internal functions use unsafe accesses.
That should be possible in Cstruct.of_bigarray and Cstruct.create, with
the check function above added.
-anil
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |