Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115982 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 71618 invoked from network); 7 Sep 2021 07:51:12 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Sep 2021 07:51:12 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4AC80180505 for ; Tue, 7 Sep 2021 01:28:38 -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=-2.1 required=5.0 tests=BAYES_00,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-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (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 ; Tue, 7 Sep 2021 01:28:37 -0700 (PDT) Received: by mail-ed1-f41.google.com with SMTP id q3so12789550edt.5 for ; Tue, 07 Sep 2021 01:28:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5P+YucalKdb9DbuhUx91DpfHVfgdsICxLGc9sTmIIgw=; b=NBVSqJvPkJT11wEKkJDiL68CoBYBkJhbDptclvJcjcFZPXd2v99AP+Eu3Ry7oHoT7h mEiK9wXcmxjF4RqoXNJ4pqa0C3xotj+KmztEG0bqAvuXCPtAHfKZOQ9UxINE5OBGq+dL yk6dZBcyWRUuYlUOqretcgaVXxlaC4UFjCVxy7PDytG832+mYJvMiHTIXxb7S8ELLT+5 kxDpsR3OZpRUpIkHZqDzyyn8PQcUpoISeQEZYNln7/pkqyOf6JSorcbBC0hULzDtCsLo ZD/mcIoNIXyjuEMM9jkt7OalQVnD9xfsHrKptsMaNutLaGPLO69FfTgLxZHVxN6fSJsE ZEbw== 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:cc; bh=5P+YucalKdb9DbuhUx91DpfHVfgdsICxLGc9sTmIIgw=; b=rsx3TvJrcgdlA/nDEkMYU6G0Y8sb7WiQvURPTR61OdfC83zFGdg8CsS9YXTrJUSI9E PU26qLqkjsvR8qNt1SqHR3SoSqtJ4qC9yYXOxip+J1vp00Mtx2JVbBVvFZDIm0bVlfV+ LWyytBu1tOS+bvRPC5popx/urKoaTA748EisluZOwXMYtJpBnhjVv1zIlzDKhzdSS0cE u0W8iw/Bnaw4w7QcK5rHaOOIjb3thuruiVvVWKKgOmkdIzLnhDUzOHVHq/MPOslV4F+7 76kqee+7pZ3dA4RSMwe63b5E7sKLx6nhY0Vz19sWIlVdGD1Q5tiFEedYusKL4Usg0X8q +8Aw== X-Gm-Message-State: AOAM532r1yF/R8rWcmJOwT6f6iCodvl4wKJoUw0kawShI8SI8Dveo1d9 J8Tf2jNUdI5W62etGxykqbzUASJPo4nj+LejFUhy7F6uEBM= X-Google-Smtp-Source: ABdhPJxH2OtYgcsL/nKIaO2ZVe5xuHITIPD+Gn+D2ZKsraoM9mhMjnVxZLnjwalSPbCrSEmkF+354meGEMr0BMI0rU8= X-Received: by 2002:a05:6402:1cbc:: with SMTP id cz28mr17361229edb.370.1631003315613; Tue, 07 Sep 2021 01:28:35 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 7 Sep 2021 10:28:19 +0200 Message-ID: To: Go Kudo Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000004133c005cb638d3e" Subject: Re: [PHP-DEV] [RFC] Random Extension 3.0 From: nikita.ppv@gmail.com (Nikita Popov) --0000000000004133c005cb638d3e Content-Type: text/plain; charset="UTF-8" On Thu, Sep 2, 2021 at 5:10 PM Go Kudo wrote: > Hi Internals. > > Expanded from the previous RFC and changed it to an RFC that organizes the > whole PHP random number generator. Also, the target version has been > changed to 8.2. > > https://wiki.php.net/rfc/rng_extension > https://github.com/php/php-src/pull/7453 > > Hopefully you will get some good responses. > This RFC currently tries to keep some semblance of compatibility with the existing mt_rand() algorithm by retaining the same implementation for mapping the raw random number stream into a range. However, the algorithm we use for that is not exactly state of the art and requires two full-width divisions at minimum. There are more efficient scaling algorithms based on fixed-point multiplication, which are "nearly divisionless" ( https://arxiv.org/pdf/1805.10941.pdf). The variant at https://github.com/apple/swift/pull/39143 is entirely divisionless. Doing this would improve performance (though I'm not sure by how much -- maybe once we add up our call overhead, it isn't important anymore?) but it would provide a different sequence than mt_rand(). Something we might want to consider. Regards, Nikita --0000000000004133c005cb638d3e--