mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-06-06 08:21:01 +03:00
MCOL-498. Segment files extension uses fallocate() now to optimize load put on SSD disks.
This commit is contained in:
parent
8a7ccd7d93
commit
1d9f47a55c
@ -279,4 +279,21 @@ int BufferedFile::close()
|
||||
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 */ int flush();
|
||||
/* virtual */ time_t mtime();
|
||||
/* virtual */ int fallocate(int mode, off64_t offset, off64_t length);
|
||||
|
||||
protected:
|
||||
/* virtual */
|
||||
|
@ -186,6 +186,12 @@ public:
|
||||
*/
|
||||
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()
|
||||
{
|
||||
return m_fColWidth;
|
||||
|
@ -329,4 +329,21 @@ int UnbufferedFile::close()
|
||||
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 */ int flush();
|
||||
/* virtual */ time_t mtime();
|
||||
/* virtual */ int fallocate(int mode, off64_t offset, off64_t length);
|
||||
|
||||
protected:
|
||||
/* virtual */
|
||||
|
@ -348,4 +348,10 @@ int HdfsFile::close()
|
||||
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 */ int flush();
|
||||
/* virtual */ time_t mtime();
|
||||
/* virtual */ int fallocate(int mode, off64_t offset, off64_t length);
|
||||
|
||||
protected:
|
||||
/* virtual */
|
||||
|
@ -317,4 +317,9 @@ int HdfsRdwrFileBuffer::close()
|
||||
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 */ int flush();
|
||||
/* virtual */ time_t mtime();
|
||||
/* virtual*/ int fallocate(int mode, off64_t offset, off64_t length);
|
||||
|
||||
protected:
|
||||
/* virtual */
|
||||
|
@ -507,5 +507,10 @@ int HdfsRdwrMemBuffer::close()
|
||||
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 */ int flush();
|
||||
/* virtual */ time_t mtime();
|
||||
/* virtual */ int fallocate(int mode, off64_t offset, off64_t length);
|
||||
|
||||
// Returns the total size of all currently allocated HdfsRdwrMemBuffers
|
||||
static size_t getTotalBuff()
|
||||
|
@ -834,7 +834,8 @@ int FileOp::extendFile(
|
||||
width,
|
||||
newFile, // new or existing file
|
||||
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;
|
||||
}
|
||||
@ -1016,6 +1017,7 @@ int FileOp::addExtentExactFile(
|
||||
* headers will be included "if" it is a compressed file.
|
||||
* bExpandExtent (in) - Expand existing extent, or initialize a new one
|
||||
* bAbbrevExtent(in) - if creating new extent, is it an abbreviated extent
|
||||
* bOptExtension(in) - full sized segment file allocation optimization flag
|
||||
* RETURN:
|
||||
* returns ERR_FILE_WRITE if an error occurs,
|
||||
* else returns NO_ERROR.
|
||||
@ -1028,7 +1030,8 @@ int FileOp::initColumnExtent(
|
||||
int width,
|
||||
bool bNewFile,
|
||||
bool bExpandExtent,
|
||||
bool bAbbrevExtent )
|
||||
bool bAbbrevExtent,
|
||||
bool bOptExtension)
|
||||
{
|
||||
if ((bNewFile) && (m_compressionType))
|
||||
{
|
||||
@ -1071,6 +1074,7 @@ int FileOp::initColumnExtent(
|
||||
int writeSize = nBlocks * BYTE_PER_BLOCK; // 1M and 8M row extent size
|
||||
int loopCount = 1;
|
||||
int remWriteSize = 0;
|
||||
off64_t currFileSize = pFile->size();
|
||||
|
||||
if (nBlocks > MAX_NBLOCKS) // 64M row extent size
|
||||
{
|
||||
@ -1099,10 +1103,14 @@ int FileOp::initColumnExtent(
|
||||
|
||||
Stats::startParseEvent(WE_STATS_INIT_COL_EXTENT);
|
||||
#endif
|
||||
|
||||
// Allocate buffer, and store in scoped_array to insure it's deletion.
|
||||
// Create scope {...} to manage deletion of writeBuf.
|
||||
int savedErrno = 0;
|
||||
// Try to fallocate the space - fallback to write if fallocate has failed
|
||||
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];
|
||||
boost::scoped_array<unsigned char> writeBufPtr( writeBuf );
|
||||
|
||||
@ -1159,6 +1167,18 @@ int FileOp::initColumnExtent(
|
||||
Stats::stopParseEvent(WE_STATS_CREATE_COL_EXTENT);
|
||||
|
||||
#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;
|
||||
@ -2790,7 +2810,8 @@ int FileOp::expandAbbrevColumnExtent(
|
||||
int rc = FileOp::initColumnExtent(pFile, dbRoot, blksToAdd, emptyVal, width,
|
||||
false, // existing file
|
||||
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;
|
||||
}
|
||||
|
@ -507,7 +507,8 @@ private:
|
||||
int width,
|
||||
bool bNewFile,
|
||||
bool bExpandExtent,
|
||||
bool bAbbrevExtent );
|
||||
bool bAbbrevExtent,
|
||||
bool bOptExtension=false );
|
||||
|
||||
static void initDbRootExtentMutexes();
|
||||
static void removeDbRootExtentMutexes();
|
||||
|
Loading…
x
Reference in New Issue
Block a user