#At file:///C:/Work/bzr/Merge/mysql-6.0-falcon-team/
2866 Kevin Lewis 2008-10-15
Bug#39672 - Using BitMap::nextSet does not work correctly
when you clear the previous set bit. This was fixed by
the other changeset for this bug. This caused half of
the RecordLeafs to remain in memory. In order to process
the bitmap more reliably and make this loop like others
in the Falcon code, we use nextSet(0).
Also, do not spread out the numbers in the emptySections
bitmap by setting record numbers. Use section numbers
for a tighter bitmap.
Also, add some reporting features to analyze the RecordLeaf
objects and their contents.
Also, use RecordSection::anyActiveRecords() instead of
RecordSection::countActiveRecords() when the count is not
important. This will improve speed.
modified:
storage/falcon/Bitmap.h
storage/falcon/Connection.h
storage/falcon/Database.cpp
storage/falcon/RecordGroup.cpp
storage/falcon/RecordGroup.h
storage/falcon/RecordLeaf.cpp
storage/falcon/RecordLeaf.h
storage/falcon/RecordSection.h
storage/falcon/Table.cpp
storage/falcon/Table.h
per-file messages:
storage/falcon/Bitmap.h
Bug#39672 - This is needed with the previous changeset
which added Bitmap::unitTest().
storage/falcon/Connection.h
Bug#39672 - Add analyzeRecordLeafs ID.
storage/falcon/Database.cpp
Bug#39672 - Add analyzeRecordLeafs to Database::analyze()
storage/falcon/RecordGroup.cpp
Bug#39672 - Add anyActiveRecords() and chartActiveRecords()
storage/falcon/RecordGroup.h
Bug#39672 - Add anyActiveRecords() and chartActiveRecords()
storage/falcon/RecordLeaf.cpp
Bug#39672 - Add anyActiveRecords() and chartActiveRecords()
Use RecordSection::anyActiveRecords() instead of
RecordSection::countActiveRecords() when the count is not
important. This will improve speed.
storage/falcon/RecordLeaf.h
Bug#39672 - Add anyActiveRecords() and chartActiveRecords()
storage/falcon/RecordSection.h
Bug#39672 - Add anyActiveRecords() and chartActiveRecords()
storage/falcon/Table.cpp
Bug#39672 - Be sure Table::emptySections is released
in the desctructor.
Do not spread out the numbers in the emptySections
bitmap by setting record numbers. Use section numbers
for a tighter bitmap.
Add chartActiveRecords()
storage/falcon/Table.h
Bug#39672 - Add chartActiveRecords()
=== modified file 'storage/falcon/Bitmap.h'
--- a/storage/falcon/Bitmap.h 2007-09-20 15:44:25 +0000
+++ b/storage/falcon/Bitmap.h 2008-10-16 02:40:08 +0000
@@ -64,6 +64,8 @@ public:
void addRef();
INTERLOCK_TYPE count;
+
+ static void unitTest(void);
protected:
void decompose (int32 number, uint *indexes);
=== modified file 'storage/falcon/Connection.h'
--- a/storage/falcon/Connection.h 2008-02-25 12:17:55 +0000
+++ b/storage/falcon/Connection.h 2008-10-16 02:40:08 +0000
@@ -72,6 +72,7 @@ const int analyzeObjects = 64;
const int analyzeSpace = 128;
const int analyzeSync = 256;
const int analyzeIO = 512;
+const int analyzeRecordLeafs = 1024;
const int traceBooleans = 1;
const int traceTriggers = 2;
=== modified file 'storage/falcon/Database.cpp'
--- a/storage/falcon/Database.cpp 2008-10-16 01:04:03 +0000
+++ b/storage/falcon/Database.cpp 2008-10-16 02:40:08 +0000
@@ -73,12 +73,14 @@
#include "MemoryManager.h"
#include "MemMgr.h"
#include "RecordScavenge.h"
+#include "RecordSection.h"
#include "LogStream.h"
#include "SyncTest.h"
#include "SyncHandler.h"
#include "PriorityScheduler.h"
#include "Sequence.h"
#include "BackLog.h"
+#include "Bitmap.h"
#ifdef _WIN32
#define PATH_MAX _MAX_PATH
@@ -1825,7 +1827,7 @@ void Database::retireRecords(bool forced
catch (SQLException &exception)
{
//syncTbl.unlock();
- Log::debug ("Exception during scavenger of table %s.%s: %s\n",
+ Log::debug ("Exception during scavenge of table %s.%s: %s\n",
table->schemaName, table->name, exception.getText());
}
}
@@ -2049,6 +2051,30 @@ JString Database::analyze(int mask)
stream.putCharacter ('\n');
}
+ if (mask & analyzeRecordLeafs)
+ {
+ int *chart = new int [RECORD_SLOTS + 1];
+ stream.putSegment ("\nRecordLeafs\n");
+
+ for (Table *table = tableList; table; table = table->next)
+ {
+ memset(chart, 0, sizeof(int) * (RECORD_SLOTS + 1));
+ int count = table->chartActiveRecords(chart);
+
+ if (count)
+ {
+ stream.format ("%s.%s\t%d\t", table->schemaName, table->name, count);
+ for (int a = 0; a < RECORD_SLOTS + 1; a++)
+ if (chart[a])
+ stream.format ("[%d]%d ", a, chart[a]);
+
+ stream.format ("\n");
+ }
+ }
+
+ stream.putCharacter ('\n');
+ }
+
if (mask & analyzeStatements)
{
stream.putSegment ("\nStatements\n");
=== modified file 'storage/falcon/RecordGroup.cpp'
--- a/storage/falcon/RecordGroup.cpp 2008-03-11 16:15:47 +0000
+++ b/storage/falcon/RecordGroup.cpp 2008-10-16 02:40:08 +0000
@@ -154,6 +154,35 @@ int RecordGroup::countActiveRecords()
return count;
}
+bool RecordGroup::anyActiveRecords()
+{
+ for (RecordSection **ptr = records, **end = records + RECORD_SLOTS; ptr < end; ++ptr)
+ {
+ RecordSection *section = *ptr;
+
+ if (section)
+ if (section->anyActiveRecords())
+ return true;
+ }
+
+ return false;
+}
+
+int RecordGroup::chartActiveRecords(int *chart)
+{
+ int count = 0;
+
+ for (RecordSection **ptr = records, **end = records + RECORD_SLOTS; ptr < end; ++ptr)
+ {
+ RecordSection *section = *ptr;
+
+ if (section)
+ count += section->chartActiveRecords(chart);
+ }
+
+ return count;
+}
+
bool RecordGroup::inactive()
{
for (int slot = 0; slot < RECORD_SLOTS; slot++)
=== modified file 'storage/falcon/RecordGroup.h'
--- a/storage/falcon/RecordGroup.h 2007-10-26 21:42:32 +0000
+++ b/storage/falcon/RecordGroup.h 2008-10-16 02:40:08 +0000
@@ -33,16 +33,17 @@ public:
RecordGroup(int32 base);
virtual ~RecordGroup();
- virtual int countActiveRecords();
- virtual bool store (Record *record, Record *prior, int32 id, RecordSection **parentPtr);
- virtual void inventoryRecords(RecordScavenge* recordScavenge);
+ virtual int countActiveRecords();
+ virtual bool anyActiveRecords();
+ virtual int chartActiveRecords(int *chart);
+ virtual bool store (Record *record, Record *prior, int32 id, RecordSection
**parentPtr);
+ virtual void inventoryRecords(RecordScavenge* recordScavenge);
virtual Record* fetch (int32 id);
- virtual int retireRecords(Table *table, int base, RecordScavenge *recordScavenge);
- virtual bool retireSections(Table * table, int id);
- virtual bool inactive();
+ virtual int retireRecords(Table *table, int base, RecordScavenge *recordScavenge);
+ virtual bool retireSections(Table * table, int id);
+ virtual bool inactive();
- RecordSection *records [RECORD_SLOTS];
- //int32 base;
+ RecordSection *records [RECORD_SLOTS];
};
#endif // !defined(AFX_RECORDGROUP_H__02AD6A55_A433_11D2_AB5B_0000C01D2301__INCLUDED_)
=== modified file 'storage/falcon/RecordLeaf.cpp'
--- a/storage/falcon/RecordLeaf.cpp 2008-07-15 18:57:27 +0000
+++ b/storage/falcon/RecordLeaf.cpp 2008-10-16 02:40:08 +0000
@@ -118,7 +118,7 @@ int RecordLeaf::retireRecords (Table *ta
{
int count = 0;
Record **ptr, **end;
- Sync sync(&syncObject, "RecordLeaf::retireRecords(1)");
+ Sync sync(&syncObject, "RecordLeaf::retireRecords(syncObject)");
sync.lock(Shared);
// Get a shared lock to find at least one record to scavenge
@@ -134,7 +134,7 @@ int RecordLeaf::retireRecords (Table *ta
++count;
else if (record->isVersion())
{
- Sync syncPrior(record->getSyncPrior(), "RecordLeaf::retireRecords(2)");
+ Sync syncPrior(record->getSyncPrior(), "RecordLeaf::retireRecords(prior)");
syncPrior.lock(Shared);
if (record->scavenge(recordScavenge, Shared))
@@ -220,7 +220,7 @@ int RecordLeaf::retireRecords (Table *ta
// identifier when the leaf node is scavenged later.
if (!count && table->emptySections)
- table->emptySections->set(base * RECORD_SLOTS);
+ table->emptySections->set(base);
return count;
}
@@ -232,7 +232,7 @@ bool RecordLeaf::retireSections(Table *
bool RecordLeaf::inactive()
{
- return countActiveRecords() == 0;
+ return (!anyActiveRecords());
}
int RecordLeaf::countActiveRecords()
@@ -246,6 +246,23 @@ int RecordLeaf::countActiveRecords()
return count;
}
+bool RecordLeaf::anyActiveRecords()
+{
+ for (Record **ptr = records, **end = records + RECORD_SLOTS; ptr < end; ++ptr)
+ if (*ptr)
+ return true;
+
+ return false;
+}
+
+int RecordLeaf::chartActiveRecords(int *chart)
+{
+ int count = countActiveRecords();
+ chart[count]++;
+
+ return count;
+}
+
void RecordLeaf::inventoryRecords(RecordScavenge* recordScavenge)
{
Sync sync(&syncObject, "RecordLeaf::inventoryRecords");
=== modified file 'storage/falcon/RecordLeaf.h'
--- a/storage/falcon/RecordLeaf.h 2007-09-25 05:14:45 +0000
+++ b/storage/falcon/RecordLeaf.h 2008-10-16 02:40:08 +0000
@@ -31,8 +31,10 @@
class RecordLeaf : public RecordSection
{
public:
- virtual int countActiveRecords();
- virtual int retireRecords(Table *table, int id, RecordScavenge *recordScavenge);
+ virtual int countActiveRecords();
+ virtual bool anyActiveRecords();
+ virtual int chartActiveRecords(int *chart);
+ virtual int retireRecords(Table *table, int id, RecordScavenge *recordScavenge);
virtual bool retireSections(Table * table, int id);
virtual bool inactive();
virtual bool store(Record *record, Record *prior, int32 id,RecordSection **parentPtr);
=== modified file 'storage/falcon/RecordSection.h'
--- a/storage/falcon/RecordSection.h 2007-10-26 21:42:32 +0000
+++ b/storage/falcon/RecordSection.h 2008-10-16 02:40:08 +0000
@@ -38,11 +38,13 @@ public:
virtual bool inactive() = 0;
virtual ~RecordSection();
- virtual Record* fetch (int32 id) = 0;
- virtual bool store (Record *record, Record *prior, int32 id, RecordSection **parentPtr)
= 0;
- virtual int retireRecords(Table *table, int base, RecordScavenge *recordScavenge) = 0;
- virtual void inventoryRecords(RecordScavenge* recordScavenge) = 0;
- virtual int countActiveRecords() = 0;
+ virtual Record* fetch (int32 id) = 0;
+ virtual bool store (Record *record, Record *prior, int32 id, RecordSection
**parentPtr) = 0;
+ virtual int retireRecords(Table *table, int base, RecordScavenge *recordScavenge) =
0;
+ virtual void inventoryRecords(RecordScavenge* recordScavenge) = 0;
+ virtual int countActiveRecords() = 0;
+ virtual bool anyActiveRecords() = false;
+ virtual int chartActiveRecords(int *chart) = 0;
int32 base;
};
=== modified file 'storage/falcon/Table.cpp'
--- a/storage/falcon/Table.cpp 2008-10-03 23:56:24 +0000
+++ b/storage/falcon/Table.cpp 2008-10-16 02:40:08 +0000
@@ -162,6 +162,9 @@ Table::~Table()
if (recordBitmap)
recordBitmap->release();
+
+ if (emptySections)
+ emptySections->release();
}
Field* Table::findField(const char * fieldName)
@@ -1875,7 +1878,7 @@ int Table::retireRecords(RecordScavenge
syncObj.lock(Exclusive);
// Confirm that tree is still empty
-
+
count = records->countActiveRecords();
if (count == 0)
@@ -1888,16 +1891,17 @@ int Table::retireRecords(RecordScavenge
{
// Get an exclusive lock only if there are empty leaf nodes. Find and
// delete the empty nodes using the stored record numbers as identifiers.
-
+
if (emptySections->count > 0)
{
syncObj.unlock();
syncObj.lock(Exclusive);
- for (int recordNumber = 0; (recordNumber = emptySections->nextSet(recordNumber))
>= 0;)
+ for (int sectionNumber = 0; (sectionNumber = emptySections->nextSet(0)) >= 0;)
{
+ int recordNumber = sectionNumber * RECORD_SLOTS;
records->retireSections(this, recordNumber);
- emptySections->clear(recordNumber);
+ emptySections->clear(sectionNumber);
}
}
@@ -2117,10 +2121,10 @@ void Table::garbageCollect(Record *leavi
if (!leaving && !staying)
return;
- Sync sync (&syncObject, "Table::garbageCollect(1)");
+ Sync sync (&syncObject, "Table::garbageCollect(Obj)");
sync.lock(Shared);
- Sync syncPrior(getSyncPrior(leaving ? leaving : staying), "Table::garbageCollect(2)");
+ Sync syncPrior(getSyncPrior(leaving ? leaving : staying),
"Table::garbageCollect(prior)");
syncPrior.lock(Shared);
// Clean up field indexes
@@ -2770,6 +2774,17 @@ int Table::countActiveRecords()
return records->countActiveRecords();
}
+int Table::chartActiveRecords(int *chart)
+{
+ Sync sync(&syncObject, "Table::countActiveRecords");
+ sync.lock(Shared);
+
+ if (!records)
+ return 0;
+
+ return records->chartActiveRecords(chart);
+}
+
void Table::rebuildIndex(Index *index, Transaction *transaction)
{
index->rebuildIndex(transaction);
=== modified file 'storage/falcon/Table.h'
--- a/storage/falcon/Table.h 2008-08-18 05:45:29 +0000
+++ b/storage/falcon/Table.h 2008-10-16 02:40:08 +0000
@@ -99,6 +99,7 @@ public:
void rebuildIndex (Index *index, Transaction *transaction);
int retireRecords (RecordScavenge *recordScavenge);
int countActiveRecords();
+ int chartActiveRecords(int *chart);
bool foreignKeyMember (ForeignKey *key);
void makeNotSearchable (Field *field, Transaction *transaction);
bool dropForeignKey (int fieldCount, Field **fields, Table *references);
| Thread |
|---|
| • bzr commit into mysql-6.0-falcon-team branch (klewis:2866) Bug#39672 | Kevin Lewis | 16 Oct |