List:Commits« Previous MessageNext Message »
From:Olav Sandstaa Date:June 7 2008 2:33pm
Subject:commit into mysql-6.0-falcon:mysql-6.0-falcon branch (olav:2693)
View as plain text  
#At bzr+ssh://bk-internal.mysql.com/bzrroot/server/mysql-6.0-falcon/

 2693 Olav Sandstaa	2008-06-07 [merge]
      Committing the result of last merge into local repository. Should this really be
necessary?
added:
  storage/falcon/SectorBuffer.cpp
  storage/falcon/SectorBuffer.h
  storage/falcon/SectorCache.cpp
  storage/falcon/SectorCache.h
modified:
  .bzr-mysql/default.conf
  storage/falcon/Backup.cpp
  storage/falcon/CMakeLists.txt
  storage/falcon/Cache.cpp
  storage/falcon/Cache.h
  storage/falcon/Makefile.am


=== modified file '.bzr-mysql/default.conf'
--- a/.bzr-mysql/default.conf	2008-05-27 11:53:11 +0000
+++ b/.bzr-mysql/default.conf	2008-06-06 13:22:16 +0000
@@ -1,6 +1,7 @@
 [MYSQL]
 tree_location = bzr+ssh://bk-internal.mysql.com/bzrroot/server/mysql-6.0-falcon/
 post_commit_to = commits@stripped
+post_push_to = commits@stripped
 post_commit_url = bzr+ssh://bk-internal.mysql.com/bzrroot/server/mysql-6.0-falcon/
 tree_name = mysql-6.0-falcon
 project_name = "mysql-6.0-falcon"

=== modified file 'storage/falcon/Backup.cpp'
--- a/storage/falcon/Backup.cpp	2008-05-29 22:49:01 +0000
+++ b/storage/falcon/Backup.cpp	2008-06-06 19:24:32 +0000
@@ -17,7 +17,7 @@
 #include "Backup.h"
 #include "Database.h"
 #include "Dbb.h"
-#include "Bdb.h"
+#include "BDB.h"
 #include "IndexPage.h"
 #include "RecordLocatorPage.h"
 #include "DataPage.h"

=== modified file 'storage/falcon/CMakeLists.txt'
--- a/storage/falcon/CMakeLists.txt	2008-05-14 14:12:04 +0000
+++ b/storage/falcon/CMakeLists.txt	2008-06-06 19:20:10 +0000
@@ -204,6 +204,8 @@
 		SearchWords.cpp 
 		Section.cpp 
 		SectionPage.cpp 
+		SectorBuffer.cpp
+		SectorCache.cpp
 		Sequence.cpp
 		SequenceManager.cpp 
 		SequenceResultSet.cpp
@@ -480,6 +482,8 @@
 		SearchWords.h 
 		Section.h 
 		SectionPage.h 
+		SectorBuffer.h
+		SectorCache.h
 		Sequence.h
 		SequenceManager.h 
 		SequencePage.h 

=== modified file 'storage/falcon/Cache.cpp'
--- a/storage/falcon/Cache.cpp	2008-05-14 18:39:57 +0000
+++ b/storage/falcon/Cache.cpp	2008-06-06 19:20:10 +0000
@@ -38,6 +38,7 @@
 #include "Database.h"
 #include "Bitmap.h"
 #include "Priority.h"
+#include "SectorCache.h"
 
 extern uint falcon_io_threads;
 
@@ -48,7 +49,7 @@
 
 static const uint64 cacheHunkSize		= 1024 * 1024 * 128;
 static const int	ASYNC_BUFFER_SIZE	= 1024000;
-
+static const int	sectorCacheSize		= 20000000;
 #ifdef _DEBUG
 #undef THIS_FILE
 static const char THIS_FILE[]=__FILE__;
@@ -74,7 +75,7 @@
 	pageWriter = NULL;
 	hashTable = new Bdb* [hashSz];
 	memset (hashTable, 0, sizeof (Bdb*) * hashSize);
-
+	sectorCache = new SectorCache(sectorCacheSize / SECTOR_BUFFER_SIZE, pageSize);
 	uint64 n = ((uint64) pageSize * numberBuffers + cacheHunkSize - 1) / cacheHunkSize;
 	numberHunks = (int) n;
 	bufferHunks = new char* [numberHunks];
@@ -141,7 +142,8 @@
 	delete [] bdbs;
 	delete [] ioThreads;
 	delete flushBitmap;
-
+	delete sectorCache;
+	
 	if (bufferHunks)
 		{
 		for (int n = 0; n < numberHunks; ++n)
@@ -257,7 +259,8 @@
 			
 			Priority priority(database->ioScheduler);
 			priority.schedule(PRIORITY_MEDIUM);	
-			dbb->readPage(bdb);
+			//dbb->readPage(bdb);
+			sectorCache->readPage(bdb);
 			priority.finished();
 #ifdef HAVE_PAGE_NUMBER
 			ASSERT(bdb->buffer->pageNumber == pageNumber);
@@ -521,6 +524,7 @@
 
 	try
 		{
+		sectorCache->writePage(bdb);
 		dbb->writePage(bdb, type);
 		}
 	catch (SQLException& exception)
@@ -791,6 +795,7 @@
 						bdb->incrementUseCount(ADD_HISTORY);
 						sync.unlock();
 						bdb->addRef(Shared  COMMA_ADD_HISTORY);
+						sectorCache->writePage(bdb);
 						
 						bdb->syncWrite.lock(NULL, Exclusive);
 						bdb->ioThreadNext = bdbList;

=== modified file 'storage/falcon/Cache.h'
--- a/storage/falcon/Cache.h	2008-03-27 06:09:29 +0000
+++ b/storage/falcon/Cache.h	2008-06-06 19:20:10 +0000
@@ -36,6 +36,7 @@
 class Thread;
 class Database;
 class Bitmap;
+class SectorCache;
 
 class Cache  
 {
@@ -95,6 +96,7 @@
 	Bitmap		*flushBitmap;
 	char		**bufferHunks;
 	Thread		**ioThreads;
+	SectorCache	*sectorCache;
 	SyncObject	syncFlush;
 	SyncObject	syncDirty;
 	SyncObject	syncThreads;

=== modified file 'storage/falcon/Makefile.am'
--- a/storage/falcon/Makefile.am	2008-04-28 20:47:43 +0000
+++ b/storage/falcon/Makefile.am	2008-06-06 19:26:53 +0000
@@ -117,8 +117,11 @@
 		ScaledBinary.h ScanDir.h \
 		Scan.h ScanType.h Scavenger.h Scheduled.h ScheduleElement.h \
 		Schedule.h Scheduler.h Schema.h Search.h SearchHit.h \
-		SearchWords.h Section.h \
+		SearchWords.h \
+		Section.h \
 		SectionPage.h \
+		SectorBuffer.h \
+		SectorCache.h \
 		Sequence.h SequenceManager.h SequencePage.h \
 		SequenceResultSet.h \
 		Serialize.h \
@@ -291,8 +294,12 @@
 		ScaledBinary.cpp Scan.cpp \
 		ScanDir.cpp Scavenger.cpp Schedule.cpp Scheduled.cpp \
 		ScheduleElement.cpp Scheduler.cpp Schema.cpp Search.cpp \
-		SearchHit.cpp SearchWords.cpp Section.cpp \
-		SectionPage.cpp Sequence.cpp \
+		SearchHit.cpp SearchWords.cpp \
+		Section.cpp \
+		SectionPage.cpp \
+		SectorBuffer.cpp \
+		SectorCache.cpp \
+		Sequence.cpp \
 		SequenceManager.cpp SequenceResultSet.cpp \
 		Serialize.cpp \
 		SerialLogAction.cpp SerialLogControl.cpp SerialLog.cpp \

=== added file 'storage/falcon/SectorBuffer.cpp'
--- a/storage/falcon/SectorBuffer.cpp	1970-01-01 00:00:00 +0000
+++ b/storage/falcon/SectorBuffer.cpp	2008-06-06 19:24:32 +0000
@@ -0,0 +1,58 @@
+/* Copyright (C) 2008 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 "SectorBuffer.h"
+#include "SectorCache.h"
+#include "BDB.h"
+#include "Dbb.h"
+
+SectorBuffer::SectorBuffer()
+{
+	activeLength = 0;
+	sectorNumber = -1;
+}
+
+SectorBuffer::~SectorBuffer(void)
+{
+}
+
+void SectorBuffer::readPage(Bdb* bdb)
+{
+	int offset = (bdb->pageNumber % cache->pagesPerSector) * cache->pageSize;
+	ASSERT(offset < activeLength);
+	memcpy(bdb->buffer, buffer + offset, cache->pageSize);
+}
+
+void SectorBuffer::readSector()
+{
+	uint64 offset = sectorNumber * cache->pagesPerSector * cache->pageSize;
+	activeLength = dbb->pread(offset, SECTOR_BUFFER_SIZE, buffer);
+}
+
+void SectorBuffer::setSector(Dbb* db, int sector)
+{
+	dbb = db;
+	sectorNumber = sector;
+}
+
+void SectorBuffer::writePage(Bdb* bdb)
+{
+	int offset = (bdb->pageNumber % cache->pagesPerSector) * cache->pageSize;
+	memcpy(buffer + offset, bdb->buffer, cache->pageSize);
+	offset += cache->pageSize;
+	activeLength = MAX(activeLength, offset);
+}

=== added file 'storage/falcon/SectorBuffer.h'
--- a/storage/falcon/SectorBuffer.h	1970-01-01 00:00:00 +0000
+++ b/storage/falcon/SectorBuffer.h	2008-06-06 19:20:10 +0000
@@ -0,0 +1,46 @@
+/* Copyright (C) 2008 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 _SECTOR_BUFFER_H_
+#define _SECTOR_BUFFER_H_
+
+#include "SyncObject.h"
+
+class SectorCache;
+class Dbb;
+class Bdb;
+
+class SectorBuffer
+{
+public:
+	SectorBuffer();
+	~SectorBuffer(void);
+
+	void		readPage(Bdb* bdb);
+	void		readSector();
+	
+	SyncObject		syncObject;
+	SectorCache		*cache;
+	SectorBuffer	*next;
+	SectorBuffer	*collision;
+	Dbb				*dbb;
+	UCHAR			*buffer;
+	int				activeLength;
+	int				sectorNumber;
+	void setSector(Dbb* dbb, int sectorNumber);
+	void writePage(Bdb* bdb);
+};
+
+#endif

=== added file 'storage/falcon/SectorCache.cpp'
--- a/storage/falcon/SectorCache.cpp	1970-01-01 00:00:00 +0000
+++ b/storage/falcon/SectorCache.cpp	2008-06-06 19:24:32 +0000
@@ -0,0 +1,129 @@
+/* Copyright (C) 2008 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 "SectorCache.h"
+#include "SectorBuffer.h"
+#include "Dbb.h"
+#include "BDB.h"
+#include "Sync.h"
+
+#define SECTOR_BUFFER_ALIGNMENT	= 4096;
+
+#ifdef _DEBUG
+#undef THIS_FILE
+static const char THIS_FILE[]=__FILE__;
+#endif
+
+
+SectorCache::SectorCache(int numBuffers, int pgSize)
+{
+	memset(hashTable, 0, sizeof(hashTable));
+	numberBuffers = numBuffers;
+	pageSize = pgSize;
+	pagesPerSector = SECTOR_BUFFER_SIZE / pageSize;
+	bufferSpace = new UCHAR[(numberBuffers + 1) * SECTOR_BUFFER_SIZE];
+	UCHAR *p = (UCHAR*) (((UIPTR) bufferSpace + SECTOR_BUFFER_SIZE - 1) / SECTOR_BUFFER_SIZE
* SECTOR_BUFFER_SIZE);
+	SectorBuffer *buffer = buffers = nextBuffer = new SectorBuffer[numberBuffers];
+	SectorBuffer *prior = buffer + numberBuffers - 1;
+	
+	for (int n = 0; n < numberBuffers; ++n, ++buffer, p += SECTOR_BUFFER_SIZE)
+		{
+		prior->next = buffer;
+		prior = buffer;
+		buffer->cache = this;
+		buffer->buffer = p;
+		}
+}
+
+SectorCache::~SectorCache(void)
+{
+	delete [] bufferSpace;
+	delete [] buffers;
+}
+
+void SectorCache::readPage(Bdb* bdb)
+{
+	Sync sync(&syncObject, "SectorCache::readPage");
+	sync.lock(Shared);
+	int sectorNumber = bdb->pageNumber / pagesPerSector;
+	int slot = sectorNumber % SECTOR_HASH_SIZE;
+	SectorBuffer *buffer;
+	
+	for (buffer = hashTable[slot]; buffer; buffer = buffer->collision)
+		if (buffer->sectorNumber == sectorNumber && buffer->dbb == bdb->dbb)
+			{
+			Sync syncBuffer(&buffer->syncObject, "SectorCache::readPage(2)");
+			syncBuffer.lock(Shared);
+			sync.unlock();
+			buffer->readPage(bdb);
+			
+			return;
+			}
+	
+	sync.unlock();
+	sync.lock(Exclusive);
+	
+	for (buffer = hashTable[slot]; buffer; buffer = buffer->collision)
+		if (buffer->sectorNumber == sectorNumber && buffer->dbb == bdb->dbb)
+			{
+			Sync syncBuffer(&buffer->syncObject, "SectorCache::readPage(3)");
+			syncBuffer.lock(Shared);
+			sync.unlock();
+			buffer->readPage(bdb);
+			
+			return;
+			}
+	
+	buffer = nextBuffer;
+	nextBuffer = buffer->next;
+	Sync syncBuffer(&buffer->syncObject, "SectorCache::readPage(3)");
+	syncBuffer.lock(Exclusive);
+	
+	if (buffer->sectorNumber >= 0)
+		for (SectorBuffer **ptr = hashTable + (buffer->sectorNumber % SECTOR_HASH_SIZE);
*ptr; ptr = &(*ptr)->collision)
+			if (*ptr == buffer)
+				{
+				*ptr = buffer->collision;
+				
+				break;
+				}
+		
+	buffer->collision = hashTable[slot];
+	hashTable[slot] = buffer;
+	buffer->setSector(bdb->dbb, sectorNumber);
+	sync.unlock();
+	buffer->readSector();
+	buffer->readPage(bdb);	
+}
+
+void SectorCache::writePage(Bdb* bdb)
+{
+	Sync sync(&syncObject, "SectorCache::writePage");
+	sync.lock(Shared);
+	int sectorNumber = bdb->pageNumber / pagesPerSector;
+	int slot = sectorNumber % SECTOR_HASH_SIZE;
+	
+	for (SectorBuffer *buffer = hashTable[slot]; buffer; buffer = buffer->collision)
+		if (buffer->sectorNumber == sectorNumber && buffer->dbb == bdb->dbb)
+			{
+			Sync syncBuffer(&buffer->syncObject, "SectorCache::writePage(2)");
+			syncBuffer.lock(Shared);
+			sync.unlock();
+			buffer->writePage(bdb);
+			
+			return;
+			}
+}

=== added file 'storage/falcon/SectorCache.h'
--- a/storage/falcon/SectorCache.h	1970-01-01 00:00:00 +0000
+++ b/storage/falcon/SectorCache.h	2008-06-06 19:20:10 +0000
@@ -0,0 +1,47 @@
+/* Copyright (C) 2008 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 _SECTOR_CACHE_H_
+#define _SECTOR_CACHE_H_
+
+#include "SyncObject.h"
+
+static const int SECTOR_BUFFER_SIZE		= 65536;
+static const int SECTOR_HASH_SIZE		= 1024;
+
+class SectorBuffer;
+class Dbb;
+class Bdb;
+
+class SectorCache
+{
+public:
+	SectorCache(int numberBuffers, int pageSize);
+	~SectorCache(void);
+	
+	void readPage(Bdb* bdb);
+
+	SyncObject		syncObject;
+	SectorBuffer	*buffers;
+	SectorBuffer	*nextBuffer;
+	SectorBuffer	*hashTable[SECTOR_HASH_SIZE];
+	UCHAR			*bufferSpace;
+	int				numberBuffers;
+	int				pageSize;
+	int				pagesPerSector;
+	void writePage(Bdb* bdb);
+};
+
+#endif

Thread
commit into mysql-6.0-falcon:mysql-6.0-falcon branch (olav:2693) Olav Sandstaa7 Jun