/* create client connection */ int db_connect( db_conn_t * conn ) { int rc; /* Connect to database */ rc = sqlite3_open( lmgr_config.db_config.filepath, conn ); if ( rc != 0 ) { if ( *conn ) { DisplayLog( LVL_CRIT, LISTMGR_TAG, "Failed to connect to SQLite DB (file %s): Error: %s", lmgr_config.db_config.filepath, sqlite3_errmsg( *conn ) ); } else { DisplayLog( LVL_CRIT, LISTMGR_TAG, "Failed to connect to SQLite DB (file %s): Error: %d", lmgr_config.db_config.filepath, rc ); } return DB_CONNECT_FAILED; } DisplayLog( LVL_FULL, LISTMGR_TAG, "Logged on to database successfully" ); set_cache_size( *conn ); return DB_SUCCESS; }
bool basic_jit_cache::initialize(void) { if (cache_size == 0) set_cache_size(JIT_CACHE_SIZE); return tcode_start && cache_size; }
int main(int argc, char *argv[]) { int i; int num_offs; char *root_conf_file; char *data_file; if (argc < 3) { fprintf(stderr, "test root_conf data_file\n"); return -1; } root_conf_file = argv[1]; data_file = argv[2]; if (file_per_proc) num_offs = data_size / block_size / num_threads; else num_offs = data_size / block_size; offs = (off_t *) malloc(num_offs * sizeof(off_t)); for (i = 0; i < num_offs; i++) offs[i] = i * (long) block_size; rand_permute_array(offs, num_offs); printf("generate random offsets\n"); signal(SIGINT, int_handler); int node_ids[num_nodes]; for (i = 0; i < num_nodes; i++) node_ids[i] = i; ssd_init_io_system(root_conf_file, node_ids, num_nodes); if (file_per_proc) set_cache_size(512 * 1024 * 1024 / num_threads); printf("init IO system\n"); char file_name_buf[128]; char *file_name; #ifdef PROFILER ProfilerStart(prof_file); #endif struct thread_data data[num_threads]; long start = get_curr_ms(); for (i = 0; i < num_threads; i++) { data[i].idx = i; data[i].node_id = i % num_nodes; if (file_per_proc) { data[i].off_start = 0; data[i].num = num_offs; } else { data[i].num = num_offs / num_threads; data[i].off_start = i * data[i].num; } if (file_per_proc) { sprintf(file_name_buf, "%s.%08d", data_file, data[i].idx); file_name = file_name_buf; int suggested_nodes[1] = {data->node_id}; ssd_file_io_init(file_name, 0, 1, 1, suggested_nodes); } else { file_name = data_file; ssd_file_io_init(file_name, 0, num_threads, num_nodes, NULL); } printf("init file IO\n"); printf("open file %s\n", file_name); strncpy(data[i].file_name, file_name, sizeof(data[i].file_name)); int ret; if (sync) ret = pthread_create(&data[i].tid, NULL, SyncThreadWriteOrRead, (void *) &data[i]); else ret = pthread_create(&data[i].tid, NULL, AsyncThreadWriteOrRead, (void *) &data[i]); assert(ret == 0); } for (i = 0; i < num_threads; i++) pthread_join(data[i].tid, NULL); long end = get_curr_ms(); #ifdef PROFILER ProfilerStop(); #endif printf("It takes %ld ms\n", end - start); }