Implement next-gen APC storage engine (APCng) #72
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.
This PR deprecates the older PR #37 and solves Issue #36 . It also fixes a few places where Issue #27 can crop up, for instance if an APC value is deleted by another process at just the right moment, the
APCengine would spin forever waiting forapcu_casto succeed - this solves the problem by limiting the number of iterations we will wait.README.APCng.mdincludes detailed benchmarking results comparing the originalAPCengine vs this newAPCngengine, as requested by @LKaemmerling . Also as requested, this is implemented as a new Storage engine type, since the storage format is not compatible. Either theAPCorAPCngengine may be employed by users, both are currently treated equally andAPCremains unchanged.I put a fair amount of effort into a semi-automated performance-test "mini suite", including some assertions around performance of
APCngrelative toAPC(basically: it should be much faster forcollect()calls, and approximately the same speed for all other calls to the storage layer). This "Performance" PHPUnit group is excluded by default, since it takes many minutes to complete, but the README files include instructions on how to run this test suite. PHPUnit isn't the best tool for the job, but I do like the ability to make assertions about relative performance, and it beats trying to write up my own test harness and make it work cross-platform.By comparing the
src/Prometheus/Storage/APCng.phpwith theAPC.phpfrom #37 , one can see the overall structure of the engine is very similar, so most of the comments from that PR about the storage structure and function are still relevant. However, a few changes have been made to improve stability and speed, and remove complex code that offers little actual performance increase, based on real-world experience in our production environment. SeeREADME.APCng.mdfor a more-detailed description of how the engine works.I am happy to answer questions or respond/engage in any other ways needed for anyone reviewing this PR, just let me know!