Below is the list of changes that have just been committed into a local
6.0 repository of . When does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-11-02 12:54:48-04:00, jas@rowvwade. +10 -0
Add support for priority scheduler to manage I/O operations.
storage/falcon/CMakeLists.txt@stripped, 2007-11-02 12:54:36-04:00, jas@rowvwade. +4 -0
Added new classes PriorityScheduler and Priority.
storage/falcon/Cache.cpp@stripped, 2007-11-02 12:54:37-04:00, jas@rowvwade. +12 -5
Add support for priority scheduler to manage I/O operations.
storage/falcon/Database.cpp@stripped, 2007-11-02 12:54:37-04:00, jas@rowvwade. +4 -4
Add support for priority scheduler to manage I/O operations.
storage/falcon/Database.h@stripped, 2007-11-02 12:54:37-04:00, jas@rowvwade. +43 -42
Add support for priority scheduler to manage I/O operations.
storage/falcon/Makefile.am@stripped, 2007-11-02 12:54:38-04:00, jas@rowvwade. +6 -1
Added new classes PriorityScheduler and Priority.
storage/falcon/Priority.cpp@stripped, 2007-11-02 12:54:39-04:00, jas@rowvwade. +42 -0
New BitKeeper file ``storage/falcon/Priority.cpp''
storage/falcon/Priority.cpp@stripped, 2007-11-02 12:54:39-04:00, jas@rowvwade. +0 -0
storage/falcon/Priority.h@stripped, 2007-11-02 12:54:39-04:00, jas@rowvwade. +39 -0
New BitKeeper file ``storage/falcon/Priority.h''
storage/falcon/Priority.h@stripped, 2007-11-02 12:54:39-04:00, jas@rowvwade. +0 -0
storage/falcon/PriorityScheduler.cpp@stripped, 2007-11-02 12:54:39-04:00, jas@rowvwade. +89 -0
New BitKeeper file ``storage/falcon/PriorityScheduler.cpp''
storage/falcon/PriorityScheduler.cpp@stripped, 2007-11-02 12:54:39-04:00, jas@rowvwade. +0 -0
storage/falcon/PriorityScheduler.h@stripped, 2007-11-02 12:54:39-04:00, jas@rowvwade. +39 -0
New BitKeeper file ``storage/falcon/PriorityScheduler.h''
storage/falcon/PriorityScheduler.h@stripped, 2007-11-02 12:54:39-04:00, jas@rowvwade. +0 -0
storage/falcon/SerialLogFile.cpp@stripped, 2007-11-02 12:54:38-04:00, jas@rowvwade. +9 -4
Add support for priority scheduler to manage I/O operations.
diff -Nrup a/storage/falcon/CMakeLists.txt b/storage/falcon/CMakeLists.txt
--- a/storage/falcon/CMakeLists.txt 2007-10-25 14:10:18 -04:00
+++ b/storage/falcon/CMakeLists.txt 2007-11-02 12:54:36 -04:00
@@ -158,6 +158,8 @@ ADD_LIBRARY(ha_falcon
Parameters.cpp
PreparedStatement.cpp
PrettyPrint.cpp
+ Priority.cpp
+ PriorityScheduler.cpp
Privilege.cpp
PrivilegeObject.cpp
Protocol.cpp
@@ -426,6 +428,8 @@ ADD_LIBRARY(ha_falcon
Parameters.h
PreparedStatement.h
PrettyPrint.h
+ Priority.h
+ PriorityScheduler.h
Privilege.h
PrivilegeObject.h
Protocol.h
diff -Nrup a/storage/falcon/Cache.cpp b/storage/falcon/Cache.cpp
--- a/storage/falcon/Cache.cpp 2007-10-29 17:48:01 -04:00
+++ b/storage/falcon/Cache.cpp 2007-11-02 12:54:37 -04:00
@@ -38,6 +38,7 @@
#include "DatabaseCopy.h"
#include "Database.h"
#include "Bitmap.h"
+#include "Priority.h"
extern uint falcon_io_threads;
@@ -252,8 +253,11 @@ Bdb* Cache::fetchPage(Dbb *dbb, int32 pa
if (bdb->pageNumber == STOP_PAGE)
Log::debug("reading page %d/%d\n", bdb->pageNumber, dbb->tableSpaceId);
#endif
-
+
+ Priority priority(database->ioScheduler);
+ priority.schedule(PRIORITY_MEDIUM);
dbb->readPage(bdb);
+ priority.finished();
if (actual != lockType)
bdb->downGrade(lockType);
@@ -574,7 +578,10 @@ void Cache::writePage(Bdb *bdb, int type
ASSERT(database);
markClean (bdb);
// time_t start = database->timestamp;
+ Priority priority(database->ioScheduler);
+ priority.schedule(PRIORITY_MEDIUM);
dbb->writePage(bdb, type);
+ priority.finished();
/***
time_t delta = database->timestamp - start;
@@ -864,7 +871,6 @@ void Cache::syncFile(Dbb *dbb, const cha
void Cache::ioThread(void* arg)
{
((Cache*) arg)->ioThread();
- Log::debug("Cache::ioThread shutting down\n");
}
void Cache::ioThread(void)
@@ -873,7 +879,8 @@ void Cache::ioThread(void)
syncThread.lock(Shared);
Sync flushLock(&syncFlush, "Cache::ioThread");
Sync sync(&syncObject, "Cache::ioThread");
- Sync syncPIO(&database->syncSerialLogIO, "Cache::ioThread");
+ //Sync syncPIO(&database->syncSerialLogIO, "Cache::ioThread");
+ Priority priority(database->ioScheduler);
Thread *thread = Thread::getThread("Cache::ioThread");
UCHAR *rawBuffer = new UCHAR[ASYNC_BUFFER_SIZE];
UCHAR *buffer = (UCHAR*) (((UIPTR) rawBuffer + pageSize - 1) / pageSize * pageSize);
@@ -942,9 +949,9 @@ void Cache::ioThread(void)
flushLock.unlock();
//Log::debug(" %d Writing %s %d pages: %d - %d\n", thread->threadId, (const char*) dbb->fileName, count, pageNumber, pageNumber + count - 1);
int length = p - buffer;
- syncPIO.lock(Shared);
- syncPIO.unlock();
+ priority.schedule(PRIORITY_LOW);
dbb->writePages(pageNumber, length, buffer, WRITE_TYPE_FLUSH);
+ priority.finished();
Bdb *next;
for (bdb = bdbList; bdb; bdb = next)
diff -Nrup a/storage/falcon/Database.cpp b/storage/falcon/Database.cpp
--- a/storage/falcon/Database.cpp 2007-10-31 13:10:39 -04:00
+++ b/storage/falcon/Database.cpp 2007-11-02 12:54:37 -04:00
@@ -74,6 +74,7 @@
#include "RecordScavenge.h"
#include "LogStream.h"
#include "SyncTest.h"
+#include "PriorityScheduler.h"
#ifndef STORAGE_ENGINE
#include "Applications.h"
@@ -452,6 +453,7 @@ Database::Database(const char *dbName, C
pageWriter = NULL;
zombieTables = NULL;
updateCardinality = NULL;
+ ioScheduler = new PriorityScheduler;
lastScavenge = 0;
scavengeCycle = 0;
serialLogBlockSize = configuration->serialLogBlockSize;
@@ -466,7 +468,6 @@ Database::Database(const char *dbName, C
syncResultSets.setName("Database::syncResultSets");
syncConnectionStatements.setName("Database::syncConnectionStatements");
syncScavenge.setName("Database::syncScavenge");
- syncSerialLogIO.setName("Database::syncSerialLogIO");
}
@@ -597,6 +598,7 @@ Database::~Database()
delete filterSetManager;
delete repositoryManager;
delete transactionManager;
+ delete ioScheduler;
}
void Database::createDatabase(const char * filename)
@@ -2247,9 +2249,7 @@ void Database::updateCardinalities(void)
void Database::sync()
{
-// if (threshold == 0 || dbb->writesSinceSync > threshold)
- cache->syncFile(dbb, "sync");
-
+ cache->syncFile(dbb, "sync");
tableSpaceManager->sync();
}
diff -Nrup a/storage/falcon/Database.h b/storage/falcon/Database.h
--- a/storage/falcon/Database.h 2007-10-31 13:05:11 -04:00
+++ b/storage/falcon/Database.h 2007-11-02 12:54:37 -04:00
@@ -100,6 +100,7 @@ class InfoTable;
class TableSpace;
class MemMgr;
class RecordScavenge;
+class PriorityScheduler;
struct JavaCallback;
@@ -215,49 +216,49 @@ public:
void pageCacheFlushed(int64 flushArg);
JString setLogRoot(const char *defaultPath, bool create);
- Dbb *dbb;
- Cache *cache;
- JString name;
- Database *next; // used by Connection
- Database *prior; // used by Connection
- Schema *schemas [TABLE_HASH_SIZE];
- Table *tables [TABLE_HASH_SIZE];
- Table *tablesModId [TABLE_HASH_SIZE];
- Table *tableList;
- Table *zombieTables;
- UnTable *unTables [TABLE_HASH_SIZE];
+ Dbb *dbb;
+ Cache *cache;
+ JString name;
+ Database *next; // used by Connection
+ Database *prior; // used by Connection
+ Schema *schemas [TABLE_HASH_SIZE];
+ Table *tables [TABLE_HASH_SIZE];
+ Table *tablesModId [TABLE_HASH_SIZE];
+ Table *tableList;
+ Table *zombieTables;
+ UnTable *unTables [TABLE_HASH_SIZE];
CompiledStatement *compiledStatements;
- Configuration *configuration;
- SerialLog *serialLog;
- Connection *systemConnection;
- int nextTableId;
- bool formatting;
- bool licensed;
- bool fieldExtensions;
- bool utf8;
- bool panicShutdown;
- bool shuttingDown;
- bool longSync;
- int useCount;
- int sequence;
- int stepNumber;
- int scavengeCycle;
- Java *java;
- Applications *applications;
- SyncObject syncObject;
- SyncObject syncTables;
- SyncObject syncStatements;
- SyncObject syncAddStatement;
- SyncObject syncSysConnection;
- SyncObject syncResultSets;
- SyncObject syncConnectionStatements;
- SyncObject syncScavenge;
- SyncObject syncSerialLogIO;
- Threads *threads;
- Scheduler *scheduler;
- Scheduler *internalScheduler;
- Scavenger *scavenger;
- Scavenger *garbageCollector;
+ Configuration *configuration;
+ SerialLog *serialLog;
+ Connection *systemConnection;
+ int nextTableId;
+ bool formatting;
+ bool licensed;
+ bool fieldExtensions;
+ bool utf8;
+ bool panicShutdown;
+ bool shuttingDown;
+ bool longSync;
+ int useCount;
+ int sequence;
+ int stepNumber;
+ int scavengeCycle;
+ Java *java;
+ Applications *applications;
+ SyncObject syncObject;
+ SyncObject syncTables;
+ SyncObject syncStatements;
+ SyncObject syncAddStatement;
+ SyncObject syncSysConnection;
+ SyncObject syncResultSets;
+ SyncObject syncConnectionStatements;
+ SyncObject syncScavenge;
+ PriorityScheduler *ioScheduler;
+ Threads *threads;
+ Scheduler *scheduler;
+ Scheduler *internalScheduler;
+ Scavenger *scavenger;
+ Scavenger *garbageCollector;
TemplateManager *templateManager;
ImageManager *imageManager;
SessionManager *sessionManager;
diff -Nrup a/storage/falcon/Makefile.am b/storage/falcon/Makefile.am
--- a/storage/falcon/Makefile.am 2007-10-25 16:52:15 -04:00
+++ b/storage/falcon/Makefile.am 2007-11-02 12:54:38 -04:00
@@ -95,6 +95,8 @@ falcon_headers= Agent.h Alias.h Applicat
NSequence.h NStat.h NUpdate.h OpSys.h Page.h \
PageInventoryPage.h PagePrecedence.h PageType.h PageWriter.h \
Parameter.h Parameters.h PreparedStatement.h PrettyPrint.h \
+ Priority.h \
+ PriorityScheduler.h \
Privilege.h PrivilegeObject.h PrivType.h Properties.h \
Protocol.h PStatement.h Queue.h QueryString.h RecordGroup.h \
Record.h RecordLeaf.h \
@@ -256,7 +258,10 @@ falcon_sources= Agent.cpp Alias.cpp \
NStat.cpp NUpdate.cpp OpSys.cpp Page.cpp \
PageInventoryPage.cpp PagePrecedence.cpp PageWriter.cpp \
Parameter.cpp Parameters.cpp PreparedStatement.cpp \
- PrettyPrint.cpp Privilege.cpp PrivilegeObject.cpp Protocol.cpp \
+ PrettyPrint.cpp \
+ Priority.cpp \
+ PriorityScheduler.cpp \
+ Privilege.cpp PrivilegeObject.cpp Protocol.cpp \
PStatement.cpp QueryString.cpp Record.cpp \
RecordGroup.cpp RecordLeaf.cpp \
RecordLocatorPage.cpp \
diff -Nrup a/storage/falcon/Priority.cpp b/storage/falcon/Priority.cpp
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/storage/falcon/Priority.cpp 2007-11-02 12:54:39 -04:00
@@ -0,0 +1,42 @@
+/* Copyright (C) 2007 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#include "Engine.h"
+#include "Priority.h"
+#include "PriorityScheduler.h"
+
+Priority::Priority(PriorityScheduler *priorityScheduler)
+{
+ scheduler = priorityScheduler;
+ priority = 0;
+}
+
+Priority::~Priority(void)
+{
+ if (priority)
+ finished();
+}
+
+void Priority::schedule(int prty)
+{
+ priority = prty;
+ scheduler->schedule(priority);
+}
+
+void Priority::finished(void)
+{
+ scheduler->finished(priority);
+ priority = 0;
+}
diff -Nrup a/storage/falcon/Priority.h b/storage/falcon/Priority.h
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/storage/falcon/Priority.h 2007-11-02 12:54:39 -04:00
@@ -0,0 +1,39 @@
+/* Copyright (C) 2007 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#ifndef _PRIORITY_H_
+#define _PRIORITY_H_
+
+static const int PRIORITY_LOW = 1;
+static const int PRIORITY_MEDIUM = 2;
+static const int PRIORITY_HIGH = 3;
+static const int PRIORITY_MAX = 4;
+
+class PriorityScheduler;
+
+class Priority
+{
+public:
+ Priority(PriorityScheduler *sched);
+ ~Priority(void);
+
+ void schedule(int priority);
+ void finished(void);
+
+ PriorityScheduler *scheduler;
+ int priority;
+};
+
+#endif
diff -Nrup a/storage/falcon/PriorityScheduler.cpp b/storage/falcon/PriorityScheduler.cpp
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/storage/falcon/PriorityScheduler.cpp 2007-11-02 12:54:39 -04:00
@@ -0,0 +1,89 @@
+/* Copyright (C) 2007 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#include <memory.h>
+#include "Engine.h"
+#include "PriorityScheduler.h"
+#include "Sync.h"
+#include "Thread.h"
+
+PriorityScheduler::PriorityScheduler(void)
+{
+ currentPriority = 0;
+ count = 0;
+ memset(waitingThreads, 0, sizeof(waitingThreads));
+}
+
+PriorityScheduler::~PriorityScheduler(void)
+{
+}
+
+void PriorityScheduler::schedule(int priority)
+{
+ Sync sync(&mutex, "PriorityScheduler::schedule");
+ sync.lock(Exclusive);
+
+ if (priority == currentPriority)
+ {
+ ++count;
+
+ return;
+ }
+
+ if (priority > currentPriority)
+ {
+ currentPriority = priority;
+ count = 1;
+
+ return;
+ }
+
+ Thread *thread = Thread::getThread("PriorityScheduler::schedule");
+ thread->que = waitingThreads[priority];
+ waitingThreads[priority] = thread;
+ sync.unlock();
+ thread->sleep();
+}
+
+void PriorityScheduler::finished(int priority)
+{
+ Sync sync(&mutex, "PriorityScheduler::finished");
+ sync.lock(Exclusive);
+
+ // If this is below the current priority level, ignore it
+
+ if (priority < currentPriority)
+ return;
+
+ // If there are other processes at this priority level, just decrement the count
+
+ if (--count > 0)
+ return;
+
+ for (currentPriority = PRIORITY_MAX - 1; currentPriority > 0; --currentPriority)
+ if (waitingThreads[currentPriority])
+ {
+ count = 0;
+
+ while (waitingThreads[currentPriority])
+ {
+ ++count;
+ waitingThreads[currentPriority]->wake();
+ waitingThreads[currentPriority] = waitingThreads[currentPriority]->que;
+ }
+
+ break;
+ }
+}
diff -Nrup a/storage/falcon/PriorityScheduler.h b/storage/falcon/PriorityScheduler.h
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/storage/falcon/PriorityScheduler.h 2007-11-02 12:54:39 -04:00
@@ -0,0 +1,39 @@
+/* Copyright (C) 2007 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#ifndef _PRIORITY_SCHEDULER_H_
+#define _PRIORITY_SCHEDULER_H_
+
+#include "Mutex.h"
+#include "Priority.h"
+
+class Thread;
+
+class PriorityScheduler
+{
+public:
+ PriorityScheduler(void);
+ ~PriorityScheduler(void);
+
+ void schedule(int priority);
+ void finished(int priority);
+
+ int currentPriority;
+ int count;
+ Thread *waitingThreads[PRIORITY_MAX];
+ Mutex mutex;
+};
+
+#endif
diff -Nrup a/storage/falcon/SerialLogFile.cpp b/storage/falcon/SerialLogFile.cpp
--- a/storage/falcon/SerialLogFile.cpp 2007-11-01 16:23:07 -04:00
+++ b/storage/falcon/SerialLogFile.cpp 2007-11-02 12:54:38 -04:00
@@ -47,6 +47,7 @@
#include "Database.h"
#include "Log.h"
#include "IOx.h"
+#include "Priority.h"
#ifndef O_BINARY
@@ -158,13 +159,15 @@ void SerialLogFile::write(int64 position
{
uint32 effectiveLength = ROUNDUP(length, sectorSize);
time_t start = database->timestamp;
- Sync syncIO(&database->syncSerialLogIO, "SerialLogFile::write");
+ //Sync syncIO(&database->syncSerialLogIO, "SerialLogFile::write");
+ Priority priority(database->ioScheduler);
if (!(position == writePoint || position == 0 || writePoint == 0))
throw SQLError(IO_ERROR, "serial log left in inconsistent state");
if (falcon_serial_log_priority)
- syncIO.lock(Exclusive);
+ //syncIO.lock(Exclusive);
+ priority.schedule(PRIORITY_HIGH);
#ifdef _WIN32
@@ -224,10 +227,12 @@ void SerialLogFile::write(int64 position
uint32 SerialLogFile::read(int64 position, uint32 length, UCHAR *data)
{
uint32 effectiveLength = ROUNDUP(length, sectorSize);
- Sync syncIO(&database->syncSerialLogIO, "SerialLogFile::read");
+ //Sync syncIO(&database->syncSerialLogIO, "SerialLogFile::read");
+ Priority priority(database->ioScheduler);
if (falcon_serial_log_priority)
- syncIO.lock(Exclusive);
+ //syncIO.lock(Exclusive);
+ priority.schedule(PRIORITY_HIGH);
#ifdef _WIN32
Sync sync(&syncObject, "SerialLogFile::read");
| Thread |
|---|
| • bk commit into 6.0 tree (jas:1.2681) | U-ROWVWADEjas | 2 Nov |