From b3f00685ec6c04c67fc9db809fbb63cb1696881e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Botond=20D=C3=A9nes?= Date: Tue, 1 Sep 2020 12:14:52 +0300 Subject: [PATCH] scylla-gdb.py: scylla memory: better summary of semaphore memory usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If available, use the recently added `reader_concurrency_semaphore::_initial_resources` to calculate the amount of memory used out of the initially configured amount. If not available, the summary falls back to the previous mode of just printing the remaining amount of memory. Example: Replica: Read Concurrency Semaphores: user sstable reads: 11/100, 263621214/ 42949672 B, queued: 847 streaming sstable reads: 0/ 10, 0/ 42949672 B, queued: 0 system sstable reads: 1/ 10, 251584/ 42949672 B, queued: 0 Signed-off-by: Botond Dénes Message-Id: <20200901091452.806419-1-bdenes@scylladb.com> --- scylla-gdb.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/scylla-gdb.py b/scylla-gdb.py index fd5f88dfa2..1a235d57cb 100644 --- a/scylla-gdb.py +++ b/scylla-gdb.py @@ -1423,24 +1423,30 @@ class scylla_memory(gdb.Command): def print_replica_stats(): db = sharded(gdb.parse_and_eval('::debug::db')).local() + try: + mem_stats = dict() + for key, sem in [('user_mem_str', db['_read_concurrency_sem']), ('streaming_mem_str', db['_streaming_concurrency_sem']), ('system_mem_str', db['_system_read_concurrency_sem'])]: + mem_stats[key] = '{:>13}/{:>13} B'.format(int(sem['_initial_resources']['memory'] - sem['_resources']['memory']), int(sem['_initial_resources']['memory'])) + except gdb.error: # <= 4.2 compatibility + for key, sem in [('user_mem_str', db['_read_concurrency_sem']), ('streaming_mem_str', db['_streaming_concurrency_sem']), ('system_mem_str', db['_system_read_concurrency_sem'])]: + mem_stats[key] = 'remaining mem: {:>13} B'.format(int(sem['_resources']['memory'])) + gdb.write('Replica:\n') gdb.write(' Read Concurrency Semaphores:\n' - ' user sstable reads: {user_sst_rd_count:>3}/{user_sst_rd_max_count:>3}, remaining mem: {user_sst_rd_mem:>13} B, queued: {user_sst_rd_queued}\n' - ' streaming sstable reads: {streaming_sst_rd_count:>3}/{streaming_sst_rd_max_count:>3}, remaining mem: {system_sst_rd_mem:>13} B, queued: {streaming_sst_rd_queued}\n' - ' system sstable reads: {system_sst_rd_count:>3}/{system_sst_rd_max_count:>3}, remaining mem: {system_sst_rd_mem:>13} B, queued: {system_sst_rd_queued}\n' + ' user sstable reads: {user_sst_rd_count:>3}/{user_sst_rd_max_count:>3}, {user_mem_str}, queued: {user_sst_rd_queued}\n' + ' streaming sstable reads: {streaming_sst_rd_count:>3}/{streaming_sst_rd_max_count:>3}, {streaming_mem_str}, queued: {streaming_sst_rd_queued}\n' + ' system sstable reads: {system_sst_rd_count:>3}/{system_sst_rd_max_count:>3}, {system_mem_str}, queued: {system_sst_rd_queued}\n' .format( user_sst_rd_count=int(gdb.parse_and_eval('database::max_count_concurrent_reads')) - int(db['_read_concurrency_sem']['_resources']['count']), user_sst_rd_max_count=int(gdb.parse_and_eval('database::max_count_concurrent_reads')), - user_sst_rd_mem=int(db['_read_concurrency_sem']['_resources']['memory']), user_sst_rd_queued=int(db['_read_concurrency_sem']['_wait_list']['_size']), streaming_sst_rd_count=int(gdb.parse_and_eval('database::max_count_streaming_concurrent_reads')) - int(db['_streaming_concurrency_sem']['_resources']['count']), streaming_sst_rd_max_count=int(gdb.parse_and_eval('database::max_count_streaming_concurrent_reads')), - streaming_sst_rd_mem=int(db['_streaming_concurrency_sem']['_resources']['memory']), streaming_sst_rd_queued=int(db['_streaming_concurrency_sem']['_wait_list']['_size']), system_sst_rd_count=int(gdb.parse_and_eval('database::max_count_system_concurrent_reads')) - int(db['_system_read_concurrency_sem']['_resources']['count']), system_sst_rd_max_count=int(gdb.parse_and_eval('database::max_count_system_concurrent_reads')), - system_sst_rd_mem=int(db['_system_read_concurrency_sem']['_resources']['memory']), - system_sst_rd_queued=int(db['_system_read_concurrency_sem']['_wait_list']['_size']))) + system_sst_rd_queued=int(db['_system_read_concurrency_sem']['_wait_list']['_size']), + **mem_stats)) gdb.write(' Execution Stages:\n') for es_path in [('_data_query_stage',), ('_mutation_query_stage', '_execution_stage'), ('_apply_stage',)]: