Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113263 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 13357 invoked from network); 25 Feb 2021 12:32:40 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Feb 2021 12:32:40 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EC5171804E4 for ; Thu, 25 Feb 2021 04:21:39 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-vs1-f48.google.com (mail-vs1-f48.google.com [209.85.217.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 25 Feb 2021 04:21:39 -0800 (PST) Received: by mail-vs1-f48.google.com with SMTP id p123so2808750vsp.6 for ; Thu, 25 Feb 2021 04:21:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=sbLgBTWz6mVJk9Yy6cW0qmtgUtNF57OudDTBsagxl8M=; b=RQa538jBLkw66is6x0VbJUHrqMr/4D5OhjnwA2uiiLe3FsxcDX186GjFnQbQlg/UTv S2gQIJqscoyhIQ8WJSaNQct17y2+7EDf+C8x3fZjL/tDcWqaz5xkc0fFNKpi3rfEg40J 7MMjN8NiMd4XoHb5iCx/Sitddc1LO+w44Foc1/I8qqFsDPEZC/5ASDynLoGZXLzai3Pp hJSWx3WvFeA12DTh4EW4Ul7V73bOfGLmsUBTDuDqF3h+rs03MpVQJnravN9FH03cMzJi NpQFHvaZ4BuYTaLtoC3CSf2rZ6uIzgjj1LxtLKwwha5lsmyRIj1DRoD5jhiGneckohfZ 2J/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=sbLgBTWz6mVJk9Yy6cW0qmtgUtNF57OudDTBsagxl8M=; b=V8+Zj8ZX+jRuda6DrL7r4DQQE/ycImkhYmxJHkdCKf/u3S+y+1s/sPs4ZF3aGpFsbb 9oaUDJYdDJ3njnOMVvm/psaG/qr4HfPAcJ1dR80oWdPdQ8S4u+t37mf8zjP+Mi5tthhZ 9c8c+DdeOuWZ1EVVRwSPLjscGPDfqCWqhFkoLVK4P7A8mMKpa6hj13HkHxe+uZ0fxosE cuanL1kqSRU8+4LJ2t+zuoM10jkojjWwF5RZJ81qXjE6PwMYnI9iQHda26I96ejD6/C2 lQ1tNpT8XhATANv7r/ePgTNSzx5DsN+wJgNdbLSoly10qTfJnVLNzvcgtQjA2q00zMQZ 0MlA== X-Gm-Message-State: AOAM5302gy2LBBTyPymjWc3zFmWZ03GnPkGbqgwZNe14kI9do/e1Rhc1 EW+M7N+n4cJXKoDDcGNi4XlARGOmlCGwITzWyKA= X-Google-Smtp-Source: ABdhPJzCGPFX50c4Nl4DsVLjZwIPubkCnn2qSdGeI3CxLFJFcOhE4S/mt9Ft6dEqTlWvEZGtwQuCLbzR9baQ7xvPQuI= X-Received: by 2002:a05:6102:2433:: with SMTP id l19mr1362706vsi.46.1614255697015; Thu, 25 Feb 2021 04:21:37 -0800 (PST) MIME-Version: 1.0 Date: Thu, 25 Feb 2021 15:21:25 +0300 Message-ID: To: Derick Rethans , PHP Internals Content-Type: multipart/alternative; boundary="00000000000065b4a005bc2831f3" Subject: timelib inefficiency From: dmitrystogov@gmail.com (Dmitry Stogov) --00000000000065b4a005bc2831f3 Content-Type: text/plain; charset="UTF-8" Hi Derick, Please take a look https://github.com/php/php-src/blob/51914610ab8bf75d87e5cdec15bd1b38de7907c5/ext/date/lib/parse_date.re#L684-L700 This code is enormously inefficient. For a single abbr_search(), it calls timelib_strcasecmp() more than 1000 times (complete linear search in a huge almost ordered array, with repeatable and redundant lowercasing). 11 calls to abbr_search() per request in the Symfony Demo application ( https://github.com/symfony/demo) eat 2% of overall CPU time. I see some other inefficient patterns in timelib. e.g. API design that leads to many useless heap allocations/deallocations; calloc() followed by memcpy(), etc Thanks. Dmitry. --00000000000065b4a005bc2831f3--