php-src/ext/random
Tim Düsterhus 31e2d2b86c
random: Optimize Randomizer::getBytes() (#15228)
This patch greatly improves the performance for the common case of using a
64-bit engine and requesting a length that is a multiple of 8.

It does so by providing a fast path that will just `memcpy()` (which will be
optimized out) the returned uint64_t directly into the output buffer,
byteswapping it for big endian architectures.

The existing byte-wise copying logic was mostly left alone. It only received an
optimization of the shifting and masking that was previously applied to
`Randomizer::getBytesFromString()` in 1fc2ddc996.

Co-authored-by: Saki Takamachi <saki@php.net>
2024-08-05 19:12:29 +02:00
..
tests random: Deprecate lcg_value() (#15211) 2024-08-04 18:24:21 +02:00
config.m4 random: Remove engine_combinedlcg.c (#15216) 2024-08-04 18:26:15 +02:00
config.w32 random: Remove engine_combinedlcg.c (#15216) 2024-08-04 18:26:15 +02:00
CREDITS
csprng.c Rename HAVE_DECL_ARC4RANDOM_BUF to HAVE_ARC4RANDOM_BUF (#14565) 2024-06-13 22:36:05 +02:00
engine_mt19937.c Use zend_std_build_properties() to access zend_object.properties 2024-07-18 22:18:38 +02:00
engine_pcgoneseq128xslrr64.c random: Add PHPAPI to all php_random_algo definitions (#14088) 2024-04-30 21:01:13 +02:00
engine_secure.c random: Add PHPAPI to all php_random_algo definitions (#14088) 2024-04-30 21:01:13 +02:00
engine_user.c random: Add PHPAPI to all php_random_algo definitions (#14088) 2024-04-30 21:01:13 +02:00
engine_xoshiro256starstar.c random: Add PHPAPI to all php_random_algo definitions (#14088) 2024-04-30 21:01:13 +02:00
gammasection.c random: Pass algorithm and state together as php_random_algo_with_state (#13350) 2024-02-25 20:48:58 +01:00
php_random_csprng.h random: Make php_random_bytes() useable early during engine startup (#14291) 2024-05-30 17:24:34 +02:00
php_random_uint128.h random: Split the uint128 implementation into its own header (#13132) 2024-01-17 16:07:45 +01:00
php_random_zend_utils.h Add zend_random_bytes(), zend_random_bytes_insecure() functions (#14054) 2024-06-12 17:27:01 +02:00
php_random.h random: Optimize Randomizer::getBytes() (#15228) 2024-08-05 19:12:29 +02:00
random_arginfo.h random: Deprecate lcg_value() (#15211) 2024-08-04 18:24:21 +02:00
random.c random: Remove engine_combinedlcg.c (#15216) 2024-08-04 18:26:15 +02:00
random.stub.php random: Deprecate lcg_value() (#15211) 2024-08-04 18:24:21 +02:00
randomizer.c random: Optimize Randomizer::getBytes() (#15228) 2024-08-05 19:12:29 +02:00
zend_utils.c Add zend_random_bytes(), zend_random_bytes_insecure() functions (#14054) 2024-06-12 17:27:01 +02:00