[php-src] PR #14107: Implement BCMath LRU cache
| From: | nielsdos | Date: | Wed, 01 May 2024 19:47:51 +0000 |
| Subject: | [php-src] PR #14107: Implement BCMath LRU cache | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-25983@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/14107
Author: nielsdos
This is a prototype for an LRU cache for operands used in BCMath.
We notice in profiles that parsing operands takes a long time (like over 30% for the benchmark in
#14076).
This PR implements a cache for the 16 most recently used operands, such that parsing can be avoided.
The underlying idea is that in a particular time window the same operands are likely to be used
again (*).
This implementation could probably be improved too performance-wise. One notable thing missing is
that results are not stored in the LRU cache yet.
(*) The question is whether this is true in real-world use-cases. If this is not true most of the
time, then a patch like this will cause a performance degradation because maintaining the LRU also
has some overhead.