8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 08:03:03 +01:00

Move impure area and rpbs to their own arrays

This commit is contained in:
asfernandes 2010-04-09 15:43:48 +00:00
parent ca88126833
commit 3387c9c288
3 changed files with 21 additions and 38 deletions

View File

@ -118,18 +118,15 @@ inline bool IS_DATE_AND_TIME(const dsc d1, const dsc d2)
((d2.dsc_dtype == dtype_sql_time) && (d1.dsc_dtype == dtype_sql_date))); ((d2.dsc_dtype == dtype_sql_time) && (d1.dsc_dtype == dtype_sql_date)));
} }
// size of req_rpb[0] const unsigned MAP_LENGTH = 256;
const size_t REQ_TAIL = sizeof(Jrd::jrd_req::blk_repeat_type);
const int MAP_LENGTH = 256;
// RITTER - changed HP10 to HPUX
#if defined (HPUX) && defined (SUPERSERVER) #if defined (HPUX) && defined (SUPERSERVER)
const int MAX_RECURSION = 96; const int MAX_RECURSION = 96;
#else #else
const int MAX_RECURSION = 128; const int MAX_RECURSION = 128;
#endif #endif
const int MAX_REQUEST_SIZE = 10485760; // 10 MB - just to be safe const unsigned MAX_REQUEST_SIZE = 10485760; // 10 MB - just to be safe
using namespace Jrd; using namespace Jrd;
using namespace Firebird; using namespace Firebird;
@ -697,12 +694,10 @@ jrd_req* CMP_clone_request(thread_db* tdbb, jrd_req* request, USHORT level, bool
// clone the request // clone the request
const size_t n = (request->req_impure_size - REQ_SIZE + REQ_TAIL - 1) / REQ_TAIL; clone = FB_NEW(*pool) jrd_req(pool, ULONG(request->req_rpb.getCount()),
clone = FB_NEW_RPT(*pool, n) jrd_req(pool, &dbb->dbb_memory_stats); ULONG(request->impureArea.getCount()), &dbb->dbb_memory_stats);
(*vector)[level] = clone; (*vector)[level] = clone;
clone->req_attachment = attachment; clone->req_attachment = attachment;
clone->req_count = request->req_count;
clone->req_impure_size = request->req_impure_size;
clone->req_top_node = request->req_top_node; clone->req_top_node = request->req_top_node;
clone->req_trg_name = request->req_trg_name; clone->req_trg_name = request->req_trg_name;
clone->req_procedure = request->req_procedure; clone->req_procedure = request->req_procedure;
@ -718,10 +713,10 @@ jrd_req* CMP_clone_request(thread_db* tdbb, jrd_req* request, USHORT level, bool
clone->req_exec_sta = request->req_exec_sta; clone->req_exec_sta = request->req_exec_sta;
clone->req_map_field_info.assign(request->req_map_field_info); clone->req_map_field_info.assign(request->req_map_field_info);
record_param* rpb1 = clone->req_rpb; record_param* rpb1 = clone->req_rpb.begin();
const record_param* const end = rpb1 + clone->req_count; const record_param* const end = rpb1 + clone->req_rpb.getCount();
for (const record_param* rpb2 = request->req_rpb; rpb1 < end; rpb1++, rpb2++) for (const record_param* rpb2 = request->req_rpb.begin(); rpb1 < end; ++rpb1, ++rpb2)
{ {
if (rpb2->rpb_stream_flags & RPB_s_update) { if (rpb2->rpb_stream_flags & RPB_s_update) {
rpb1->rpb_stream_flags |= RPB_s_update; rpb1->rpb_stream_flags |= RPB_s_update;
@ -2120,7 +2115,6 @@ jrd_req* CMP_make_request(thread_db* tdbb, CompilerScratch* csb, bool internal_f
fieldInfo.validation = CMP_pass1(tdbb, csb, fieldInfo.validation); fieldInfo.validation = CMP_pass1(tdbb, csb, fieldInfo.validation);
} }
csb->csb_impure = REQ_SIZE + REQ_TAIL * MAX(csb->csb_n_stream, 1);
csb->csb_exec_sta.clear(); csb->csb_exec_sta.clear();
csb->csb_node = CMP_pass2(tdbb, csb, csb->csb_node, 0); csb->csb_node = CMP_pass2(tdbb, csb, csb->csb_node, 0);
@ -2142,12 +2136,9 @@ jrd_req* CMP_make_request(thread_db* tdbb, CompilerScratch* csb, bool internal_f
// count of hold the impure areas. // count of hold the impure areas.
MemoryPool* const pool = tdbb->getDefaultPool(); MemoryPool* const pool = tdbb->getDefaultPool();
const size_t n = (csb->csb_impure - REQ_SIZE + REQ_TAIL - 1) / REQ_TAIL;
Firebird::MemoryStats* const parent_stats = Firebird::MemoryStats* const parent_stats =
internal_flag ? &dbb->dbb_memory_stats : &attachment->att_memory_stats; internal_flag ? &dbb->dbb_memory_stats : &attachment->att_memory_stats;
request = FB_NEW_RPT(*pool, n) jrd_req(pool, parent_stats); request = FB_NEW(*pool) jrd_req(pool, csb->csb_n_stream, csb->csb_impure, parent_stats);
request->req_count = csb->csb_n_stream;
request->req_impure_size = csb->csb_impure;
request->req_top_node = csb->csb_node; request->req_top_node = csb->csb_node;
request->req_access = csb->csb_access; request->req_access = csb->csb_access;
request->req_external = csb->csb_external; request->req_external = csb->csb_external;
@ -2223,7 +2214,7 @@ jrd_req* CMP_make_request(thread_db* tdbb, CompilerScratch* csb, bool internal_f
const CompilerScratch::csb_repeat* const streams_end = tail + csb->csb_n_stream; const CompilerScratch::csb_repeat* const streams_end = tail + csb->csb_n_stream;
DEBUG; DEBUG;
for (record_param* rpb = request->req_rpb; tail < streams_end; rpb++, tail++) for (record_param* rpb = request->req_rpb.begin(); tail < streams_end; ++rpb, ++tail)
{ {
// fetch input stream for update if all booleans matched against indices // fetch input stream for update if all booleans matched against indices

View File

@ -194,24 +194,25 @@ private:
// request block // request block
class jrd_req : public pool_alloc_rpt<record_param, type_req> class jrd_req : public pool_alloc<type_req>
{ {
public: public:
jrd_req(MemoryPool* pool, Firebird::MemoryStats* parent_stats) jrd_req(MemoryPool* pool, USHORT streamCount, ULONG impureSize, Firebird::MemoryStats* parent_stats)
: req_pool(pool), req_memory_stats(parent_stats), : req_pool(pool), req_memory_stats(parent_stats),
req_blobs(pool), req_external(*pool), req_access(*pool), req_resources(*pool), req_blobs(pool), req_external(*pool), req_access(*pool), req_resources(*pool),
req_trg_name(*pool), req_stats(*pool), req_base_stats(*pool), req_fors(*pool), req_trg_name(*pool), req_stats(*pool), req_base_stats(*pool), req_fors(*pool),
req_exec_sta(*pool), req_ext_stmt(NULL), req_cursors(*pool), req_invariants(*pool), req_exec_sta(*pool), req_ext_stmt(NULL), req_cursors(*pool), req_invariants(*pool),
req_charset(CS_dynamic), req_blr(*pool), req_domain_validation(NULL), req_charset(CS_dynamic), req_blr(*pool), req_domain_validation(NULL),
req_map_field_info(*pool), req_map_item_info(*pool), req_auto_trans(*pool), req_map_field_info(*pool), req_map_item_info(*pool), req_auto_trans(*pool),
req_sorts(*pool) req_sorts(*pool), req_rpb(*pool, streamCount), impureArea(*pool, impureSize)
{} {
req_rpb.grow(streamCount);
impureArea.grow(impureSize);
}
Attachment* req_attachment; // database attachment Attachment* req_attachment; // database attachment
SLONG req_id; // request identifier SLONG req_id; // request identifier
USHORT req_count; // number of streams
USHORT req_incarnation; // incarnation number USHORT req_incarnation; // incarnation number
ULONG req_impure_size; // size of impure area
MemoryPool* req_pool; MemoryPool* req_pool;
Firebird::MemoryStats req_memory_stats; Firebird::MemoryStats req_memory_stats;
vec<jrd_req*>* req_sub_requests; // vector of sub-requests vec<jrd_req*>* req_sub_requests; // vector of sub-requests
@ -278,7 +279,9 @@ public:
ExtEngineManager::ResultSet* resultSet; // external procedure result set ExtEngineManager::ResultSet* resultSet; // external procedure result set
ValuesImpl* inputParams; // external procedure input values ValuesImpl* inputParams; // external procedure input values
ValuesImpl* outputParams; // external procedure output values ValuesImpl* outputParams; // external procedure output values
SortOwner req_sorts; SortOwner req_sorts;
Firebird::Array<record_param> req_rpb; // record parameter blocks
Firebird::Array<UCHAR> impureArea; // impure area
enum req_ta { enum req_ta {
// Order should be maintained because the numbers are stored in BLR // Order should be maintained because the numbers are stored in BLR
@ -306,11 +309,9 @@ public:
StatusXcp req_last_xcp; // last known exception StatusXcp req_last_xcp; // last known exception
record_param req_rpb[1]; // record parameter blocks
template <typename T> T* getImpure(unsigned offset) template <typename T> T* getImpure(unsigned offset)
{ {
return reinterpret_cast<T*>(((SCHAR*) this) + offset); return reinterpret_cast<T*>(&impureArea[offset]);
} }
void adjustCallerStats() void adjustCallerStats()
@ -324,15 +325,6 @@ public:
const Routine* getRoutine() const; const Routine* getRoutine() const;
}; };
// Size of request without rpb items at the tail. Used to calculate impure area size
//
// 24-Mar-2004, Nickolay Samofatov.
// Note it may be not accurate on 64-bit RISC targets with 32-bit pointers due to
// alignment quirks, but from quick glance on code it looks like it should not be
// causing problems. Good fix for this kludgy behavior is to use some C++ means
// to manage impure area and array of record parameter blocks
const size_t REQ_SIZE = sizeof(jrd_req) - sizeof(jrd_req::blk_repeat_type);
// Flags for req_flags // Flags for req_flags
const ULONG req_active = 0x1L; const ULONG req_active = 0x1L;
const ULONG req_stall = 0x2L; const ULONG req_stall = 0x2L;

View File

@ -368,7 +368,7 @@ const char* TraceTriggerImpl::getTriggerName()
const char* TraceTriggerImpl::getRelationName() const char* TraceTriggerImpl::getRelationName()
{ {
const jrd_rel* rel = m_trig->req_rpb->rpb_relation; const jrd_rel* rel = m_trig->req_rpb[0].rpb_relation;
return rel ? rel->rel_name.c_str() : NULL; return rel ? rel->rel_name.c_str() : NULL;
} }