From 811a3ba155e000d45eb5603f09be230ab6dbcd9d Mon Sep 17 00:00:00 2001 From: dimitr Date: Tue, 5 Apr 2011 05:15:19 +0000 Subject: [PATCH] Better locality of allocations. This also fixes a tiny memory leak in SuperServer. --- src/jrd/lck.cpp | 2 +- src/jrd/pag.cpp | 4 ++-- src/jrd/vio.cpp | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/jrd/lck.cpp b/src/jrd/lck.cpp index 97a951e153..a65931ca11 100644 --- a/src/jrd/lck.cpp +++ b/src/jrd/lck.cpp @@ -999,7 +999,7 @@ static void hash_allocate(Lock* lock) if (attachment) { attachment->att_compatibility_table = - vec::newVector(*dbb->dbb_permanent, LOCK_HASH_SIZE); + vec::newVector(*attachment->att_pool, LOCK_HASH_SIZE); } } diff --git a/src/jrd/pag.cpp b/src/jrd/pag.cpp index b7a7ca731c..f40ab8f03c 100644 --- a/src/jrd/pag.cpp +++ b/src/jrd/pag.cpp @@ -1013,7 +1013,7 @@ SLONG PAG_attachment_id(thread_db* tdbb) // Take out lock on attachment id - Lock* lock = FB_NEW_RPT(*dbb->dbb_permanent, sizeof(SLONG)) Lock(); + Lock* lock = FB_NEW_RPT(*attachment->att_pool, sizeof(SLONG)) Lock(); attachment->att_id_lock = lock; lock->lck_type = LCK_attachment; lock->lck_owner_handle = LCK_get_owner_handle(tdbb, lock->lck_type); @@ -2473,7 +2473,7 @@ USHORT PageManager::getTempPageSpaceID(thread_db* tdbb) Attachment* att = tdbb->getAttachment(); if (!att->att_temp_pg_lock) { - Lock* lock = FB_NEW_RPT(*dbb->dbb_permanent, sizeof(SLONG)) Lock(); + Lock* lock = FB_NEW_RPT(*att->att_pool, sizeof(SLONG)) Lock(); lock->lck_type = LCK_page_space; lock->lck_owner_handle = LCK_get_owner_handle(tdbb, lock->lck_type); lock->lck_parent = dbb->dbb_lock; diff --git a/src/jrd/vio.cpp b/src/jrd/vio.cpp index a4b435a361..35ca7bc793 100644 --- a/src/jrd/vio.cpp +++ b/src/jrd/vio.cpp @@ -483,6 +483,7 @@ void VIO_bump_count(thread_db* tdbb, USHORT count_id, jrd_rel* relation) **************************************/ SET_TDBB(tdbb); Database* dbb = tdbb->getDatabase(); + Attachment* attachment = tdbb->getAttachment(); CHECK_DBB(dbb); #ifdef VIO_DEBUG @@ -504,9 +505,9 @@ void VIO_bump_count(thread_db* tdbb, USHORT count_id, jrd_rel* relation) #endif const USHORT relation_id = relation->rel_id; - vcl** ptr = tdbb->getAttachment()->att_counts + count_id; + vcl** ptr = attachment->att_counts + count_id; - vcl* vector = *ptr = vcl::newVector(*dbb->dbb_permanent, *ptr, relation_id + 1); + vcl* vector = *ptr = vcl::newVector(*attachment->att_pool, *ptr, relation_id + 1); ((*vector)[relation_id])++; tdbb->bumpStats((RuntimeStatistics::StatType) count_id, relation_id);