Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66067 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61415 invoked from network); 20 Feb 2013 18:37:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Feb 2013 18:37:45 -0000 Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.210.169 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.210.169 mail-ia0-f169.google.com Received: from [209.85.210.169] ([209.85.210.169:60252] helo=mail-ia0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 99/2A-19387-8F715215 for ; Wed, 20 Feb 2013 13:37:44 -0500 Received: by mail-ia0-f169.google.com with SMTP id j5so7568641iaf.28 for ; Wed, 20 Feb 2013 10:37:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=cnIFKejigIWsted+TOECPeHPPftGD0+NIX9/tbCTVtY=; b=QMppziqp6Thm3pqmgzSxn7HwiM5MPu6AuzbPG5WK2Mk+r0aXm955YJm9jCmKow1noH gitIMoX4Z5auzLlkxE5tu0uzrlR4Sa/5kS78VNzlSfYLvxG1Abm95p+ZfAn2mIG1jP5+ +Rm500tQi3tYojzpjJh0skZCGminm46fJXvHg+jwN6Q+Jv6uRf8OccbsykRF1b9PtNI9 qxcov3b0wShJqWtieHlFmK5IgI5ReFd4iF3YACWpJDKmENOp3dbtcPZVjFJCjmPtSGFn infeKDX5VuPwBR8BgeR12DkFsdMog9ZKG2qW/L2PbePpVo5jff55n89ufgSgN60fGntW v+7A== MIME-Version: 1.0 X-Received: by 10.50.180.228 with SMTP id dr4mr10924842igc.17.1361385461591; Wed, 20 Feb 2013 10:37:41 -0800 (PST) Received: by 10.50.114.137 with HTTP; Wed, 20 Feb 2013 10:37:41 -0800 (PST) In-Reply-To: References: Date: Wed, 20 Feb 2013 19:37:41 +0100 Message-ID: To: Paul Taulborg , Derick Rethans Cc: PHP Internals Content-Type: multipart/alternative; boundary=14dae93408c5d730a004d62c402d Subject: Re: [PHP-DEV] date/strtotime poor performance - further digging (v 5.4.9) From: tyra3l@gmail.com (Ferenc Kovacs) --14dae93408c5d730a004d62c402d Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, Dec 4, 2012 at 5:58 PM, Paul Taulborg wrote: > So, I've been going through the internals of date() and related, > trying to isolate where some poor performance is, to try and find ways > to optimize it. In doing so, I came across this: > > On line 863 of ext/date/php_date.c is this code: > } else if (*DATEG(default_timezone) && > timelib_timezone_id_is_valid(DATEG(default_timezone), tzdb)) { > > I noticed it's checking every time that the timezone is "still" valid. > Commenting this out results in a tremendous speed increase. From my > tests before, I saw 3.3 seconds for strtotime, and 1.75s for date. > After commenting out the timelib_timezone_id_is_valid check above, > speed increased to 2.3s and 1.2s respectively! (Tests are run 1 > million times each) > > It immediately jumped out at me, because on a few lines prior is > initializes DATEG(default_timezone) and checks to make sure it's valid > there. Additionally, in PHP_FUNCTION(date_default_timezone_set) it > also checks to ensure it is a valid timezone. > > Having only glanced at what ini_set() does internally, I can presume > this check is there to prevent a bad value being set via that command? > However, I'm not certain it directly writes the value to > DATEG(default_timezone), so it may not be relevant at all. If it does, > some better cursory bounds checking in ini_set() might save a lot of > redundant bounds checking during runtime calls. It would also make > more sense to error them out on the ini_set() line rather than on a > date() call that was the result of an improperly configured value. > > Rather than spending time digging into that when it may not be > applicable I figured I'd ask here if anyone is more familiar with the > inner-workings of ini_set and other globals that can give me some > insight into this? Seems like an easy optimization to make, if I'm not > missing something else. > > Thanks! > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > Hi, Derick, could you please spare some to look into this (and maybe to look into the couple of patches sent to the list from Paul)? Thanks! --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --14dae93408c5d730a004d62c402d--