diff options
author | Mark Hagger <mark.hagger@grapeshot.com> | 2020-07-02 14:45:24 +0100 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2020-07-02 15:43:38 -0700 |
commit | 7bb69b80b1252d77766097567d1e1b40dd60775c (patch) | |
tree | e55665393bdc62ad24de8fca2aadcbadf5191688 /scripts | |
parent | e1bb1db06081d61e16ee42c791da22003357427b (diff) | |
download | memcached-7bb69b80b1252d77766097567d1e1b40dd60775c.tar.gz |
Improve page balancing when writes are bursty
Extention to the existing slab reallocation model to better cope with eviction patterns that appear in short timeframe bursts.
This means that if more than 25% of the total evictions in the window appear in this slab it becomes a candidate for
needing more pages.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/memcached-automove | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/scripts/memcached-automove b/scripts/memcached-automove index 4a3d3dd..a5b531c 100755 --- a/scripts/memcached-automove +++ b/scripts/memcached-automove @@ -31,7 +31,15 @@ args = parser.parse_args() host, port = args.host.split(':') -def window_check(history, sid, key): +def window_check_count(history, sid, key): + total = 0 + for window in history['w']: + s = window.get(sid) + if s and s.get(key): + total += s.get(key) > 0 and 1 or 0 + return total + +def window_check_sum(history, sid, key): total = 0 for window in history['w']: s = window.get(sid) @@ -75,14 +83,14 @@ def determine_move(history, diffs, totals): w[sid]['dirty'] = 1 if slab['evicted_d'] > 0: w[sid]['dirty'] = 1 - w[sid]['ev'] = 1 + w[sid]['ev'] = slab['evicted_d'] / totals['evicted_d'] w[sid]['age'] = slab['age'] - age = window_check(history, sid, 'age') / len(history['w']) + age = window_check_sum(history, sid, 'age') / len(history['w']) # if > 2.5 pages free, and not dirty, reassign to global page pool and # break. if slab['free_chunks'] > slab['chunks_per_page'] * 2.5: - if window_check(history, sid, 'dirty') == 0: + if window_check_sum(history, sid, 'dirty') == 0: decision = (sid, 0) break @@ -91,9 +99,13 @@ def determine_move(history, diffs, totals): oldest = (sid, age) # are we the youngest evicting slab class? - ev_total = window_check(history, sid, 'ev') + ev_total = window_check_count(history, sid, 'ev') + ev_total_sum = window_check_sum(history, sid, 'ev') / args.window window_min = args.window / 2 - if age < youngest[1] and ev_total > window_min: + if args.verbose: + print("sid {} age {} ev_total {} window_min {} ev_total_sum {}".format(sid, age, ev_total, window_min, ev_total_sum)) + # If youngest and evicted in more than 50% of the window interval, or more than 25% of the total evictions in the window + if age < youngest[1] and ( ev_total > window_min or ev_total_sum > 0.25 ): youngest = (sid, age) #if args.verbose: # print("window: {} range: {}".format(ev_total, window_min)) |