Skip to content

Extend admission policies, statistics, add multi thread eviction and promotion #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from

Conversation

igchor
Copy link

@igchor igchor commented Jun 29, 2022

Please take a look at https://github.com/pmem/CacheLib/blob/9dbbc6d6cc994312bf7d47bc3a9a174ae6a52bb3/BackgroundMovers.md for eviction description.

Most new config options are here:

double promotionAcWatermark{97.0};

This change is Reviewable

@igchor igchor force-pushed the in_progress_promotion branch from dec1628 to 5a58a6d Compare June 29, 2022 12:15
@igchor
Copy link
Author

igchor commented Jun 29, 2022

TODO:

  • fix test compilation
  • add tests for all new config params + promotion + eviction
  • distribute allocation classes to BG promoter/evictor based on size/hotness of allocation classes
  • print slabsAllocatedPercentage and acAllocatedPercentage in cachebench
    I see some strange behavior here: for larger allocation classes, we are evicting too much (in terms of percents)
  • fix promotion stats

@igchor igchor force-pushed the in_progress_promotion branch 3 times, most recently from 401bf23 to 9476e5c Compare July 5, 2022 11:54
@igchor igchor mentioned this pull request Jul 5, 2022
@igchor igchor force-pushed the in_progress_promotion branch 2 times, most recently from 1716061 to 66a317f Compare July 5, 2022 14:09
@raema
Copy link
Collaborator

raema commented Jul 5, 2022

Hi Igor, currently some monitoring scripts expect the format below. If we use this format the scripts will pick up the metrics. The other format would work as well, we just need to modify some monitor scripts.

== Class Background Promotion Counters Map ==
Class 64 : 28676862698660485
Class 96 : 28676860978156165
Class 144 : 28676859257651845
Class 216 : 28676864419164805
Class 328 : 28676862698660485
Class 496 : 28676860978156165
Class 744 : 28676859257651845
Class 1120 : 28676864419164805
Class 1680 : 28676862698660485
Class 2520 : 28676860978156165
Class 3784 : 28676859257651845
Class 5680 : 28676864419164805
Class 8520 : 28676862698660485
Class 12784 : 28676860978156165
Class 19232 : 28676859257651845
Class 28920 : 28676864419164805
Class 43688 : 28676862698660485
Class 65536 : 28676860978156165
Class 99864 : 28676859257651845
Class 155344 : 28676864419164805
Class 233016 : 28676862698660485
Class 381296 : 28676860978156165
Class 599184 : 28676859257651845
Class 1048576 : 28676864419164805

@igchor
Copy link
Author

igchor commented Jul 6, 2022

@raema I extracted the memory usage stats to separate PR: #91
Can you take a look if the format is fine?

@igchor igchor force-pushed the in_progress_promotion branch 5 times, most recently from 625c23c to 9cd86c5 Compare July 12, 2022 14:18
@raema
Copy link
Collaborator

raema commented Jul 13, 2022

Hi @igchor, can we use the same output format for -report_memory_usage_stats for this branch?

== Class Background Eviction Counters Map ==
Eviction Class 1  :  2534549
Eviction Class 2  :  9361373
Eviction Class 3  :  14011676
Eviction Class 4  :  13478359
Eviction Class 5  :  13318040
Eviction Class 6  :  10341963
Eviction Class 7  :  5314650
Eviction Class 8  :  1682540
Eviction Class 9  :  703919
Eviction Class 10  :  542128
Eviction Class 11  :  443432
Eviction Class 12  :  66225
Eviction Class 13  :  21960
Eviction Class 14  :  22024
Eviction Class 15  :  33506
Eviction Class 16  :  134238
Eviction Class 17  :  29135
Eviction Class 18  :  35891
Eviction Class 19  :  12394
Eviction Class 20  :  11
== Class Background Promotion Counters Map ==
Promotion Class 10  :  4094
Promotion Class 11  :  35
Promotion Class 14  :  7184
Promotion Class 15  :  14189
Promotion Class 16  :  19432
Promotion Class 17  :  22341
Promotion Class 18  :  32894
Promotion Class 19  :  12364
tid 0 free slabs : 0.00%
tid 1 free slabs : 0.00%
tid 0 pid 0 cid   0    64.00B memorySize:     0.00B
tid 0 pid 0 cid   1    96.00B memorySize:    36.00MB
tid 0 pid 0 cid   2   144.00B memorySize:   124.00MB
tid 0 pid 0 cid   3   216.00B memorySize:   276.00MB
tid 0 pid 0 cid   4   328.00B memorySize:   744.00MB
tid 0 pid 0 cid   5   496.00B memorySize:   992.00MB
tid 0 pid 0 cid   6   744.00B memorySize:   508.00MB
tid 0 pid 0 cid   7     1.09KB memorySize:   416.00MB
tid 0 pid 0 cid   8     1.64KB memorySize:   212.00MB
tid 0 pid 0 cid   9     2.46KB memorySize:   132.00MB
tid 0 pid 0 cid  10     3.70KB memorySize:   152.00MB
tid 0 pid 0 cid  11     5.55KB memorySize:   136.00MB
tid 0 pid 0 cid  12     8.32KB memorySize:    36.00MB
tid 0 pid 0 cid  13    12.48KB memorySize:    20.00MB
tid 0 pid 0 cid  14    18.78KB memorySize:    20.00MB
tid 0 pid 0 cid  15    28.24KB memorySize:    32.00MB
tid 0 pid 0 cid  16    42.66KB memorySize:   200.00MB
tid 0 pid 0 cid  17    64.00KB memorySize:    36.00MB
tid 0 pid 0 cid  18    97.52KB memorySize:    12.00MB
tid 0 pid 0 cid  19   151.70KB memorySize:     4.00MB
tid 0 pid 0 cid  20   227.55KB memorySize:     4.00MB
tid 0 pid 0 cid  21   372.36KB memorySize:     0.00B
tid 0 pid 0 cid  22   585.14KB memorySize:     0.00B
tid 0 pid 0 cid  23     1.00MB memorySize:     0.00B
tid 1 pid 0 cid   0    64.00B memorySize:     0.00B
tid 1 pid 0 cid   1    96.00B memorySize:    40.00MB
tid 1 pid 0 cid   2   144.00B memorySize:   124.00MB
tid 1 pid 0 cid   3   216.00B memorySize:   272.00MB
tid 1 pid 0 cid   4   328.00B memorySize:   760.00MB
tid 1 pid 0 cid   5   496.00B memorySize:   984.00MB
tid 1 pid 0 cid   6   744.00B memorySize:   508.00MB
tid 1 pid 0 cid   7     1.09KB memorySize:   424.00MB
tid 1 pid 0 cid   8     1.64KB memorySize:   208.00MB
tid 1 pid 0 cid   9     2.46KB memorySize:   136.00MB
tid 1 pid 0 cid  10     3.70KB memorySize:   148.00MB
tid 1 pid 0 cid  11     5.55KB memorySize:   132.00MB
tid 1 pid 0 cid  12     8.32KB memorySize:    32.00MB
tid 1 pid 0 cid  13    12.48KB memorySize:    16.00MB
tid 1 pid 0 cid  14    18.78KB memorySize:    20.00MB
tid 1 pid 0 cid  15    28.24KB memorySize:    32.00MB
tid 1 pid 0 cid  16    42.66KB memorySize:   208.00MB
tid 1 pid 0 cid  17    64.00KB memorySize:    32.00MB
tid 1 pid 0 cid  18    97.52KB memorySize:    12.00MB
tid 1 pid 0 cid  19   151.70KB memorySize:     4.00MB
tid 1 pid 0 cid  20   227.55KB memorySize:     0.00B
tid 1 pid 0 cid  21   372.36KB memorySize:     0.00B
tid 1 pid 0 cid  22   585.14KB memorySize:     0.00B
tid 1 pid 0 cid  23     1.00MB memorySize:     0.00B
tid 0 pid 0 cid   0    64.00B free: 100.00%
tid 0 pid 0 cid   1    96.00B free: 0.00%
tid 0 pid 0 cid   2   144.00B free: 0.00%
tid 0 pid 0 cid   3   216.00B free: 0.00%
tid 0 pid 0 cid   4   328.00B free: 0.00%
tid 0 pid 0 cid   5   496.00B free: 0.00%
tid 0 pid 0 cid   6   744.00B free: 0.01%
tid 0 pid 0 cid   7     1.09KB free: 0.02%
tid 0 pid 0 cid   8     1.64KB free: 0.02%
tid 0 pid 0 cid   9     2.46KB free: 0.02%
tid 0 pid 0 cid  10     3.70KB free: 0.04%
tid 0 pid 0 cid  11     5.55KB free: 0.06%
tid 0 pid 0 cid  12     8.32KB free: 0.06%
tid 0 pid 0 cid  13    12.48KB free: 0.03%
tid 0 pid 0 cid  14    18.78KB free: 0.04%
tid 0 pid 0 cid  15    28.24KB free: 0.02%
tid 0 pid 0 cid  16    42.66KB free: 0.01%
tid 0 pid 0 cid  17    64.00KB free: 0.00%
tid 0 pid 0 cid  18    97.52KB free: 0.00%
tid 0 pid 0 cid  19   151.70KB free: 0.00%
tid 0 pid 0 cid  20   227.55KB free: 61.11%
tid 0 pid 0 cid  21   372.36KB free: 100.00%
tid 0 pid 0 cid  22   585.14KB free: 100.00%
tid 0 pid 0 cid  23     1.00MB free: 100.00%
tid 1 pid 0 cid   0    64.00B free: 100.00%
tid 1 pid 0 cid   1    96.00B free: 0.00%
tid 1 pid 0 cid   2   144.00B free: 0.00%
tid 1 pid 0 cid   3   216.00B free: 0.00%
tid 1 pid 0 cid   4   328.00B free: 0.00%
tid 1 pid 0 cid   5   496.00B free: 0.00%
tid 1 pid 0 cid   6   744.00B free: 0.01%
tid 1 pid 0 cid   7     1.09KB free: 0.02%
tid 1 pid 0 cid   8     1.64KB free: 0.02%
tid 1 pid 0 cid   9     2.46KB free: 0.02%
tid 1 pid 0 cid  10     3.70KB free: 0.04%
tid 1 pid 0 cid  11     5.55KB free: 0.06%
tid 1 pid 0 cid  12     8.32KB free: 0.06%
tid 1 pid 0 cid  13    12.48KB free: 0.03%
tid 1 pid 0 cid  14    18.78KB free: 0.04%
tid 1 pid 0 cid  15    28.24KB free: 0.02%
tid 1 pid 0 cid  16    42.66KB free: 0.01%
tid 1 pid 0 cid  17    64.00KB free: 0.00%
tid 1 pid 0 cid  18    97.52KB free: 0.00%
tid 1 pid 0 cid  19   151.70KB free: 0.00%
tid 1 pid 0 cid  20   227.55KB free: 100.00%
tid 1 pid 0 cid  21   372.36KB free: 100.00%
tid 1 pid 0 cid  22   585.14KB free: 100.00%
tid 1 pid 0 cid  23     1.00MB free: 100.00%

@igchor
Copy link
Author

igchor commented Jul 14, 2022

@raema Sure, I'll change it

Copy link
Collaborator

@vinser52 vinser52 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 36 files reviewed, 1 unresolved discussion (waiting on @igchor and @vinser52)


cachelib-background-evictor.png line 0 at r1 (raw file):
As we agreed, we should avoid using PMEM. Let's make the picture more abstract.

Copy link
Author

@igchor igchor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 36 files reviewed, 1 unresolved discussion (waiting on @byrnedj and @vinser52)


cachelib-background-evictor.png line at r1 (raw file):

Previously, vinser52 (Sergei Vinogradov) wrote…

As we agreed, we should avoid using PMEM. Let's make the picture more abstract.

@byrnedj could you please fix the picture? I don't think I have access to the source image.

Copy link
Author

@igchor igchor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 36 files reviewed, 2 unresolved discussions (waiting on @byrnedj and @vinser52)


-- commits line 12 at r1:
@vinser52 what do you think about this patch? Are you OK with merging this for now and possibly reverting later (once we enable transparent synchronization for chained items)?

Right now, in my patch, we do not use any extra synchronization for items being moved - we just use moveCb (or fallback to memcpy if none is provided). This should be fine for cachebench and Jimmy also said it's fine for them.

Copy link
Collaborator

@vinser52 vinser52 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 36 files reviewed, 5 unresolved discussions (waiting on @byrnedj, @igchor, and @vinser52)


MultiTierDataMovement.md line 20 at r1 (raw file):

## Background Evictors

The background evictors scan each class to see if there are objects to move the next (higher)

Are we talking about eviction or promotion thread here? If it is an eviction thread then "move to the next (higher) tier" is confusing, it should "down" instead of "higher".
Right?


MultiTierDataMovement.md line 39 at r1 (raw file):

- `maxEvictionBatch`: The number of objects to remove in a given eviction call. The
default is 40. Lower range is 10 and the upper range is 1000. Too low and we might not
remove objects at a reasonable rate, too high and we hold the locks for copying data

I believe that we exposing implementation details with that phrase: "we hold the locks for copying data". Probably better to say that it might increase contention with user threads.


MultiTierDataMovement.md line 47 at r1 (raw file):

- `maxEvictionPromotionHotness`: Maximum candidates to consider for eviction. This is similar to `maxEvictionBatch`
but it specifies how many candidates will be taken into consideration, not the actual number of items to evict.
This option can be used to configure duration of critical section on LRU lock.

The same as the previous comment. We are exposing implementation details. Let's be less specific.

@igchor igchor force-pushed the in_progress_promotion branch from 4d177fd to 682cee4 Compare August 3, 2022 13:51
Copy link
Author

@igchor igchor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raema Done. Output is now:

== Class Background Eviction Counters Map ==
tid 0 pid 0 cid   1 evicted: 132064
tid 0 pid 0 cid   2 evicted: 332206
tid 0 pid 0 cid   3 evicted: 488053
tid 0 pid 0 cid   4 evicted: 888834
tid 0 pid 0 cid   5 evicted: 777947
tid 0 pid 0 cid   6 evicted: 266416
tid 0 pid 0 cid   7 evicted: 133270
tid 0 pid 0 cid   8 evicted: 111095
tid 0 pid 0 cid   9 evicted: 111005
tid 0 pid 0 cid  10 evicted: 111015
tid 0 pid 0 cid  11 evicted: 111000
tid 0 pid 0 cid  12 evicted: 106050
tid 0 pid 0 cid  13 evicted: 89620
tid 0 pid 0 cid  14 evicted: 89615
tid 0 pid 0 cid  15 evicted: 89635
tid 0 pid 0 cid  16 evicted: 107845
tid 0 pid 0 cid  17 evicted: 84529
tid 0 pid 0 cid  18 evicted: 60725
tid 0 pid 0 cid  19 evicted: 39425
== Class Background Promotion Counters Map ==
tid 1 pid 0 cid   1 promoted:   85
tid 1 pid 0 cid   2 promoted:  156
tid 1 pid 0 cid   3 promoted:  165
tid 1 pid 0 cid   4 promoted:  110
tid 1 pid 0 cid   5 promoted:  115
tid 1 pid 0 cid   6 promoted:   95
tid 1 pid 0 cid   7 promoted:  110
tid 1 pid 0 cid   8 promoted:  150
tid 1 pid 0 cid   9 promoted:  100
tid 1 pid 0 cid  10 promoted:   90
tid 1 pid 0 cid  11 promoted:  125
tid 1 pid 0 cid  12 promoted: 80681
tid 1 pid 0 cid  13 promoted: 81997
tid 1 pid 0 cid  14 promoted: 83309
tid 1 pid 0 cid  15 promoted: 83151
tid 1 pid 0 cid  16 promoted: 76818
tid 1 pid 0 cid  17 promoted: 81311
tid 1 pid 0 cid  18 promoted: 59994
tid 1 pid 0 cid  19 promoted: 39424

Reviewable status: 0 of 36 files reviewed, 5 unresolved discussions (waiting on @byrnedj and @vinser52)


MultiTierDataMovement.md line 20 at r1 (raw file):

Previously, vinser52 (Sergei Vinogradov) wrote…

Are we talking about eviction or promotion thread here? If it is an eviction thread then "move to the next (higher) tier" is confusing, it should "down" instead of "higher".
Right?

Right, something went wrong here. Done.


MultiTierDataMovement.md line 39 at r1 (raw file):

Previously, vinser52 (Sergei Vinogradov) wrote…

I believe that we exposing implementation details with that phrase: "we hold the locks for copying data". Probably better to say that it might increase contention with user threads.

Done.


MultiTierDataMovement.md line 47 at r1 (raw file):

Previously, vinser52 (Sergei Vinogradov) wrote…

The same as the previous comment. We are exposing implementation details. Let's be less specific.

Done.

@igchor igchor force-pushed the in_progress_promotion branch from 682cee4 to 42e103a Compare August 3, 2022 13:54
igchor and others added 3 commits August 9, 2022 10:02
and add additional parameters to control allocation
and eviction of items.

Co-authored-by: Daniel Byrne <[email protected]>
instead of relying on transparent synchronization mechanims
(wait context).
@igchor igchor force-pushed the in_progress_promotion branch from 42e103a to b7300e2 Compare August 9, 2022 14:42
Hot queue iterator for 2Q. Will start at Hot queue and move to Warm queue if hot queue is exhausted. Useful for promotion semantics if using 2Q replacement. rebased on to develop and added some tests.
@igchor igchor force-pushed the in_progress_promotion branch from b7300e2 to a3e29dd Compare August 9, 2022 14:52
@igchor igchor closed this Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants