improving dynamic zswap shrinker protection scheme
Status from this message: [merged mm-stable] zswap-track-swapins-from-disk-more-accurately.patch removed from -mm tree
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest2 patches 7 repliesApplied 2/4
- v22 patches 6 repliesSuperseded
- v12 patches 9 repliesSuperseded
v2 from the cover letter
* Add more details in comments, patch changelog, documentation, etc. about the second chance scheme and its ability to modulate the writeback rate (patch 1) (suggested by Yosry Ahmed).
* Move the referenced bit (patch 1) (suggested by Yosry Ahmed).
Patches in v3 Applied · 2/4
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | zswap: implement a second chance algorithm for dynamic zswap shrinkerinclude/ mm/ | +70 | 3 replies | Applied |
| 1/2 | zswap: implement a second chance algorithm for dynamic zswap shrinker (fix)mm/ | +2 | 1 reply | |
| 2/2 | zswap: track swapins from disk more accuratelymm/ mm/ | +12 | 3 replies | Applied |
| 2/2 | zswap: track swapins from disk more accurately (fix)mm/ | +1 | 0 replies |
Reviews trailers per patch
All 4 patches have a Reviewed-by or Acked-by.
| Patch | Yosry Ahmed | Johannes Weiner |
|---|---|---|
| 1/2 | A-b A-b | A-b |
| 1/2 | A-b A-b | A-b |
| 2/2 | A-b | A-b |
| 2/2 | A-b | A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v3 0/2] improving dynamic zswap shrinker protection scheme
v3: No (intended) functional change
* Small cleanups, renamings, etc. (suggested by Yosry Ahmed)
v2:
* Add more details in comments, patch changelog, documentation, etc. about the second chance scheme and its ability to modulate the writeback rate (patch 1) (suggested by Yosry Ahmed).
* Move the referenced bit (patch 1) (suggested by Yosry Ahmed).
When experimenting with the memory-pressure based (i.e "dynamic") zswap shrinker in production, we observed a sharp increase in the number of swapins, which led to performance regression. We were able to trace this regression to the following problems with the shrinker's warm pages protection scheme:
1. The protection decays way too rapidly, and the decaying is coupled with zswap stores, leading to anomalous patterns, in which a small batch of zswap stores effectively erase all the protection in place for the warmer pages in the zswap LRU.
This observation has also been corroborated upstream by Takero Funaki (in [1]).
2. We inaccurately track the number of swapped in pages, missing the non-pivot pages that are part of the readahead window, while counting the pages that are found in the zswap pool.
To alleviate these two issues, this patch series improve the dynamic zswap shrinker in the following manner:
1. Replace the protection size tracking scheme with a second chance algorithm. This new scheme removes the need for haphazard stats decaying, and automatically adjusts the pace of pages aging with memory pressure, and writeback rate with pool activities: slowing down when the pool is dominated with zswpouts, and speeding up when the pool is dominated with stale entries.
2. Fix the tracking of the number of swapins to take into account non-pivot pages in the readahead window.
With these two changes in place, in a kernel-building benchmark without any cold data added, the number of swapins is reduced by 64.12%. This translate to a 10.32% reduction in build time. We also observe a 3% reduction in kernel CPU time.
In another benchmark, with cold data added (to gauge the new algorithm's ability to offload cold data), the new second chance scheme outperforms the old protection scheme by around 0.7%, and actually written back around 21% more pages to backing swap device. So the new scheme is just as good, if not even better than the old scheme on this front as well.
[1]: https://lore.kernel.org/linux-mm/CAPpodddcGsK=0Xczfuk8usgZ47xeyf4ZjiofdT+ujiyz6V2pFQ@mail.gmail.com/
Nhat Pham (2):
zswap: implement a second chance algorithm for dynamic zswap shrinker
zswap: track swapins from disk more accurately
include/linux/zswap.h | 16 +++---- mm/page_io.c | 11 ++++- mm/swap_state.c | 8 +--- mm/zswap.c | 108 ++++++++++++++++++++++++------------------ 4 files changed, 82 insertions(+), 61 deletions(-)
base-commit: cca1345bd26a67fc61a92ff0c6d81766c259e522
Signature · 1 line
2.43.0