You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-24 22:42:05 +03:00
MCOL-498. Segment files extension uses fallocate() now to optimize load put on SSD disks.
This commit is contained in:
@ -279,4 +279,21 @@ int BufferedFile::close()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int BufferedFile::fallocate(int mode, off64_t offset, off64_t length)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
int savedErrno = 0;
|
||||||
|
|
||||||
|
ret = ::fallocate( fileno(m_fp), mode, offset, length );
|
||||||
|
savedErrno = errno;
|
||||||
|
|
||||||
|
if ( ret == -1 && IDBLogger::isEnabled() )
|
||||||
|
{
|
||||||
|
IDBLogger::logNoArg(m_fname, this, "fallocate", errno);
|
||||||
|
}
|
||||||
|
|
||||||
|
errno = savedErrno;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@ public:
|
|||||||
/* virtual */ off64_t tell();
|
/* virtual */ off64_t tell();
|
||||||
/* virtual */ int flush();
|
/* virtual */ int flush();
|
||||||
/* virtual */ time_t mtime();
|
/* virtual */ time_t mtime();
|
||||||
|
/* virtual */ int fallocate(int mode, off64_t offset, off64_t length);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/* virtual */
|
/* virtual */
|
||||||
|
@ -186,6 +186,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual time_t mtime() = 0;
|
virtual time_t mtime() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The fallocate() method returns the modification time of the file in
|
||||||
|
* seconds. Returns -1 on error.
|
||||||
|
*/
|
||||||
|
virtual int fallocate(int mode, off64_t offset, off64_t length) = 0;
|
||||||
|
|
||||||
int colWidth()
|
int colWidth()
|
||||||
{
|
{
|
||||||
return m_fColWidth;
|
return m_fColWidth;
|
||||||
|
@ -329,4 +329,21 @@ int UnbufferedFile::close()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int UnbufferedFile::fallocate(int mode, off64_t offset, off64_t length)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
int savedErrno = 0;
|
||||||
|
|
||||||
|
ret = ::fallocate( m_fd, mode, offset, length );
|
||||||
|
savedErrno = errno;
|
||||||
|
|
||||||
|
if ( ret == -1 && IDBLogger::isEnabled() )
|
||||||
|
{
|
||||||
|
IDBLogger::logNoArg(m_fname, this, "fallocate", errno);
|
||||||
|
}
|
||||||
|
|
||||||
|
errno = savedErrno;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ public:
|
|||||||
/* virtual */ off64_t tell();
|
/* virtual */ off64_t tell();
|
||||||
/* virtual */ int flush();
|
/* virtual */ int flush();
|
||||||
/* virtual */ time_t mtime();
|
/* virtual */ time_t mtime();
|
||||||
|
/* virtual */ int fallocate(int mode, off64_t offset, off64_t length);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/* virtual */
|
/* virtual */
|
||||||
|
@ -348,4 +348,10 @@ int HdfsFile::close()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int HdfsFile::fallocate(int mode, off64_t offset, off64_t length)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ public:
|
|||||||
/* virtual */ off64_t tell();
|
/* virtual */ off64_t tell();
|
||||||
/* virtual */ int flush();
|
/* virtual */ int flush();
|
||||||
/* virtual */ time_t mtime();
|
/* virtual */ time_t mtime();
|
||||||
|
/* virtual */ int fallocate(int mode, off64_t offset, off64_t length);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/* virtual */
|
/* virtual */
|
||||||
|
@ -317,4 +317,9 @@ int HdfsRdwrFileBuffer::close()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int HdfsRdwrFileBuffer::fallocate(int mode, off64_t offset, off64_t length)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ public:
|
|||||||
/* virtual */ off64_t tell();
|
/* virtual */ off64_t tell();
|
||||||
/* virtual */ int flush();
|
/* virtual */ int flush();
|
||||||
/* virtual */ time_t mtime();
|
/* virtual */ time_t mtime();
|
||||||
|
/* virtual*/ int fallocate(int mode, off64_t offset, off64_t length);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/* virtual */
|
/* virtual */
|
||||||
|
@ -507,5 +507,10 @@ int HdfsRdwrMemBuffer::close()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int HdfsRdwrMemBuffer::fallocate(int mode, off64_t offset, off64_t length)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ public:
|
|||||||
/* virtual */ off64_t tell();
|
/* virtual */ off64_t tell();
|
||||||
/* virtual */ int flush();
|
/* virtual */ int flush();
|
||||||
/* virtual */ time_t mtime();
|
/* virtual */ time_t mtime();
|
||||||
|
/* virtual */ int fallocate(int mode, off64_t offset, off64_t length);
|
||||||
|
|
||||||
// Returns the total size of all currently allocated HdfsRdwrMemBuffers
|
// Returns the total size of all currently allocated HdfsRdwrMemBuffers
|
||||||
static size_t getTotalBuff()
|
static size_t getTotalBuff()
|
||||||
|
@ -834,7 +834,8 @@ int FileOp::extendFile(
|
|||||||
width,
|
width,
|
||||||
newFile, // new or existing file
|
newFile, // new or existing file
|
||||||
false, // don't expand; new extent
|
false, // don't expand; new extent
|
||||||
false ); // add full (not abbreviated) extent
|
false, // add full (not abbreviated) extent
|
||||||
|
true); // try to use fallocate first
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -1016,6 +1017,7 @@ int FileOp::addExtentExactFile(
|
|||||||
* headers will be included "if" it is a compressed file.
|
* headers will be included "if" it is a compressed file.
|
||||||
* bExpandExtent (in) - Expand existing extent, or initialize a new one
|
* bExpandExtent (in) - Expand existing extent, or initialize a new one
|
||||||
* bAbbrevExtent(in) - if creating new extent, is it an abbreviated extent
|
* bAbbrevExtent(in) - if creating new extent, is it an abbreviated extent
|
||||||
|
* bOptExtension(in) - full sized segment file allocation optimization flag
|
||||||
* RETURN:
|
* RETURN:
|
||||||
* returns ERR_FILE_WRITE if an error occurs,
|
* returns ERR_FILE_WRITE if an error occurs,
|
||||||
* else returns NO_ERROR.
|
* else returns NO_ERROR.
|
||||||
@ -1028,7 +1030,8 @@ int FileOp::initColumnExtent(
|
|||||||
int width,
|
int width,
|
||||||
bool bNewFile,
|
bool bNewFile,
|
||||||
bool bExpandExtent,
|
bool bExpandExtent,
|
||||||
bool bAbbrevExtent )
|
bool bAbbrevExtent,
|
||||||
|
bool bOptExtension)
|
||||||
{
|
{
|
||||||
if ((bNewFile) && (m_compressionType))
|
if ((bNewFile) && (m_compressionType))
|
||||||
{
|
{
|
||||||
@ -1071,6 +1074,7 @@ int FileOp::initColumnExtent(
|
|||||||
int writeSize = nBlocks * BYTE_PER_BLOCK; // 1M and 8M row extent size
|
int writeSize = nBlocks * BYTE_PER_BLOCK; // 1M and 8M row extent size
|
||||||
int loopCount = 1;
|
int loopCount = 1;
|
||||||
int remWriteSize = 0;
|
int remWriteSize = 0;
|
||||||
|
off64_t currFileSize = pFile->size();
|
||||||
|
|
||||||
if (nBlocks > MAX_NBLOCKS) // 64M row extent size
|
if (nBlocks > MAX_NBLOCKS) // 64M row extent size
|
||||||
{
|
{
|
||||||
@ -1099,10 +1103,14 @@ int FileOp::initColumnExtent(
|
|||||||
|
|
||||||
Stats::startParseEvent(WE_STATS_INIT_COL_EXTENT);
|
Stats::startParseEvent(WE_STATS_INIT_COL_EXTENT);
|
||||||
#endif
|
#endif
|
||||||
|
int savedErrno = 0;
|
||||||
// Allocate buffer, and store in scoped_array to insure it's deletion.
|
// Try to fallocate the space - fallback to write if fallocate has failed
|
||||||
// Create scope {...} to manage deletion of writeBuf.
|
if (!bOptExtension || pFile->fallocate(0, currFileSize, writeSize))
|
||||||
{
|
{
|
||||||
|
// Allocate buffer, store it in scoped_array to insure it's deletion.
|
||||||
|
// Create scope {...} to manage deletion of writeBuf.
|
||||||
|
// Save errno of the failed fallocate() to log it later.
|
||||||
|
savedErrno = errno;
|
||||||
unsigned char* writeBuf = new unsigned char[writeSize];
|
unsigned char* writeBuf = new unsigned char[writeSize];
|
||||||
boost::scoped_array<unsigned char> writeBufPtr( writeBuf );
|
boost::scoped_array<unsigned char> writeBufPtr( writeBuf );
|
||||||
|
|
||||||
@ -1159,6 +1167,18 @@ int FileOp::initColumnExtent(
|
|||||||
Stats::stopParseEvent(WE_STATS_CREATE_COL_EXTENT);
|
Stats::stopParseEvent(WE_STATS_CREATE_COL_EXTENT);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
// Log the fallocate() call result
|
||||||
|
std::ostringstream oss;
|
||||||
|
std::string errnoMsg;
|
||||||
|
Convertor::mapErrnoToString(savedErrno, errnoMsg);
|
||||||
|
oss << "FileOp::initColumnExtent(): fallocate(" << currFileSize <<
|
||||||
|
", " << writeSize << "): errno = " << savedErrno <<
|
||||||
|
": " << errnoMsg;
|
||||||
|
logging::Message::Args args;
|
||||||
|
args.add(oss.str());
|
||||||
|
SimpleSysLog::instance()->logMsg(args, logging::LOG_TYPE_INFO,
|
||||||
|
logging::M0006);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
@ -2790,7 +2810,8 @@ int FileOp::expandAbbrevColumnExtent(
|
|||||||
int rc = FileOp::initColumnExtent(pFile, dbRoot, blksToAdd, emptyVal, width,
|
int rc = FileOp::initColumnExtent(pFile, dbRoot, blksToAdd, emptyVal, width,
|
||||||
false, // existing file
|
false, // existing file
|
||||||
true, // expand existing extent
|
true, // expand existing extent
|
||||||
false); // n/a since not adding new extent
|
false, // n/a since not adding new extent
|
||||||
|
true); // optimize segment file extension
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -507,7 +507,8 @@ private:
|
|||||||
int width,
|
int width,
|
||||||
bool bNewFile,
|
bool bNewFile,
|
||||||
bool bExpandExtent,
|
bool bExpandExtent,
|
||||||
bool bAbbrevExtent );
|
bool bAbbrevExtent,
|
||||||
|
bool bOptExtension=false );
|
||||||
|
|
||||||
static void initDbRootExtentMutexes();
|
static void initDbRootExtentMutexes();
|
||||||
static void removeDbRootExtentMutexes();
|
static void removeDbRootExtentMutexes();
|
||||||
|
Reference in New Issue
Block a user