Motr  M0
crate_index.c File Reference
#include <errno.h>
#include "lib/bitmap.h"
#include "lib/trace.h"
#include "lib/time.h"
#include "motr/m0crate/logger.h"
#include "motr/m0crate/crate_client.h"
#include "motr/m0crate/crate_client_utils.h"
Include dependency graph for crate_index.c:

Go to the source code of this file.

Data Structures

struct  cr_time_measure_ctx
 
struct  cr_idx_ops_result
 
struct  cr_idx_w_results
 
struct  cr_ops_counter
 
struct  cr_idx_w
 
struct  kv_pair
 
struct  cr_idx_w_ops
 
struct  cr_watchdog
 

Macros

#define LOG_PREFIX   "dix: "
 

Typedefs

typedef int(* cr_idx_w_find_k_t) (struct cr_idx_w *w, enum cr_opcode opcode, int *keys, size_t nr_keys)
 

Enumerations

enum  { CR_MAX_OF_MAX_KEY_SIZE = (1 << 20), CR_MIN_KEY_SIZE = sizeof(struct m0_fid), CR_MAX_OF_MAX_VALUE_SIZE = (1 << 30), CR_MAX_NEXT_RECORDS = (1 << 30) }
 
enum  cr_op_selector { CR_OP_SEL_RR, CR_OP_SEL_RND }
 

Functions

static int cr_rand_pos_range (int end)
 
static size_t cr_rand_pos_range_l (size_t end)
 
static bool cr_rand_bool ()
 
static void cr_get_random_string (char *dest, size_t length)
 
static double cr_time_in_seconds (m0_time_t mtime)
 
static void cr_time_measure_begin (struct cr_time_measure_ctx *t)
 
static double cr_time_measure_elapsed_now (struct cr_time_measure_ctx *t)
 
static void cr_time_measure_end (struct cr_time_measure_ctx *t)
 
static void m0_bitmap_print (struct m0_bitmap *bm)
 
static int cr_watchdog_init (struct m0_workload_index *wt)
 
static void cr_watchdog_fini ()
 
static void cr_watchdog_touch ()
 
static const char * crate_op_to_string (enum cr_opcode op)
 
static bool cr_opcode_valid (enum cr_opcode opcode)
 
static int cr_idx_w_init (struct cr_idx_w *ciw, struct m0_workload_index *wit)
 
static void cr_idx_w_fini (struct cr_idx_w *ciw)
 
static void cr_idx_w_seq_keys_init (struct cr_idx_w *w, int keys_nr)
 
static void cr_idx_w_seq_keys_fini (struct cr_idx_w *w)
 
static int cr_idx_w_seq_keys_get_last (struct cr_idx_w *w, int nr, enum cr_opcode op)
 
static bool cr_idx_w_seq_keys_enabled (struct cr_idx_w *w)
 
static void cr_idx_w_seq_keys_save (struct cr_idx_w *w, int *keys, size_t keys_nr, enum cr_opcode op)
 
static size_t cr_idx_w_get_value_size (struct cr_idx_w *w)
 
static int cr_idx_w_get_nr_keys_per_op (struct cr_idx_w *w, enum cr_opcode op)
 
static int cr_idx_w_find_seq_k (struct cr_idx_w *w, enum cr_opcode opcode, int *keys, size_t nr_keys)
 
static int cr_idx_w_find_rnd_k (struct cr_idx_w *w, enum cr_opcode opcode, int *keys, size_t nr_keys)
 
static bool cr_idx_w_timeout_expired (struct cr_idx_w *w)
 
static int cr_idx_w_execute (struct cr_idx_w *w, enum cr_opcode opcode, bool random, size_t nr_keys, bool *missing_key)
 
static int cr_idx_w_get_nr_remained_ops (struct cr_idx_w *w)
 
static enum cr_opcode cr_idx_w_select_op (struct cr_idx_w *w)
 
static int cr_idx_w_get_nr_remained_op_types (struct cr_idx_w *w)
 
static void cr_idx_w_print_ops_table (struct cr_idx_w *w)
 
static bool cr_idx_w_rebalance_ops (struct cr_idx_w *w, enum cr_opcode op)
 
static int cr_idx_w_common (struct cr_idx_w *w)
 
static int cr_idx_w_warmup (struct cr_idx_w *w)
 
static void cr_time_capture_results (struct cr_time_measure_ctx *t, struct cr_idx_w *ciw)
 
static void cr_time_measure_report (struct cr_time_measure_ctx *t, struct cr_idx_w w)
 
static void idx_bufvec_free (struct m0_bufvec *bv)
 
static void kv_pair_fini (struct kv_pair *p)
 
static struct m0_bufvecidx_bufvec_alloc (int nr)
 
static int fill_kv_del (struct cr_idx_w *w, struct m0_fid *k, struct kv_pair *p, size_t nr, int kpart_one_size, char *kpart_one)
 
static int fill_kv_next (struct cr_idx_w *w, struct m0_fid *k, struct kv_pair *p, size_t nr, int kpart_one_size, char *kpart_one)
 
static int fill_kv_get (struct cr_idx_w *w, struct m0_fid *k, struct kv_pair *p, size_t nr, int kpart_one_size, char *kpart_one)
 
static int fill_kv_put (struct cr_idx_w *w, struct m0_fid *k, struct kv_pair *p, size_t nr, int kpart_one_size, char *kpart_one)
 
static M0_UNUSED bool int_array_is_set (int *vals, size_t nr)
 
static bool m0_bitmap_is_fulfilled (struct m0_bitmap *bm, bool fill)
 
static int cr_execute_query (struct m0_fid *id, struct kv_pair *p, enum cr_opcode opcode)
 
static enum cr_opcode cr_idx_w_select_op_rr (struct cr_idx_w *w, int depth)
 
static M0_UNUSED int delete_index (struct m0_uint128 id)
 
static int create_index (struct m0_uint128 id)
 
static void cr_watchdog_thread (void *arg)
 
static int index_operation (struct workload *wt, struct m0_workload_task *task)
 
void run_index (struct workload *w, struct workload_task *tasks)
 
void m0_op_run_index (struct workload *w, struct workload_task *task, const struct workload_op *op)
 

Variables

char * cr_idx_op_labels [CRATE_OP_NR]
 
struct cr_watchdogcr_watchdog = NULL
 
struct cr_idx_w_ops cr_idx_w_ops [CRATE_OP_NR]
 

Macro Definition Documentation

◆ LOG_PREFIX

#define LOG_PREFIX   "dix: "

Logger prefix for DIX workload

Definition at line 144 of file crate_index.c.

Typedef Documentation

◆ cr_idx_w_find_k_t

typedef int(* cr_idx_w_find_k_t) (struct cr_idx_w *w, enum cr_opcode opcode, int *keys, size_t nr_keys)

Definition at line 801 of file crate_index.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Global constants for DIX workload

Enumerator
CR_MAX_OF_MAX_KEY_SIZE 

Upper limit for max_key_size parameter. i.e 1MB

CR_MIN_KEY_SIZE 

Lower limit for key_size parameter. i.e 16 Bytes

CR_MAX_OF_MAX_VALUE_SIZE 

Upper limit for max_value_size parameter. i.e 1GB

CR_MAX_NEXT_RECORDS 

Upper limit for next_records parameter. ie 1GB

Definition at line 161 of file crate_index.c.

◆ cr_op_selector

Enumerator
CR_OP_SEL_RR 

Operations should be selected in round-robin maner.

CR_OP_SEL_RND 

Operations should be selected randomly

Definition at line 172 of file crate_index.c.

Function Documentation

◆ cr_execute_query()

static int cr_execute_query ( struct m0_fid id,
struct kv_pair p,
enum cr_opcode  opcode 
)
static

Definition at line 976 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_get_random_string()

static void cr_get_random_string ( char *  dest,
size_t  length 
)
static

Get random string

Definition at line 208 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_idx_w_common()

static int cr_idx_w_common ( struct cr_idx_w w)
static

Definition at line 1254 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_idx_w_execute()

static int cr_idx_w_execute ( struct cr_idx_w w,
enum cr_opcode  opcode,
bool  random,
size_t  nr_keys,
bool *  missing_key 
)
static

Definition at line 1050 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_idx_w_find_rnd_k()

static int cr_idx_w_find_rnd_k ( struct cr_idx_w w,
enum cr_opcode  opcode,
int *  keys,
size_t  nr_keys 
)
static

Definition at line 932 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_idx_w_find_seq_k()

static int cr_idx_w_find_seq_k ( struct cr_idx_w w,
enum cr_opcode  opcode,
int *  keys,
size_t  nr_keys 
)
static

Definition at line 890 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_idx_w_fini()

static void cr_idx_w_fini ( struct cr_idx_w ciw)
static

Definition at line 552 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_idx_w_get_nr_keys_per_op()

static int cr_idx_w_get_nr_keys_per_op ( struct cr_idx_w w,
enum cr_opcode  op 
)
static

Definition at line 669 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_idx_w_get_nr_remained_op_types()

static int cr_idx_w_get_nr_remained_op_types ( struct cr_idx_w w)
static

Definition at line 1214 of file crate_index.c.

Here is the caller graph for this function:

◆ cr_idx_w_get_nr_remained_ops()

static int cr_idx_w_get_nr_remained_ops ( struct cr_idx_w w)
static

Definition at line 1144 of file crate_index.c.

Here is the caller graph for this function:

◆ cr_idx_w_get_value_size()

static size_t cr_idx_w_get_value_size ( struct cr_idx_w w)
static

Definition at line 654 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_idx_w_init()

static int cr_idx_w_init ( struct cr_idx_w ciw,
struct m0_workload_index wit 
)
static

Definition at line 453 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_idx_w_print_ops_table()

static void cr_idx_w_print_ops_table ( struct cr_idx_w w)
static

Definition at line 1228 of file crate_index.c.

Here is the caller graph for this function:

◆ cr_idx_w_rebalance_ops()

static bool cr_idx_w_rebalance_ops ( struct cr_idx_w w,
enum cr_opcode  op 
)
static

Definition at line 1238 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_idx_w_select_op()

static enum cr_opcode cr_idx_w_select_op ( struct cr_idx_w w)
static

Definition at line 1190 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_idx_w_select_op_rr()

static enum cr_opcode cr_idx_w_select_op_rr ( struct cr_idx_w w,
int  depth 
)
static

Definition at line 1156 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_idx_w_seq_keys_enabled()

static bool cr_idx_w_seq_keys_enabled ( struct cr_idx_w w)
static

Definition at line 583 of file crate_index.c.

Here is the caller graph for this function:

◆ cr_idx_w_seq_keys_fini()

static void cr_idx_w_seq_keys_fini ( struct cr_idx_w w)
static

Definition at line 568 of file crate_index.c.

Here is the caller graph for this function:

◆ cr_idx_w_seq_keys_get_last()

static int cr_idx_w_seq_keys_get_last ( struct cr_idx_w w,
int  nr,
enum cr_opcode  op 
)
static

Definition at line 573 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_idx_w_seq_keys_init()

static void cr_idx_w_seq_keys_init ( struct cr_idx_w w,
int  keys_nr 
)
static

Definition at line 558 of file crate_index.c.

Here is the caller graph for this function:

◆ cr_idx_w_seq_keys_save()

static void cr_idx_w_seq_keys_save ( struct cr_idx_w w,
int *  keys,
size_t  keys_nr,
enum cr_opcode  op 
)
static

Definition at line 588 of file crate_index.c.

Here is the caller graph for this function:

◆ cr_idx_w_timeout_expired()

static bool cr_idx_w_timeout_expired ( struct cr_idx_w w)
static

Definition at line 1043 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_idx_w_warmup()

static int cr_idx_w_warmup ( struct cr_idx_w w)
static

Definition at line 1297 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_opcode_valid()

static bool cr_opcode_valid ( enum cr_opcode  opcode)
static

Definition at line 869 of file crate_index.c.

Here is the caller graph for this function:

◆ cr_rand_bool()

static bool cr_rand_bool ( )
static

Get random boolean value

Definition at line 202 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_rand_pos_range()

static int cr_rand_pos_range ( int  end)
static

Get pseudo-random int32 in positive range [0;end)

Definition at line 181 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_rand_pos_range_l()

static size_t cr_rand_pos_range_l ( size_t  end)
static

Get pseudo-random uint64 in positive range [0;end)

Definition at line 187 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_time_capture_results()

static void cr_time_capture_results ( struct cr_time_measure_ctx t,
struct cr_idx_w ciw 
)
static

capture final results

Definition at line 387 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_time_in_seconds()

static double cr_time_in_seconds ( m0_time_t  mtime)
static

Definition at line 270 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_time_measure_begin()

static void cr_time_measure_begin ( struct cr_time_measure_ctx t)
static

Definition at line 276 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_time_measure_elapsed_now()

static double cr_time_measure_elapsed_now ( struct cr_time_measure_ctx t)
static

Definition at line 282 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_time_measure_end()

static void cr_time_measure_end ( struct cr_time_measure_ctx t)
static

Definition at line 289 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_time_measure_report()

static void cr_time_measure_report ( struct cr_time_measure_ctx t,
struct cr_idx_w  w 
)
static

RESULT REPORT

Definition at line 410 of file crate_index.c.

Here is the caller graph for this function:

◆ cr_watchdog_fini()

static void cr_watchdog_fini ( )
static

Definition at line 1463 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_watchdog_init()

static int cr_watchdog_init ( struct m0_workload_index wt)
static

Definition at line 1439 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_watchdog_thread()

static void cr_watchdog_thread ( void *  arg)
static

Definition at line 1407 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cr_watchdog_touch()

static void cr_watchdog_touch ( )
static

Definition at line 1426 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ crate_op_to_string()

static const char * crate_op_to_string ( enum cr_opcode  op)
static

Definition at line 864 of file crate_index.c.

Here is the caller graph for this function:

◆ create_index()

static int create_index ( struct m0_uint128  id)
static

Definition at line 1359 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete_index()

static M0_UNUSED int delete_index ( struct m0_uint128  id)
static

Definition at line 1318 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fill_kv_del()

static int fill_kv_del ( struct cr_idx_w w,
struct m0_fid k,
struct kv_pair p,
size_t  nr,
int  kpart_one_size,
char *  kpart_one 
)
static

Definition at line 682 of file crate_index.c.

Here is the call graph for this function:

◆ fill_kv_get()

static int fill_kv_get ( struct cr_idx_w w,
struct m0_fid k,
struct kv_pair p,
size_t  nr,
int  kpart_one_size,
char *  kpart_one 
)
static

Definition at line 733 of file crate_index.c.

Here is the call graph for this function:

◆ fill_kv_next()

static int fill_kv_next ( struct cr_idx_w w,
struct m0_fid k,
struct kv_pair p,
size_t  nr,
int  kpart_one_size,
char *  kpart_one 
)
static

Definition at line 707 of file crate_index.c.

Here is the call graph for this function:

◆ fill_kv_put()

static int fill_kv_put ( struct cr_idx_w w,
struct m0_fid k,
struct kv_pair p,
size_t  nr,
int  kpart_one_size,
char *  kpart_one 
)
static

Definition at line 762 of file crate_index.c.

Here is the call graph for this function:

◆ idx_bufvec_alloc()

static struct m0_bufvec* idx_bufvec_alloc ( int  nr)
static

Definition at line 629 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ idx_bufvec_free()

static void idx_bufvec_free ( struct m0_bufvec bv)
static

Definition at line 607 of file crate_index.c.

Here is the caller graph for this function:

◆ index_operation()

static int index_operation ( struct workload wt,
struct m0_workload_task task 
)
static

Definition at line 1474 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ int_array_is_set()

static M0_UNUSED bool int_array_is_set ( int *  vals,
size_t  nr 
)
static

Check if all values in array is unique

Definition at line 875 of file crate_index.c.

Here is the caller graph for this function:

◆ kv_pair_fini()

static void kv_pair_fini ( struct kv_pair p)
static

Definition at line 623 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_bitmap_is_fulfilled()

static bool m0_bitmap_is_fulfilled ( struct m0_bitmap bm,
bool  fill 
)
static

Definition at line 927 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_bitmap_print()

static void m0_bitmap_print ( struct m0_bitmap bm)
static

Definition at line 296 of file crate_index.c.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ cr_idx_op_labels

char* cr_idx_op_labels[CRATE_OP_NR]
Initial value:
= {
"PUT",
"GET",
"NEXT",
"DEL"
}

Definition at line 238 of file crate_index.c.

◆ cr_idx_w_ops

Definition at line 825 of file crate_index.c.

◆ cr_watchdog

Definition at line 311 of file crate_index.c.