From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 8EB8B7EE25 for ; Wed, 6 Nov 2013 14:58:05 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of rich@annexia.org) identity=pra; client-ip=80.68.91.176; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="rich@annexia.org"; x-sender="rich@annexia.org"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of rich@annexia.org designates 80.68.91.176 as permitted sender) identity=mailfrom; client-ip=80.68.91.176; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="rich@annexia.org"; x-sender="rich@annexia.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@furbychan.cocan.org) identity=helo; client-ip=80.68.91.176; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="rich@annexia.org"; x-sender="postmaster@furbychan.cocan.org"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiUFAMlJelJQRFuw/2dsb2JhbABagweDPL0NgSQWdIIlAQEFOj8QCxgJExIPBSghE4gFAb50hhWJRAeDIIEQA5gLkguDJjw X-IPAS-Result: AiUFAMlJelJQRFuw/2dsb2JhbABagweDPL0NgSQWdIIlAQEFOj8QCxgJExIPBSghE4gFAb50hhWJRAeDIIEQA5gLkguDJjw X-IronPort-AV: E=Sophos;i="4.93,647,1378850400"; d="scan'208";a="41257143" Received: from furbychan.cocan.org ([80.68.91.176]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 06 Nov 2013 14:57:27 +0100 Received: from rich by furbychan.cocan.org with local (Exim 4.80) (envelope-from ) id 1Ve3cN-0002ox-W9; Wed, 06 Nov 2013 13:57:59 +0000 Date: Wed, 6 Nov 2013 13:57:59 +0000 From: "Richard W.M. Jones" To: Anil Madhavapeddy Cc: rixed@happyleptic.org, OCaml Mailing List Message-ID: <20131106135759.GA10737@annexia.org> References: <20131018115553.GA28679@ombreroze.happyleptic.org> <20131018115955.GG25839@dark.recoil.org> <20131018121612.GB28679@ombreroze.happyleptic.org> <20131018122018.GJ25839@dark.recoil.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20131018122018.GJ25839@dark.recoil.org> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [Caml-list] IPv6 packet parsing On Fri, Oct 18, 2013 at 01:20:18PM +0100, Anil Madhavapeddy wrote: > On Fri, Oct 18, 2013 at 02:16:12PM +0200, rixed@happyleptic.org wrote: > > -[ Fri, Oct 18, 2013 at 12:59:55PM +0100, Anil Madhavapeddy ]---- > > > One feature I'd really like to see in Bitstring is support for Bigarray, > > > since that avoids a copy into the OCaml heap and lets us do quite high > > > performance parsing. If I remember right, there was a patch on the > > > Bitstring issue tracker, but it wasn't parameterised (so it's either > > > Bistring+string or Bitstring+bigarray, which isn't ideal). > > > > Pardon my lack of familiarity with bigarrays, but I can't see what's the > > difference between copying packets from pcap ring buffer into a bigarray > > or into a string. Or do you mean using Bigarray.map_file on the whole > > raw ring buffer and handle it without pcap help? > > We have a number of use-cases that run OCaml in kernel mode, directly > operating on packets read from a network driver that's also written in > OCaml. Bigarrays are used as the mechanism for passing around externally > allocated memory (i.e. network card buffers) directly, whereas inspecting > them with a string-based Bigarray requires an expensive data copy. I'm late to the party here, but could you just Obj.magic the bitstring string pointer (ie. the first in the 3-tuple) to point at the Bigarray data? Note that bitstring doesn't really move the string around (well, I don't want to claim that never happens, but it shouldn't happen in the common cases AFAIK). Rich. -- Richard Jones Red Hat