From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q1SKHOka023232 for ; Tue, 28 Feb 2012 21:17:24 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApIDAF81TU/ZSMD3jmdsb2JhbABDs2YiAQEBAQkLCQkSBSSCJRN7NAEEKIhAn2CYSo0LBwYGGgIKAQYLAgYHDBQJAoUHCHuDHgSbCo0mgVMQ X-IronPort-AV: E=Sophos;i="4.73,497,1325458800"; d="scan'208";a="133441955" Received: from fmmailgate06.web.de ([217.72.192.247]) by mail4-smtp-sop.national.inria.fr with ESMTP; 28 Feb 2012 21:17:18 +0100 Received: from moweb001.kundenserver.de (moweb001.kundenserver.de [172.19.20.114]) by fmmailgate06.web.de (Postfix) with ESMTP id 6A555D3392E for ; Tue, 28 Feb 2012 21:17:18 +0100 (CET) Received: from frosties.localnet ([95.208.118.96]) by smtp.web.de (mrweb002) with ESMTPA (Nemesis) id 0LuMER-1SSDNZ1U63-010wJr; Tue, 28 Feb 2012 21:17:18 +0100 Received: from mrvn by frosties.localnet with local (Exim 4.77) (envelope-from ) id 1S2TU5-0004bZ-Oe for caml-list@inria.fr; Tue, 28 Feb 2012 21:17:17 +0100 From: Goswin von Brederlow To: caml-list@inria.fr Date: Tue, 28 Feb 2012 21:17:17 +0100 Message-ID: <87y5rmemr6.fsf@frosties.localnet> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Provags-ID: V02:K0:86dAsqipNCxpjuxDNqSJXRCJ49rd0QIckln6ZdS8Cyy /sloFDK8uJqdQ61spauqJO9OHgF2+2C+AzEKGHxT6tDqT3IPfc J4M6N91e9TEGBZ07/69JaSMs1lukGe9VZcV+MGgEYEFaWHhZMV 08tiGp6Uriujm0SjBJS/2NlmZ5S5iZnFOZfbBWYUDLJkw48CNK 1hRsuB7YFI4CpUosQquGw== Subject: [Caml-list] Bigarray question: Detecting subarrays, overlaps, ... Hi, I'm implementing a RAID in userspace using ocaml and NBD (Network Block Device) as protocol to export the device. For this I'm using Bigarray.Array1 as buffer for data and wrote myself the right read(), write(), pread() and pwrite() stubs. The advantage of this (over strings) is that Bigarrays are not copied around by the GC so they don't need to copy data around between the Bigarray and a temporary buffer in the C stub. For efficiency each request stores all its data in a single Bigarray.Array1. For reasons of the RAID implementation large requests are split into 4k chunks using Bigarray.Array1.sub and grouped into stripes. The stripes are then acted upon independently until all stripes involved in a request are finished. Then the request is completed. Now I get a problem when 2 requests come in that overlap. Say I get a write request for blocks 0 - 6 and a read request for blocks 4-9 in that order. Since I already have the data for block 4-6 in memory from the write request I do not want to reread them from disk. On the stripe level the data looks like this: |W0 W1 W2 W3 W4 W5 W6 . . . | write 0-6 | W4 W5 W6 R7 R8 R9 | read 4-9 For the read request I need to copy W4-6 to R4-6 or send out W4-6 + R7-9 in two writes. I think I would like to avoid sending each stripe chunk out seperately. On the other hand I could implement (p)readv() and (p)writev() stubs. Anyway, my question now is how to detect which subarrays in the stripes are part of a common larger array? Do I need to write my own C stub that looks into the internas of the arrays to see if they share a common ancestor? I think that would be preferable to tracking the origin of each subarray myself. On a similar note how does Bigarray.Array1.blit handle arrays that are part of the same larger array and overlap? ---------------------------------------------------------------------- I'm missing functions like: val super : ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> ('a, 'b, 'c) t Create a merged sub-array of 2 adjacent sub-arrays of the same big array. val same_parent : ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> bool True if the 2 (sub-)arrays are part of the same big array. val offset : ('a, 'b, 'c) t -> int Offset of the sub-array in the underlying big array. MfG Goswin