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 24C26820A1 for ; Sat, 17 Aug 2013 02:06:34 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of yminsky@janestreet.com) identity=pra; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yminsky@janestreet.com"; x-sender="yminsky@janestreet.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of yminsky@janestreet.com designates 38.105.200.229 as permitted sender) identity=mailfrom; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yminsky@janestreet.com"; x-sender="yminsky@janestreet.com"; 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@tot-dmz-mxout1.janestreet.com) identity=helo; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yminsky@janestreet.com"; x-sender="postmaster@tot-dmz-mxout1.janestreet.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlcBAAC+DlImacjlnGdsb2JhbABbgztRrG2SNYEhHg4BAQEBAQYNCQkUKIIkAQEFDDQBARMZCwEPCwsNDSEhARIBBQEKEgYTCAqHbAMPAwmcD4sLhEcBBYRWAwqIWAaNVYJIMweEEpV+gWmBLYsAg0MWKYRegUwk X-IPAS-Result: AlcBAAC+DlImacjlnGdsb2JhbABbgztRrG2SNYEhHg4BAQEBAQYNCQkUKIIkAQEFDDQBARMZCwEPCwsNDSEhARIBBQEKEgYTCAqHbAMPAwmcD4sLhEcBBYRWAwqIWAaNVYJIMweEEpV+gWmBLYsAg0MWKYRegUwk X-IronPort-AV: E=Sophos;i="4.89,898,1367964000"; d="scan'208";a="29538473" Received: from mx5.janestreet.com (HELO tot-dmz-mxout1.janestreet.com) ([38.105.200.229]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 17 Aug 2013 02:06:32 +0200 Received: from tot-oib-smtp1.delacy.com ([172.27.22.15] helo=tot-smtp) by tot-dmz-mxout1.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1VAU2J-0002fE-Pt for caml-list@inria.fr; Fri, 16 Aug 2013 20:06:31 -0400 Received: from tot-dmz-mxgoog1.delacy.com ([172.27.224.14] helo=mxgoog2.janestreet.com) by tot-smtp with esmtps (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1VAU2J-0004K3-P3 for caml-list@inria.fr; Fri, 16 Aug 2013 20:06:31 -0400 Received: from mail-ea0-f182.google.com ([209.85.215.182]) by mxgoog2.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1VAU2J-0000SS-L4 for caml-list@inria.fr; Fri, 16 Aug 2013 20:06:31 -0400 Received: by mail-ea0-f182.google.com with SMTP id o10so1266223eaj.41 for ; Fri, 16 Aug 2013 17:06:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=Z9Fjg2yE9k0K58PH3x4cgR3PBX9jkeAY5Gfnn8OuezU=; b=umk7qztYtD0J40Sh6+W+8pLX6kDBmD+qA+ZffCbs6RLdo6KIePnRKjFeegf5JZf909 mjGVCPeT3nu5tpCAVtNdmbcPu915VsJ4B9cmmrWRBRADDVUlx3N/l5ExBYcp3v2clVTX TkHPNblXNiKkb92egoeOIDrwUt+DnRmOPqgDo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=Z9Fjg2yE9k0K58PH3x4cgR3PBX9jkeAY5Gfnn8OuezU=; b=XXcP5mIYsKQGkcOLkI7Y4QlgbXEt6+T/KAcMMKZe3wMtXVqIaG+4bmcn/JabFT/pX/ /IMDe3db4PLMkk0UKZmLS4hIOlkay1eSQCFYi9qNDIPdnLchdzP5TBHFjR7SIL9FcVLh vKAzR+TXCLUqW3E+6Iq4LuNuHyL5PbQx36pwaCBUAvyWskFFWFg2PKnFb2I58bBsOPgy bPmrzSVI2KwETPCCiZgZbZSFcw7OsAJgO4FA9CVYm0HKlVP6HpPtQrnwc8YKov2YG4oX wfHAx6fYLpNjnq12ffOgJS+H9fnIQgZstIX02TeuoJ5Cg9bouUrzusgBqIBmUqcbQOOU g50A== X-Gm-Message-State: ALoCoQmaItx3iRd7xX1L3GwR9g2niVzuyyy0NtduGDfAcfDEdf4MD/lCgrhP9SGRaMnlD0EkvYGEm4jTw+wElgf99k2IVv7UCWLqd6l/ELuXpIIKvdVawkfqPn8+EtRtZYHXkFqWQ++zY4g+hkDcVgxFfkxFxVILXQ== X-Received: by 10.15.54.199 with SMTP id t47mr463583eew.46.1376697991077; Fri, 16 Aug 2013 17:06:31 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.15.54.199 with SMTP id t47mr463573eew.46.1376697990971; Fri, 16 Aug 2013 17:06:30 -0700 (PDT) Received: by 10.223.43.65 with HTTP; Fri, 16 Aug 2013 17:06:30 -0700 (PDT) In-Reply-To: References: <520DE6F8.9000105@etorok.net> Date: Fri, 16 Aug 2013 20:06:30 -0400 Message-ID: From: Yaron Minsky To: Markus Mottl Cc: =?ISO-8859-1?Q?T=F6r=F6k_Edwin?= , "caml-list@inria.fr" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] Threads and "transaction isolation" in OCaml I'd like to second Markus' request here. We definitely take advantage of this behavior in the compiler, and I hadn't realized that it didn't hold in byte-code. I do think this is a rather valuable hack, and it would be good to make the bounds of its applicability more explicit. y On Fri, Aug 16, 2013 at 12:07 PM, Markus Mottl wro= te: > On Fri, Aug 16, 2013 at 4:46 AM, T=F6r=F6k Edwin wrote: >> I wrote a little test program and this is not true for bytecode -vmthrea= d, but seems to work for bytecode -thread and native -thread: > > Thanks for this example. It's not surprising that this trick does not > work with VM-threads, but I have never seen anybody use them for > anything so I'm not bothered by this. > > But, surprisingly to me, I did manage to get a failure with byte code > + POSIX threads when running this example on Linux (Centos 6.4) via > VMware Fusion (Mac OS X). I admittedly have never thoroughly tested > these "transactions" with any sort of byte code, since I practically > exclusively run native code. Still, I would have expected the runtime > to work identically here. Interestingly, I couldn't replicate the > error on a VPS running the same OS and compiler, but using Xen (via > Linode) instead of VMware Fusion for virtualization. > > Note that some open source libraries, e.g. the Nano_mutex module in > Jane Street Core, depend on this trick so it seems important to figure > out how safe and portable it really is. It would be a huge pity to do > without, since it can offer quite dramatic performance improvements > for certain applications. > > Does anybody know a reason why byte code + POSIX threads might fail > with this trick? > >> I'd consider this very fragile as you'd need to know the implementation = details of every function you call (or only calling your own safe functions= ). I was surprised to find out that even Array.fold_left creates a temporar= y ref for example. > > It would certainly be unwise to call any function whose implementation > is not fixed and fully understood wrt. transaction isolation. This > trick is obviously low-level and its use should be clearly documented > by the developer. Most of the time it will only consist of a few > assignments or pattern-matches anyway. > > Regards, > Markus > > -- > Markus Mottl http://www.ocaml.info markus.mottl@gmail.com > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs