From 543fc5e0d1f661987c85134a39ca68d5b104ddf6 Mon Sep 17 00:00:00 2001 From: dimitr Date: Tue, 31 Oct 2006 15:59:23 +0000 Subject: [PATCH] Enabled rescheduling points for classic. It allows to shutdown database or cancel operation timely for a heavy loaded attachment. --- src/jrd/blb.cpp | 4 ---- src/jrd/btr.cpp | 7 +------ src/jrd/evl.cpp | 6 ------ src/jrd/exe.cpp | 8 -------- src/jrd/idx.cpp | 2 -- src/jrd/jrd.cpp | 10 +++++++--- src/jrd/rse.cpp | 6 ------ src/jrd/validation.cpp | 2 -- src/jrd/vio.cpp | 12 ++---------- 9 files changed, 10 insertions(+), 47 deletions(-) diff --git a/src/jrd/blb.cpp b/src/jrd/blb.cpp index 8b7f15db84..2cd8b006d6 100644 --- a/src/jrd/blb.cpp +++ b/src/jrd/blb.cpp @@ -518,13 +518,9 @@ USHORT BLB_get_segment(thread_db* tdbb, SET_TDBB(tdbb); Database* dbb = tdbb->tdbb_database; -#ifdef SUPERSERVER - if (--tdbb->tdbb_quantum < 0) JRD_reschedule(tdbb, 0, true); -#endif - /* If we reached end of file, we're still there */ if (blob->blb_flags & BLB_eof) diff --git a/src/jrd/btr.cpp b/src/jrd/btr.cpp index 278d7d91b6..07d711f985 100644 --- a/src/jrd/btr.cpp +++ b/src/jrd/btr.cpp @@ -3710,11 +3710,8 @@ static SLONG fast_load(thread_db* tdbb, pointers[level] = levelPointer; } -#ifdef SUPERSERVER - if (--tdbb->tdbb_quantum < 0) { + if (--tdbb->tdbb_quantum < 0) error = JRD_reschedule(tdbb, 0, false); - } -#endif } // To finish up, put an end of level marker on the last bucket @@ -6310,7 +6307,6 @@ static CONTENTS remove_leaf_node(thread_db* tdbb, index_insertion* insertion, WI } while (--l); } -#ifdef SUPERSERVER // Until deletion of duplicate nodes becomes efficient, limit // leaf level traversal by rescheduling. if (--tdbb->tdbb_quantum < 0) { @@ -6319,7 +6315,6 @@ static CONTENTS remove_leaf_node(thread_db* tdbb, index_insertion* insertion, WI ERR_punt(); } } -#endif } // If we've needed to search thru a significant number of pages, warn the diff --git a/src/jrd/evl.cpp b/src/jrd/evl.cpp index c2e234a9de..bdce04f23f 100644 --- a/src/jrd/evl.cpp +++ b/src/jrd/evl.cpp @@ -294,10 +294,8 @@ RecordBitmap** EVL_bitmap(thread_db* tdbb, jrd_nod* node) DEV_BLKCHK(node, type_nod); -#ifdef SUPERSERVER if (--tdbb->tdbb_quantum < 0) JRD_reschedule(tdbb, 0, true); -#endif switch (node->nod_type) { case nod_bit_and: @@ -815,10 +813,8 @@ dsc* EVL_expr(thread_db* tdbb, jrd_nod* const node) SET_TDBB(tdbb); -#ifdef SUPERSERVER if (--tdbb->tdbb_quantum < 0) JRD_reschedule(tdbb, 0, true); -#endif jrd_req* const request = tdbb->tdbb_request; impure_value* const impure = (impure_value*) ((SCHAR *) request + node->nod_impure); @@ -1325,10 +1321,8 @@ USHORT EVL_group(thread_db* tdbb, RecordSource* rsb, jrd_nod *const node, USHORT DEV_BLKCHK(node, type_nod); -#ifdef SUPERSERVER if (--tdbb->tdbb_quantum < 0) JRD_reschedule(tdbb, 0, true); -#endif /* if we found the last record last time, we're all done */ diff --git a/src/jrd/exe.cpp b/src/jrd/exe.cpp index a715ef1f39..6e21c88958 100644 --- a/src/jrd/exe.cpp +++ b/src/jrd/exe.cpp @@ -576,10 +576,8 @@ void EXE_receive(thread_db* tdbb, DEV_BLKCHK(request, type_req); -#ifdef SUPERSERVER if (--tdbb->tdbb_quantum < 0) JRD_reschedule(tdbb, 0, true); -#endif jrd_tra* transaction = request->req_transaction; @@ -720,10 +718,8 @@ void EXE_send(thread_db* tdbb, SET_TDBB(tdbb); DEV_BLKCHK(request, type_req); -#ifdef SUPERSERVER if (--tdbb->tdbb_quantum < 0) JRD_reschedule(tdbb, 0, true); -#endif if (!(request->req_flags & req_active)) ERR_post(isc_req_sync, 0); @@ -1651,16 +1647,12 @@ static jrd_nod* looper(thread_db* tdbb, jrd_req* request, jrd_nod* in_node) { try { -#ifdef SUPERSERVER - if (request->req_operation == jrd_req::req_evaluate && (--tdbb->tdbb_quantum < 0)) { JRD_reschedule(tdbb, 0, true); } -#endif - #if defined(DEBUG_GDS_ALLOC) && FALSE int node_type = node->nod_type; #endif diff --git a/src/jrd/idx.cpp b/src/jrd/idx.cpp index aa59d05c0a..b313bd7a0c 100644 --- a/src/jrd/idx.cpp +++ b/src/jrd/idx.cpp @@ -472,10 +472,8 @@ void IDX_create_index( delete record; } -#ifdef SUPERSERVER if (--tdbb->tdbb_quantum < 0) JRD_reschedule(tdbb, 0, true); -#endif } gc_record->rec_flags &= ~REC_gc_active; diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp index 829a493063..85f1b03dfa 100644 --- a/src/jrd/jrd.cpp +++ b/src/jrd/jrd.cpp @@ -4472,7 +4472,6 @@ void JRD_print_procedure_info(thread_db* tdbb, const char* mesg) #endif // DEBUG_PROCS -#ifdef MULTI_THREAD bool JRD_reschedule(thread_db* tdbb, SLONG quantum, bool punt) { /************************************** @@ -4487,6 +4486,7 @@ bool JRD_reschedule(thread_db* tdbb, SLONG quantum, bool punt) * **************************************/ +#ifdef MULTI_THREAD // Force garbage collection activity to yield the // processor in case client threads haven't had // an opportunity to enter the scheduling queue. @@ -4498,6 +4498,7 @@ bool JRD_reschedule(thread_db* tdbb, SLONG quantum, bool punt) THREAD_YIELD(); THREAD_ENTER(); } +#endif Database* dbb = tdbb->tdbb_database; @@ -4583,13 +4584,16 @@ bool JRD_reschedule(thread_db* tdbb, SLONG quantum, bool punt) } tdbb->tdbb_quantum = (tdbb->tdbb_quantum <= 0) ? +#ifdef MULTI_THREAD (quantum ? quantum : (ThreadPriorityScheduler::boosted() ? - Config::getPriorityBoost() : 1) * QUANTUM) : + Config::getPriorityBoost() : 1) * QUANTUM) : +#else + (quantum ? quantum : QUANTUM) : +#endif tdbb->tdbb_quantum; return false; } -#endif void JRD_restore_context(void) diff --git a/src/jrd/rse.cpp b/src/jrd/rse.cpp index f08e105ccc..0bf0438d57 100644 --- a/src/jrd/rse.cpp +++ b/src/jrd/rse.cpp @@ -1808,14 +1808,8 @@ static bool get_record(thread_db* tdbb, **************************************/ SET_TDBB(tdbb); -#ifdef SUPERSERVER - if (--tdbb->tdbb_quantum < 0) - { JRD_reschedule(tdbb, 0, true); - } - -#endif /* check request flags for special processing */ diff --git a/src/jrd/validation.cpp b/src/jrd/validation.cpp index 7c308d88b3..f9960761b5 100644 --- a/src/jrd/validation.cpp +++ b/src/jrd/validation.cpp @@ -820,10 +820,8 @@ static FETCH_CODE fetch_page(thread_db* tdbb, Database* dbb = tdbb->tdbb_database; CHECK_DBB(dbb); -#ifdef SUPERSERVER if (--tdbb->tdbb_quantum < 0) JRD_reschedule(tdbb, 0, true); -#endif window->win_page = page_number; window->win_flags = 0; diff --git a/src/jrd/vio.cpp b/src/jrd/vio.cpp index 68cb86f0de..ae7c22b623 100644 --- a/src/jrd/vio.cpp +++ b/src/jrd/vio.cpp @@ -3637,14 +3637,10 @@ static void garbage_collect(thread_db* tdbb, if (rpb->rpb_record) { going.push(rpb->rpb_record); } -#ifdef SUPERSERVER /* Don't monopolize the server while chasing long back version chains. */ - - if (--tdbb->tdbb_quantum < 0) { + if (--tdbb->tdbb_quantum < 0) JRD_reschedule(tdbb, 0, true); - } -#endif } BLB_garbage_collect(tdbb, going, staying, prior_page, rpb->rpb_relation); @@ -4086,14 +4082,10 @@ static void list_staying(thread_db* tdbb, record_param* rpb, RecordStack& stayin temp.rpb_prior = (temp.rpb_flags & rpb_delta) ? data : NULL; DPM_fetch_back(tdbb, &temp, LCK_read, 1); depth++; -#ifdef SUPERSERVER /* Don't monopolize the server while chasing long back version chains. */ - - if (--tdbb->tdbb_quantum < 0) { + if (--tdbb->tdbb_quantum < 0) JRD_reschedule(tdbb, 0, true); - } -#endif } /* If there is a next older version, then process it: remember that