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 BFCCF7FACE for ; Thu, 18 Sep 2014 13:09:35 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=pra; client-ip=212.227.126.187; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=mailfrom; client-ip=212.227.126.187; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mout.kundenserver.de) identity=helo; client-ip=212.227.126.187; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="postmaster@mout.kundenserver.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: As0BAGe8GlTU4367m2dsb2JhbABYCINgV4MAxj8Gh1EBgQ4WAREBAQEBAQYLCwkUKoQEAQEDAR0GMiQFCwtCAgJXBhMJEogbDAmrFxQhbw2UfAEXiXmFKDAmB4I3QRKBQQWGH4tpkkgFkV9qAYJJAQEB X-IPAS-Result: As0BAGe8GlTU4367m2dsb2JhbABYCINgV4MAxj8Gh1EBgQ4WAREBAQEBAQYLCwkUKoQEAQEDAR0GMiQFCwtCAgJXBhMJEogbDAmrFxQhbw2UfAEXiXmFKDAmB4I3QRKBQQWGH4tpkkgFkV9qAYJJAQEB X-IronPort-AV: E=Sophos;i="5.04,546,1406584800"; d="asc'?scan'208";a="96420041" Received: from mout.kundenserver.de ([212.227.126.187]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 18 Sep 2014 13:09:35 +0200 Received: from office1.lan.sumadev.de (dslb-178-004-068-137.178.004.pools.vodafone-ip.de [178.4.68.137]) by mrelayeu.kundenserver.de (node=mreue005) with ESMTP (Nemesis) id 0MKMb4-1XV7YR2m1O-001er6; Thu, 18 Sep 2014 13:09:33 +0200 Received: from [192.168.10.100] (ip-37-201-182-45.hsi13.unitymediagroup.de [37.201.182.45]) by office1.lan.sumadev.de (Postfix) with ESMTPSA id AD785DC270; Thu, 18 Sep 2014 13:09:32 +0200 (CEST) Message-ID: <1411038566.5797.108.camel@e130> From: Gerd Stolpmann To: "Bauer, Christoph" Cc: caml-list Date: Thu, 18 Sep 2014 13:09:26 +0200 In-Reply-To: References: Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-OdeY2MVHwuIPs7JuIDg1" X-Mailer: Evolution 3.10.4-0ubuntu1 Mime-Version: 1.0 X-Provags-ID: V02:K0:6Tg9594vvofVxxUUzH042Pg/mhP+wgrO9EPGzFoGRO4 8ZOSKmX101Qw6SUSJNVVYgNHnAjNUeDwotXmJ61YPmcN85ru25 fg9rC6CESz3eyFHjpgeyehT1C72/GcvV2BNTNyh3JwhcAGas4R hKSH8I8Gw5So2lNqkgdIcb3V0fL722CAOscxBdHQB4ztQX3Qor pQ6DL73alYTupJM2DWaWfuLBOhxloeqITz76Z1kiDWJEt4XoMY 5HA7Bk5E3aTgBdtzTsGqYZ4CkkW/0iSXf35g9Ss/zAViVOWSPi Qe30B3mgokNXktl6a4zKvlzlVPIVrAGj+3f+SgyT+Uh/MXvmR2 GtanbS4+mxWaILIgSV/hC3+k0lPrIzfriVckicBiB X-UI-Out-Filterresults: notjunk:1; Subject: Re: [Caml-list] memory mapped files with bigarray on windows --=-OdeY2MVHwuIPs7JuIDg1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Am Donnerstag, den 18.09.2014, 08:04 +0000 schrieb Bauer, Christoph: > Dear All,=20 >=20 >=20=20 >=20 > my program maps several blocks of a file into memory with > Bigarray.Array1.map_file for writing. >=20 > Finally the file handle is closed with Unix.close. You can close the file handle immediately after establishing the mapping. The handle is only needed here as a reference of the file to map, but it doesn't influence the way the file is written. In particular, a close doesn't flush the contents to disk. > On local files system everything works as expected. Which is not guaranteed by POSIX, but normally works for all OS that deeply integrate memory mapping. There is the msync() system call for ensuring that all changes are finally reflected by the file. > But if the file is on a network drive, >=20 > the resulting file is after the close still locked [1] and it > contains just zeros. Right, this is a known problem. Call msync(). I suggest it would be easiest if msync() was part of the Bigarray module, but you can also create your own wrapper. Note that unmapping usually triggers the synchronization, but it doesn't wait until the data is written (like calling msync() with the MS_ASYNC flag). > My workaround is, to call Gc.full_major() before the close. Then all > remaining bigarrays are >=20 > finalized (the finalizer calls caml_ba_unmap_file(), see > bigarray_stubs.c). >=20 As noted, you cannot be sure that the data is really written at this point. There is no way around msyncing the file. Gerd >=20=20 >=20 > Calling Gc.full_major () is somewhat dissatisfying. But I=E2=80=99m not s= ure > how it could be solved more cleanly. >=20 > I would expect that Unix.close should unmap all remaining views of the > file. But Unix.close knows nothing >=20 > about the bigarray mapping.=20 >=20 >=20=20 >=20 > Maybe a special Bigarray.unmap is the solution. >=20 >=20=20 >=20 > Does anyone has a better idea? >=20 >=20=20 >=20 > Thanks, >=20 > Christoph Bauer >=20 >=20=20 >=20 > [1] You can=E2=80=99t delete it in the windows explorer. >=20 >=20=20 >=20 >=20=20 >=20 >=20 > ----------------- > Siemens Industry Software GmbH & Co. KG; Anschrift: Franz-Geuer-Str. > 10, 50823 K=C3=B6ln; > Kommanditgesellschaft: Sitz der Gesellschaft: K=C3=B6ln; Registergericht: > Amtsgericht K=C3=B6ln, HRA 28227; > Gesch=C3=A4ftsf=C3=BChrung und pers=C3=B6nlich haftender Gesellschafter: = Siemens > Industry Software Management GmbH; > Gesch=C3=A4ftsf=C3=BChrer: Urban August, Daniel Trebes; Sitz der Gesellsc= haft: > K=C3=B6ln; Registergericht: Amtsgericht K=C3=B6ln, HRB 70858 >=20 --=20 ------------------------------------------------------------ Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de My OCaml site: http://www.camlcity.org Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de ------------------------------------------------------------ --=-OdeY2MVHwuIPs7JuIDg1 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAABAgAGBQJUGr1mAAoJEAaM4b9ZLB5TypkIAJwCgX3SStOawSScSo/0Vm+G qOXR6M6G23OR/zrVknh3SXu4LrGN2cp/Ufpdh857i2hnjEAj+FLS16r25ebGkyJS lfomfIAbvyHCcDisWpV8Buy7HBuyMQNTa4TrAzodH9aJmdriDsRM/2HDU5MMLNmE WGQyncexEVa1UvC7ty0vslHS5l0/XpFjwNTz+r7CrRk/RVDFvXncP59ixNcK663W AyTbzHxxMwpdsuX5VF8NzvfwQUNmaqSw+zNcJAfKvbC1GKp0miCMW0Z36vKFZG6Q 4taAOARs0PuJXAZxqNj9bBM09tgYP4ge5QYldE4feFuDR0QDFAMuGH+82smE5yU= =KHn0 -----END PGP SIGNATURE----- --=-OdeY2MVHwuIPs7JuIDg1--