Commit 293a684e authored by Rich Prohaska's avatar Rich Prohaska

#87 add callback to allow loader memory size to be a session variable

parent 1ed8c69b
...@@ -459,7 +459,7 @@ static void print_db_env_struct (void) { ...@@ -459,7 +459,7 @@ static void print_db_env_struct (void) {
"void (*change_fsync_log_period) (DB_ENV*, uint32_t)", "void (*change_fsync_log_period) (DB_ENV*, uint32_t)",
"int (*iterate_live_transactions) (DB_ENV *env, iterate_transactions_callback callback, void *extra)", "int (*iterate_live_transactions) (DB_ENV *env, iterate_transactions_callback callback, void *extra)",
"int (*iterate_pending_lock_requests) (DB_ENV *env, iterate_requests_callback callback, void *extra)", "int (*iterate_pending_lock_requests) (DB_ENV *env, iterate_requests_callback callback, void *extra)",
"void (*set_loader_memory_size)(DB_ENV *env, uint64_t loader_memory_size)", "void (*set_loader_memory_size)(DB_ENV *env, uint64_t (*get_loader_memory_size_callback)(void))",
"uint64_t (*get_loader_memory_size)(DB_ENV *env)", "uint64_t (*get_loader_memory_size)(DB_ENV *env)",
NULL}; NULL};
......
...@@ -319,8 +319,8 @@ toku_loader_create_loader(DB_ENV *env, ...@@ -319,8 +319,8 @@ toku_loader_create_loader(DB_ENV *env,
} }
TOKUTXN ttxn = txn ? db_txn_struct_i(txn)->tokutxn : NULL; TOKUTXN ttxn = txn ? db_txn_struct_i(txn)->tokutxn : NULL;
rval = toku_ft_loader_open(&loader->i->ft_loader, rval = toku_ft_loader_open(&loader->i->ft_loader,
loader->i->env->i->cachetable, env->i->cachetable,
loader->i->env->i->generate_row_for_put, env->i->generate_row_for_put,
src_db, src_db,
N, N,
brts, dbs, brts, dbs,
...@@ -330,7 +330,7 @@ toku_loader_create_loader(DB_ENV *env, ...@@ -330,7 +330,7 @@ toku_loader_create_loader(DB_ENV *env,
load_lsn, load_lsn,
ttxn, ttxn,
puts_allowed, puts_allowed,
loader->i->env->i->loader_memory_size, env->get_loader_memory_size(env),
compress_intermediates); compress_intermediates);
if ( rval!=0 ) { if ( rval!=0 ) {
toku_free(new_inames_in_env); toku_free(new_inames_in_env);
......
...@@ -91,14 +91,21 @@ PATENT RIGHTS GRANT: ...@@ -91,14 +91,21 @@ PATENT RIGHTS GRANT:
#include "test.h" #include "test.h"
#include <db.h> #include <db.h>
static uint64_t my_loader_memory_size;
static uint64_t get_loader_memory_size(void) {
return my_loader_memory_size;
}
int test_main (int argc, char * const argv[]) { int test_main (int argc, char * const argv[]) {
parse_args(argc, argv); parse_args(argc, argv);
int r; int r;
DB_ENV *env; DB_ENV *env;
r = db_env_create(&env, 0); r = db_env_create(&env, 0);
assert_zero(r); assert_zero(r);
env->set_loader_memory_size(env, get_loader_memory_size);
for (uint64_t n = 0 ; n < 10000000000; n += 1000000000) { for (uint64_t n = 0 ; n < 10000000000; n += 1000000000) {
env->set_loader_memory_size(env, n); my_loader_memory_size = n;
assert(env->get_loader_memory_size(env) == n); assert(env->get_loader_memory_size(env) == n);
} }
r = env->close(env, 0); r = env->close(env, 0);
......
...@@ -182,7 +182,7 @@ struct __toku_db_env_internal { ...@@ -182,7 +182,7 @@ struct __toku_db_env_internal {
int datadir_lockfd; int datadir_lockfd;
int logdir_lockfd; int logdir_lockfd;
int tmpdir_lockfd; int tmpdir_lockfd;
uint64_t loader_memory_size; uint64_t (*get_loader_memory_size_callback)(void);
}; };
// test-only environment function for running lock escalation // test-only environment function for running lock escalation
......
...@@ -2416,12 +2416,15 @@ env_iterate_live_transactions(DB_ENV *env, ...@@ -2416,12 +2416,15 @@ env_iterate_live_transactions(DB_ENV *env,
return toku_txn_manager_iter_over_live_root_txns(txn_manager, iter_txns_callback, &e); return toku_txn_manager_iter_over_live_root_txns(txn_manager, iter_txns_callback, &e);
} }
static void env_set_loader_memory_size(DB_ENV *env, uint64_t loader_memory_size) { static void env_set_loader_memory_size(DB_ENV *env, uint64_t (*get_loader_memory_size_callback)(void)) {
env->i->loader_memory_size = loader_memory_size; env->i->get_loader_memory_size_callback = get_loader_memory_size_callback;
} }
static uint64_t env_get_loader_memory_size(DB_ENV *env) { static uint64_t env_get_loader_memory_size(DB_ENV *env) {
return env->i->loader_memory_size; uint64_t memory_size = 0;
if (env->i->get_loader_memory_size_callback)
memory_size = env->i->get_loader_memory_size_callback();
return memory_size;
} }
static int static int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment