Allow all entries to be soft_expired - #1
Open
t-tomalak wants to merge 42 commits into
Open
Conversation
We have a lot of keys put into the storage, but some of them with Day of TTL might be accessed only few times. We should allow such keys to be expired, and therefore remove check for entry->ttl.
mszabo-wikia
approved these changes
Sep 12, 2023
harnash
approved these changes
Sep 12, 2023
Cache entries now contain a reference to the previous entry or the head pointer of the linked list. This is to prepare for defragmentation, as it allows entries to be moved in memory if the address containing the reference to the current entry is not available in the context.
This adds defragmentation logic to apcu, which is performed during the default_expunge operation. It works by shifting all allocated blocks to the left (low addresses), allowing all free blocks to be coalesced to one larger free block on the right side.
Enable huge pages on Linux by calling mmap() with the MAP_HUGETLB flag. Using huge pages can improve performance when working with large amounts of shared memory. This PR adds the apc.mmap_hugepage_size setting, which accepts the huge page size.
This requires windows-2019, which is being phased out: actions/runner-images#12045
All PHP 7.x Linux pipelines silently aborted the tests because the PHP executable could not be found. This was caused by the definition of "PHP_EXECUTABLE = NONE" in the Makefile, as "php-config --php-binary" returned "NONE" during ./configure. Since it seems time-consuming to fix the root cause, this is a temporary workaround until PHP 7.x is removed from the CI pipeline.
…krakjoe#564) The access time and access statistics are now updated when using apcu_exists(). The documentation does not indicate that this function behaves differently than apcu_fetch() in this regard. This should also help to use values other than 0 for apc.ttl, since entries frequently checked with apcu_exists() no longer soft-expire.
…akjoe#570) The cache cleanup and defragmentation counts are now available in the array returned by apcu_cache_info().
A large portion of the TECHNOTES no longer reflected the current state of apcu. The TECHNOTES have therefore been revised to make it easier to get started. Since the copies of the struct definitions are not required to provide a general overview, they have been removed to avoid duplicate maintenance.
When using the zend_empty_array optimization, the process-local address of zend_empty_array was stored in shared memory during persistence, which is inconsistent with the relocatable representation. To indicate the use of zend_empty_array during unpersist, the entry's starting address is now used during persist instead.
…joe#577) The purpose of this test is to ensure that the unpersist-code does not accidentally change the persistence representation in SHM (e.g., by the offset -> pointer conversion), causing a second unpersist to fail.
A reference and an empty array have been added to the tested types. This allows the defragmentation test to verify whether references or the special case zend_empty_array work correctly after defragmentation.
Since PHP 8.5, a missing trait is no longer a fatal error. Therefore, we must use a different fatal error.
Under high load, multiple parallel insert operations could trigger multiple default expunge operations at the same time. To prevent this, pending default expunge operations are now aborted if another default expunge operation has run in the meantime.
This fixes a race condition that can occur when a newly allocated entry is moved by defragmentation before it is inserted into the hash table.
The comments for a legacy code folding mechanism and other useless comments have been removed. In addition, several other comments have been improved.
In apc_cache_store(), the ref_count was decremented even when the entry needed to be deleted. This allowed the entry to be moved by defragmentation (by another process) before deletion. As a result, the pointer no longer pointed to the desired entry during deletion, causing segmentation faults.
The "report_memleaks" ini directive is deprecated in PHP 8.5 and has therefore been removed from the tests.
The fprev field now stores the used memory size for allocated blocks. This is used during defragmentation to shrink blocks if more memory has been allocated than necessary.
The test has been removed because it serves no purpose anymore, as the opcode caching functionality was removed from the project long ago. Furthermore, the magic method __sleep() is deprecated in PHP 8.5, causing this test to fail the CI pipeline starting with PHP 8.5.
These files are no longer used by any test and have therefore been deleted.
The function sma_allocate() now inserts the unused part of a split block at the beginning of the free list, instead of reinserting it at the position of the original block. This prevents large blocks from falling behind in the list when many small blocks are inserted at the beginning of the list by sma_deallocate(). Benchmarks show that this improves allocation performance and reduces the time the SMA lock must be held.
The new functions link_free_block() and unlink_free_block_at_start() are used to insert or remove blocks from the free list. This improves readability and removes duplicate code. Also, some code comments have been refined.
This should never happen, but it should still be handled properly to avoid worse.
Since the array keys "cleanups" and "defragmentations" only exist since APCu 5.1.25, PHP warnings could occur if you are using a current version of apc.php with APCu versions <= 5.1.24.
Call zval_ptr_dtor_nogc() directly instead
Trying to insert entries larger than the shared memory no longer results in the whole cache being discarded.
chore(PLATFORM-11898): bump apcu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We have a lot of keys put into the storage, but some of them with Day of TTL might be accessed only few times. We should allow such keys to be expired, and therefore remove check for entry->ttl.