From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 4191BBC37 for ; Fri, 30 Oct 2009 00:25:22 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvkBAGfB6UrZSMDji2dsb2JhbACBT5l7AQEBCgsKBxEFwzWEPQSBYg X-IronPort-AV: E=Sophos;i="4.44,649,1249250400"; d="scan'208";a="49490898" Received: from fmmailgate02.web.de ([217.72.192.227]) by mail4-smtp-sop.national.inria.fr with ESMTP; 30 Oct 2009 00:25:21 +0100 Received: from smtp05.web.de (fmsmtp05.dlan.cinetic.de [172.20.4.166]) by fmmailgate02.web.de (Postfix) with ESMTP id 93FFB13B2779F; Fri, 30 Oct 2009 00:25:19 +0100 (CET) Received: from [95.208.117.111] (helo=frosties.localdomain) by smtp05.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #314) id 1N3eMp-0001DA-00; Fri, 30 Oct 2009 00:25:19 +0100 Received: from mrvn by frosties.localdomain with local (Exim 4.69) (envelope-from ) id 1N3eMo-0005kI-QT; Fri, 30 Oct 2009 00:25:18 +0100 From: Goswin von Brederlow To: Sylvain Le Gall Cc: caml-list@inria.fr Subject: Re: [Caml-list] Re: How to read different ints from a Bigarray? References: <87eiond3of.fsf@frosties.localdomain> <4AE87AB9.5020607@inria.fr> <87pr86b066.fsf@frosties.localdomain> Date: Fri, 30 Oct 2009 00:25:18 +0100 In-Reply-To: (Sylvain Le Gall's message of "Thu, 29 Oct 2009 18:48:29 +0000 (UTC)") Message-ID: <874oph4wbl.fsf@frosties.localdomain> User-Agent: Gnus/5.110006 (No Gnus v0.6) XEmacs/21.4.22 (linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: goswin-v-b@web.de X-Sender: goswin-v-b@web.de X-Provags-ID: V01U2FsdGVkX1+mXzW/pmS2h+V1xzkA3wyJMHcntWe2aPK0axje rYJmcVbmfdB5m+b+wkoYn9Cwq6hzEZ+iFe00vsCXjXYKsuqo8h snOOC7UoQ= X-Spam: no; 0.00; bigarray:01 le-gall:01 ocaml:01 bigarray:01 christophe:01 compiler:01 allocating:01 aligned:01 ocaml:01 mfg:98 polymorphic:01 char:01 char:01 wrote:01 wrote:01 Sylvain Le Gall writes: > On 29-10-2009, Goswin von Brederlow wrote: >> Xavier Leroy writes: >>> Goswin von Brederlow wrote: >> >> Here are some benchmark results: >> >> get an int out of a string: >> C Ocaml >> uint8 le 19.496 17.433 >> int8 le 19.298 17.850 >> uint16 le 19.427 25.046 >> int16 le 19.383 27.664 >> uint16 be 20.502 23.200 >> int16 be 20.350 27.535 >> >> get an int out of a Bigarray.Array1.t: >> safe unsafe >> uint8 le 55.194s 54.508s >> uint64 le 80.51s 81.46s >> > > Can you provide us with the corresponding code and benchmark? > > Maybe you can just commit this in libaio/test/bench.ml. > > Regards, > Sylvain Le Gall As Christophe guessed the problem was polymorphic functions. If I specify a fixed Array1 type then the compiler uses the optimized access functions. Makes unsafe Bigarray slightly faster than unsafe string actually (must not optimize int_of_char/Char.unsafe_chr away) and that independent of argument size (on set, on get allocating int32/int64 costs time so they are slower). So Bigarray is the fastest but getting different types out of a Bigarray will be tricky. Unaligned even more so if not impossible. I have to sleep on this. Maybe in my use case I can have all structures int64 aligned and then split the int64 up in ocaml where structures have smaller members. Would have been too much to have a Bigarray with access functions for any type. Maybe some little wrapper with Obj.Magic will do *hide*. As for libaio it should be easy to make it create and use any Bigarray type. MfG Goswin