Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112154 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 62504 invoked from network); 31 Oct 2020 00:48:33 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 31 Oct 2020 00:48:33 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1949A1804D1 for ; Fri, 30 Oct 2020 17:08:04 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,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-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (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 ; Fri, 30 Oct 2020 17:08:03 -0700 (PDT) Received: by mail-pf1-f176.google.com with SMTP id 10so6682460pfp.5 for ; Fri, 30 Oct 2020 17:08:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=7cKJY9IEeuXnslUlwzyRLCRbF8qgpoTNI2ZKoE326dU=; b=LhSKw1352YxFZz1/bvPzHtYffE+BoAXJIRmWNRdGVpXo8CmzfE/096X9Io0zv+OFxi 08P/bCuqAU12rvK07uEJ963hGNL9q8Rr+JLqXE6YqB+/vyct0JbLLl4bfAQmnUIUH7Pw /RM+sOz71gQ4vD1gOiygQOz3Hh3BEBga60zL2ilqGVe0DSUc+P9pGWg5cMNC87fhDV0N Kblq/c1r7Ce1A1J66tvX0meCGo1xXPiAw7lJXgtUpb0BL9U4rqDRIlCXgh7fDGv8G9SX MvI3BIptLBiDyinLdvKqKW5zkQiuHZ6UjewCFJMFrW5LqrZL0qAUcICOheskfUyqqYDZ 5ocw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=7cKJY9IEeuXnslUlwzyRLCRbF8qgpoTNI2ZKoE326dU=; b=UYjRKfvR0SWcvitMRLjdmpZJNyXBSV91UzAcveb9N5WWG97GcLKdV3me+xdzzl9+p+ GdSbho7cG/quh/v4RJ9DjB7eQm1AzVtSKiNd6ZSzonf6dAlX0Xg9o68254gmZQZ9Q6Gj 86wEo1zwo7wzkUGPQ/FpTA82q+7xsSLAExfLUb7Rf/CDddHIrTvBHpa/wW/JgcDqRJ61 2Y+I6VSYDSPI/RrNFIbaE8MrsDmUyNdXBm6oF3ND8m7RQyr0YWw+ReM5dlbbkbZxhhAN 0Xc/ufM0o+dpN4QdMnA64BvnyiOFOAZxFhNLDjCPGVUVQhrrrG4mfN91mKIfXwGns1RR swmg== X-Gm-Message-State: AOAM5333HJ1sYe2xKF9K/2k8PywBfuUNKCnLYaP55zxiEvsQC4Qca2YI Y2FgwnYlKGeuEm8eVLMjylQfm8GxqX7pIwcCNVDVk24D/QZFSw== X-Google-Smtp-Source: ABdhPJwFliFnZ+2HCakDbDffIILAg66dnwmw+AGzZzJ/nbEuyrJuCqR/VmTSIjbC69lkz+yKKCcsJwtBJyawpuWhI7k= X-Received: by 2002:a63:4d0f:: with SMTP id a15mr4089518pgb.250.1604102880688; Fri, 30 Oct 2020 17:08:00 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 31 Oct 2020 01:07:49 +0100 Message-ID: To: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: hash BLAKE3 From: divinity76@gmail.com (Hans Henrik Bergan) hmm i'll try again, made another PR: https://github.com/php/php-src/pull/6393 this PR is an alternative to https://github.com/php/php-src/pull/6358 with some notable differences, - this PR is roughly 1700 SLOC, compared to #6358 at roughly 31,000 SLOC - this PR only bundles the "portable C" version of BLAKE3, it does not contain any of the SSE/AVX/NEON cpu-optimized non-portable implementations (hence the huge SLOC difference) the idea here is that just having BLAKE3 supported in PHP, even if it's not the most performant implementation, is better than no support at all, unsurprisingly, the portable version of BLAKE3 isn't nearly as fast as in #6358 , being beaten by MD4 (still beats MD5 though), but it still does a pretty good job in /ext/hash/bech.php, being roughly 1.9 times faster than sha3-224 on my laptop (compared to 4.2 times faster in #6358 ), and being the fastest secure hash on the list, for exact numbers check the PR. thoughts? On Wed, 21 Oct 2020 at 21:34, Hans Henrik Bergan wrote: > > i want BLAKE3 hash support in php, > > some justifications can be found here https://bugs.php.net/bug.php?id=79492 > primary reasons being that it's a "cryptographically secure hash", > predecessor BLAKE was nearly crowned "SHA3" (SHA3 finalist), > and it's very fast in software, > when i run it against php-src/ext/hash/bench.php , on a cpu without > the most beneficial instruction-set available, it was still over 4 > times faster than sha3-224, outperforming even several > non-crypto-hashes, exact numbers here: > https://github.com/php/php-src/pull/6358#issuecomment-713506971 ) > > i have a PR here: https://github.com/php/php-src/pull/6358 > initially had several issues, but i think most of them are resolved now, > > - SSE/AVX optimizations are added for "gcc+(unix|windows)+x86_64" targets, > and i have asked the php-windows mailing list for help in adding > SSE/AVX optimizations to the MSVC builds, > but for the time being, MSVC builds are just using a portable generic > C implementation. > it would also be possible to add an optimized implementation for > ARM+Neon targets, i haven't looked into that at all. > > - currently the code is rolling it's own cpu feature detection, > instead of asking Zend/zend_cpuinfo.c (specifically > ext/hash/blake3/blake3_dispatch.c ), > is that something that "must be fixed" before upstream merging can be > considered? or is it ok-ish? > > - frankly, there's just *a lot* of code in there, is it possible that > it will be rejected just because "it's too much code" ? (there's a > reason there's so much code though, it contains cpu-specific > implementations for a lot of different environments, compilers, OS's, > and CPU's, from SSE2 to AVX512 to ARM+Neon, also a much smaller > implementation using just the "portable generic C implementation" > would be possible, at the cost of performance)