From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.5 required=5.0 tests=SPF_SOFTFAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id D22B5BC37 for ; Wed, 29 Apr 2009 04:43:18 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtMBAFdb90mp5TxXe2dsb2JhbACWbgEBFiIFpnqHY4hNg3MF X-IronPort-AV: E=Sophos;i="4.40,264,1238968800"; d="scan'208";a="25330740" Received: from gateway0.eecs.berkeley.edu ([169.229.60.87]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 29 Apr 2009 04:43:17 +0200 Received: from [10.212.112.89] (bldmz-nat-161-164.berkeley.intel-research.net [12.155.161.164]) (authenticated bits=0) by gateway0.EECS.Berkeley.EDU (8.14.3/8.13.5) with ESMTP id n3T2hDDv002690 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT) for ; Tue, 28 Apr 2009 19:43:15 -0700 (PDT) Message-Id: <324B24CA-9671-42C0-B722-C7710C0C45C7@cs.berkeley.edu> From: Brighten Godfrey To: caml-list@yquem.inria.fr Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Subject: Strange performance bug Date: Tue, 28 Apr 2009 19:43:08 -0700 X-Mailer: Apple Mail (2.930.3) X-Spam: no; 0.00; bug:01 bug:01 compiler:01 pcre:01 pcre:01 unpack:01 ocaml:01 ocaml:01 ocamlc:01 ocamlopt:01 parsing:01 minor:01 tar:01 parse:02 seems:03 Hi, I've encountered a very odd performance problem which I suspect is not a bug in my code. Could it be the compiler, or maybe PCRE? Here's the story. I'm parsing a file (using the PCRE library in one step). It goes quickly. When I parse the same file a second time, it goes an order of magnitude more slowly. Using Str instead of PCRE fixes the problem, but I'm not ready to blame PCRE, because various other minor changes make the problem disappear too. I have tried to strip this program down to the smallest possible, but it appears to be sensitive to the details of the code in ways that I wouldn't expect, so I couldn't make it as small as I'd like. Entire package to reproduce the problem (unpack, make, then run "./ problem fast" or "./problem slow"): http://www.cs.berkeley.edu/~pbg/tmp/ocaml_performance_problem.tar.bz2 Just the code: http://www.cs.berkeley.edu/~pbg/tmp/problem.ml In case it matters, I am running OCaml 3.11.0 on Mac OS X 10.5.6 on Intel. The problem seems to happen with both ocamlc and ocamlopt. Can anyone else reproduce this problem or figure out what is going on? Am I doing something silly? Thanks so much, ~Brighten