Commit c943ab3b authored by Yoni Fogel's avatar Yoni Fogel

Addresses #2168 refs[t:2168] Skip fsync for transactions that have done no (modify) work.

i.e. only queries

git-svn-id: file:///svn/toku/tokudb.2037b@15766 c7de825b-a66e-492c-adef-691d508d4ae1
parent ea215458
...@@ -2632,10 +2632,17 @@ int toku_brt_insert (BRT brt, DBT *key, DBT *val, TOKUTXN txn) { ...@@ -2632,10 +2632,17 @@ int toku_brt_insert (BRT brt, DBT *key, DBT *val, TOKUTXN txn) {
return toku_brt_maybe_insert(brt, key, val, txn, FALSE, ZERO_LSN); return toku_brt_maybe_insert(brt, key, val, txn, FALSE, ZERO_LSN);
} }
static void
txn_note_doing_work(TOKUTXN txn) {
if (txn)
txn->has_done_work = 1;
}
int toku_brt_maybe_insert (BRT brt, DBT *key, DBT *val, TOKUTXN txn, BOOL oplsn_valid, LSN oplsn) { int toku_brt_maybe_insert (BRT brt, DBT *key, DBT *val, TOKUTXN txn, BOOL oplsn_valid, LSN oplsn) {
int r = 0; int r = 0;
XIDS message_xids; XIDS message_xids;
TXNID xid = toku_txn_get_txnid(txn); TXNID xid = toku_txn_get_txnid(txn);
txn_note_doing_work(txn);
if (txn && (brt->h->txnid_that_created_or_locked_when_empty != xid)) { if (txn && (brt->h->txnid_that_created_or_locked_when_empty != xid)) {
BYTESTRING keybs = {key->size, toku_memdup_in_rollback(txn, key->data, key->size)}; BYTESTRING keybs = {key->size, toku_memdup_in_rollback(txn, key->data, key->size)};
int need_data = (brt->flags&TOKU_DB_DUPSORT)!=0; // dupsorts don't need the data part int need_data = (brt->flags&TOKU_DB_DUPSORT)!=0; // dupsorts don't need the data part
...@@ -2681,6 +2688,7 @@ int toku_brt_maybe_delete(BRT brt, DBT *key, TOKUTXN txn, BOOL oplsn_valid, LSN ...@@ -2681,6 +2688,7 @@ int toku_brt_maybe_delete(BRT brt, DBT *key, TOKUTXN txn, BOOL oplsn_valid, LSN
int r; int r;
XIDS message_xids; XIDS message_xids;
TXNID xid = toku_txn_get_txnid(txn); TXNID xid = toku_txn_get_txnid(txn);
txn_note_doing_work(txn);
if (txn && (brt->h->txnid_that_created_or_locked_when_empty != xid)) { if (txn && (brt->h->txnid_that_created_or_locked_when_empty != xid)) {
BYTESTRING keybs = {key->size, toku_memdup_in_rollback(txn, key->data, key->size)}; BYTESTRING keybs = {key->size, toku_memdup_in_rollback(txn, key->data, key->size)};
r = toku_logger_save_rollback_cmddelete(txn, toku_cachefile_filenum(brt->cf), keybs); r = toku_logger_save_rollback_cmddelete(txn, toku_cachefile_filenum(brt->cf), keybs);
...@@ -4774,6 +4782,7 @@ int toku_brt_maybe_delete_both(BRT brt, DBT *key, DBT *val, TOKUTXN txn, BOOL op ...@@ -4774,6 +4782,7 @@ int toku_brt_maybe_delete_both(BRT brt, DBT *key, DBT *val, TOKUTXN txn, BOOL op
int r; int r;
XIDS message_xids; XIDS message_xids;
TXNID xid = toku_txn_get_txnid(txn); TXNID xid = toku_txn_get_txnid(txn);
txn_note_doing_work(txn);
if (txn && (brt->h->txnid_that_created_or_locked_when_empty != xid)) { if (txn && (brt->h->txnid_that_created_or_locked_when_empty != xid)) {
BYTESTRING keybs = {key->size, toku_memdup_in_rollback(txn, key->data, key->size)}; BYTESTRING keybs = {key->size, toku_memdup_in_rollback(txn, key->data, key->size)};
BYTESTRING databs = {val->size, toku_memdup_in_rollback(txn, val->data, val->size)}; BYTESTRING databs = {val->size, toku_memdup_in_rollback(txn, val->data, val->size)};
......
...@@ -119,6 +119,7 @@ struct tokutxn { ...@@ -119,6 +119,7 @@ struct tokutxn {
OMT open_brts; // a collection of the brts that we touched. Indexed by filenum. OMT open_brts; // a collection of the brts that we touched. Indexed by filenum.
XIDS xids; //Represents the xid list XIDS xids; //Represents the xid list
int force_fsync_on_commit; //This transaction NEEDS an fsync once (if) it commits. (commit means root txn) int force_fsync_on_commit; //This transaction NEEDS an fsync once (if) it commits. (commit means root txn)
int has_done_work; //If this transaction has not done work, there is no need to fsync.
}; };
static inline int toku_logsizeof_u_int8_t (u_int32_t v __attribute__((__unused__))) { static inline int toku_logsizeof_u_int8_t (u_int32_t v __attribute__((__unused__))) {
......
...@@ -155,6 +155,7 @@ int toku_rollback_commit(TOKUTXN txn, YIELDF yield, void*yieldv, LSN lsn) { ...@@ -155,6 +155,7 @@ int toku_rollback_commit(TOKUTXN txn, YIELDF yield, void*yieldv, LSN lsn) {
//If this transaction needs an fsync (if it commits) //If this transaction needs an fsync (if it commits)
//save that in the parent. Since the commit really happens in the root txn. //save that in the parent. Since the commit really happens in the root txn.
txn->parent->force_fsync_on_commit |= txn->force_fsync_on_commit; txn->parent->force_fsync_on_commit |= txn->force_fsync_on_commit;
txn->parent->has_done_work |= txn->has_done_work;
} else { } else {
// do the commit calls and free everything // do the commit calls and free everything
// we do the commit calls in reverse order too. // we do the commit calls in reverse order too.
......
...@@ -61,6 +61,7 @@ int toku_txn_begin_with_xid (TOKUTXN parent_tokutxn, TOKUTXN *tokutxn, TOKULOGGE ...@@ -61,6 +61,7 @@ int toku_txn_begin_with_xid (TOKUTXN parent_tokutxn, TOKUTXN *tokutxn, TOKULOGGE
result->rollentry_fd = -1; result->rollentry_fd = -1;
result->rollentry_filesize = 0; result->rollentry_filesize = 0;
result->force_fsync_on_commit = 0; result->force_fsync_on_commit = 0;
result->has_done_work = 0;
*tokutxn = result; *tokutxn = result;
return 0; return 0;
...@@ -81,7 +82,8 @@ int toku_txn_commit_with_lsn(TOKUTXN txn, int nosync, YIELDF yield, void *yieldv ...@@ -81,7 +82,8 @@ int toku_txn_commit_with_lsn(TOKUTXN txn, int nosync, YIELDF yield, void *yieldv
// panic handled in log_commit // panic handled in log_commit
//Child transactions do not actually 'commit'. They promote their changes to parent, so no need to fsync if this txn has a parent. //Child transactions do not actually 'commit'. They promote their changes to parent, so no need to fsync if this txn has a parent.
int do_fsync = !txn->parent && (txn->force_fsync_on_commit || !nosync); int do_fsync = !txn->parent && (txn->force_fsync_on_commit || (!nosync && txn->has_done_work));
r = toku_log_commit(txn->logger, (LSN*)0, do_fsync, txn->txnid64); // exits holding neither of the tokulogger locks. r = toku_log_commit(txn->logger, (LSN*)0, do_fsync, txn->txnid64); // exits holding neither of the tokulogger locks.
if (r!=0) if (r!=0)
return r; return r;
......
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