Permalink
Browse files

Checkpoint for EE part's AntiCache stats.

  • Loading branch information...
malin1993ml committed Aug 24, 2015
1 parent ca25aa2 commit e1bca3b41eefb9d6449c1042fc84df95eedd0128
View
@@ -420,6 +420,7 @@
EvictedTupleAccessException.cpp
UnknownBlockAccessException.cpp
FullBackingStoreException.cpp
AntiCacheStats.cpp
AntiCacheDB.cpp
BerkeleyAntiCacheDB.cpp
NVMAntiCacheDB.cpp
@@ -25,6 +25,7 @@
#include "anticache/AntiCacheDB.h"
#include "anticache/UnknownBlockAccessException.h"
#include "anticache/AntiCacheStats.h"
#include "common/debuglog.h"
#include "common/FatalException.hpp"
#include "common/executorcontext.hpp"
@@ -65,10 +66,13 @@ AntiCacheDB::AntiCacheDB(ExecutorContext *ctx, std::string db_dir, long blockSiz
m_blocksEvicted = 0;
m_bytesUnevicted = 0;
m_blocksUnevicted = 0;
m_stats = new AntiCacheStats(NULL, this);
}
AntiCacheDB::~AntiCacheDB() {
delete m_stats;
}
AntiCacheBlock* AntiCacheDB::getLRUBlock() {
@@ -120,6 +124,9 @@ uint16_t AntiCacheDB::popBlockLRU() {
return blockId;
}
void AntiCacheDB::setStatsSource() {
//m_stats = new AntiCacheStats(NULL, this);
}
}
@@ -47,6 +47,7 @@ namespace voltdb {
class ExecutorContext;
class AntiCacheDB;
class AntiCacheStats;
/**
* Wrapper class for an evicted block that has been read back in
@@ -121,6 +122,8 @@ class AntiCacheDB {
* Flush the buffered blocks to disk.
*/
virtual void flushBlocks() = 0;
virtual void setStatsSource();
/**
* Return the next BlockId to use in the anti-cache database
@@ -198,6 +201,10 @@ class AntiCacheDB {
inline void setACID(int16_t ACID) {
m_ACID = ACID;
}
virtual inline AntiCacheStats* getACDBStats() {
return m_stats;
}
/**
* Return the AntiCacheID number.
@@ -318,7 +325,7 @@ class AntiCacheDB {
int64_t m_bytesUnevicted;
int32_t m_blocksUnevicted;
voltdb::AntiCacheStats* m_stats;
/* we need to test whether a deque or list is better. If we push/pop more than we
* remove, this is better. otherwise, let's use a list
@@ -33,6 +33,7 @@ vector<string> AntiCacheStats::generateAntiCacheStatsColumnNames() {
columnNames.push_back("ANTICACHE_ID");
columnNames.push_back("TABLE_ID");
columnNames.push_back("ANTICACHEDB_TYPE");
columnNames.push_back("ANTICACHE_LAST_BLOCKS_EVICTED");
columnNames.push_back("ANTICACHE_LAST_BYTES_EVICTED");
@@ -68,6 +69,11 @@ void AntiCacheStats::populateAntiCacheStatsSchema(
columnLengths.push_back(NValue::getTupleStorageSize(VALUE_TYPE_INTEGER));
allowNull.push_back(false);
// AntiCacheDB_TYPE
types.push_back(VALUE_TYPE_INTEGER);
columnLengths.push_back(NValue::getTupleStorageSize(VALUE_TYPE_INTEGER));
allowNull.push_back(false);
//ANTICACHE_LAST_BLOCKS_EVICTED
types.push_back(VALUE_TYPE_INTEGER);
columnLengths.push_back(NValue::getTupleStorageSize(VALUE_TYPE_INTEGER));
@@ -171,10 +177,12 @@ AntiCacheStats::AntiCacheStats(Table* table, AntiCacheDB* acdb)
m_lastBlocksUnevicted = 0;
m_lastBytesUnevicted = 0;
/*
m_currentBlocksEvicted = 0;
m_currentBytesEvicted = 0;
m_currentBlocksUnevicted = 0;
m_currentBytesUnevicted = 0;
*/
m_currentEvictedBlocks = 0;
@@ -201,7 +209,7 @@ void AntiCacheStats::configure(
CatalogId partitionId,
CatalogId databaseId) {
StatsSource::configure(name, hostId, hostname, siteId, partitionId, databaseId);
m_acid = acdb->getACID();
m_acid = m_acdb->getACID();
}
/**
@@ -218,7 +226,7 @@ vector<string> AntiCacheStats::generateStatsColumnNames() {
*/
void AntiCacheStats::updateStatsTuple(TableTuple *tuple) {
AntiCacheDB acdb = m_acdb;
AntiCacheDB* acdb = m_acdb;
int32_t totalBlocksEvicted = acdb->getBlocksEvicted();
int64_t totalBytesEvicted = acdb->getBytesEvicted();
@@ -243,42 +251,45 @@ void AntiCacheStats::updateStatsTuple(TableTuple *tuple) {
tuple->setNValue(
StatsSource::m_columnName2Index["ANTICACHE_ID"],
ValueFactory::getIntegerValue(m_acid));
tuple->setNValue(
StatsSource::m_columnName2Index["ANTICACHEDB_TYPE"],
ValueFactory::getIntegerValue(acdb->getDBType()));
tuple->setNValue(
StatsSource::m_columnName2Index["ANTICACHE_LAST_BLOCKS_EVICTED"],
ValueFactory::getIntegerValue());
ValueFactory::getIntegerValue(m_lastBlocksEvicted));
tuple->setNValue(
StatsSource::m_columnName2Index["ANTICACHE_LAST_BYTES_EVICTED"],
ValueFactory::getBigIntValue());
ValueFactory::getBigIntValue(m_lastBytesEvicted));
tuple->setNValue(
StatsSource::m_columnName2Index["ANTICACHE_LAST_BLOCKS_UNEVICTED"],
ValueFactory::getIntegerValue());
ValueFactory::getIntegerValue(m_lastBlocksUnevicted));
tuple->setNValue(
StatsSource::m_columnName2Index["ANTICACHE_LAST_BYTES_UNEVICTED"],
ValueFactory::getBigIntValue());
ValueFactory::getBigIntValue(m_lastBytesUnevicted));
tuple->setNValue(
StatsSource::m_columnName2Index["ANTICACHE_TOTAL_BLOCKS_EVICTED"],
ValueFactory::getIntegerValue());
ValueFactory::getIntegerValue(m_totalBlocksEvicted));
tuple->setNValue(
StatsSource::m_columnName2Index["ANTICACHE_TOTAL_BYTES_EVICTED"],
ValueFactory::getBigIntValue());
ValueFactory::getBigIntValue(m_totalBytesEvicted));
tuple->setNValue(
StatsSource::m_columnName2Index["ANTICACHE_TOTAL_BLOCKS_UNEVICTED"],
ValueFactory::getIntegerValue());
ValueFactory::getIntegerValue(m_totalBlocksUnevicted));
tuple->setNValue(
StatsSource::m_columnName2Index["ANTICACHE_TOTAL_BYTES_UNEVICTED"],
ValueFactory::getBigIntValue());
ValueFactory::getBigIntValue(m_totalBytesUnevicted));
tuple->setNValue(
StatsSource::m_columnName2Index["ANTICACHE_BLOCKS_STORED"],
ValueFactory::getIntegerValue());
ValueFactory::getIntegerValue(m_totalBlocksEvicted - m_totalBlocksUnevicted));
tuple->setNValue(
StatsSource::m_columnName2Index["ANTICACHE_BYTES_STORED"],
ValueFactory::getBigIntValue());
ValueFactory::getBigIntValue(m_totalBytesEvicted - m_totalBytesUnevicted));
tuple->setNValue(
StatsSource::m_columnName2Index["ANTICACHE_BLOCKS_FREE"],
ValueFactory::getIntegerValue());
ValueFactory::getIntegerValue(m_currentFreeBlocks));
tuple->setNValue(
StatsSource::m_columnName2Index["ANTICACHE_BYTES_FREE"],
ValueFactory::getBigIntValue());
ValueFactory::getBigIntValue(m_currentFreeBytes));
}
@@ -294,6 +305,6 @@ void AntiCacheStats::populateSchema(
}
AntiCacheStats::~AntiCacheStats() {
m_tableName.free();
m_tableType.free();
//m_tableName.free();
//m_tableType.free();
}
@@ -76,6 +76,8 @@ class AntiCacheStats : public voltdb::StatsSource {
voltdb::CatalogId partitionId,
voltdb::CatalogId databaseId);
virtual ~AntiCacheStats();
protected:
/**
@@ -96,14 +98,16 @@ class AntiCacheStats : public voltdb::StatsSource {
*/
virtual void populateSchema(std::vector<voltdb::ValueType> &types, std::vector<int32_t> &columnLengths, std::vector<bool> &allowNull);
~AntiCacheStats();
private:
/**
* AntiCacheDB whose stats are being collected.
*/
AntiCacheDB * m_acdb;
// actually we don't need this now
Table* m_table;
// AntiCacheID
int16_t m_acid;
@@ -121,6 +125,12 @@ class AntiCacheStats : public voltdb::StatsSource {
int32_t m_totalBlocksUnevicted;
int64_t m_totalBytesUnevicted;
/*
int32_t m_currentBlocksEvicted;
int64_t m_currentBytesEvicted;
int32_t m_currentBlocksUnevicted;
int64_t m_currentBytesUnevicted;*/
// current number of blocks in storage
int32_t m_currentEvictedBlocks;
int64_t m_currentEvictedBytes;
@@ -100,6 +100,7 @@
#include "storage/TableCatalogDelegate.hpp"
#include "org_voltdb_jni_ExecutionEngine.h" // to use static values
#include "stats/StatsAgent.h"
#include "stats/StatsSource.h"
#include "voltdbipc.h"
#include "common/FailureInjection.h"
@@ -838,6 +839,16 @@ bool VoltDBEngine::rebuildTableCollections() {
STATISTICS_SELECTOR_TYPE_INDEX,
indexId, index->getIndexStats());
}
// Add all different levels of anticacheDB to the stats source.
// This is duplicated, but that's fine for now (in case we need to get per-tire-table anticache stats).
std::vector <AntiCacheDB*> tacdbs = tcd->getTable()->allACDBs();
for (int i = 0; i < tacdbs.size(); i++) {
VOLT_ERROR("CREATE ACDBStats: %d\n", i);
getStatsManager().registerStatsSource(
STATISTICS_SELECTOR_TYPE_MULTITIER_ANTICACHE,
static_cast<CatalogId>(i), (StatsSource*)(tacdbs[i]->getACDBStats()));
}
}
cdIt++;
}
@@ -1279,8 +1290,30 @@ int VoltDBEngine::getStats(int selector, int locators[], int numLocators,
// -------------------------------------------------
// MULTITIER STATS
// -------------------------------------------------
case STATISTICS_SELECTOR_MULTITIER_ANTICACHE: {
case STATISTICS_SELECTOR_TYPE_MULTITIER_ANTICACHE: {
for (int ii = 0; ii < numLocators; ii++) {
CatalogId locator = static_cast<CatalogId>(locators[ii]);
locatorIds.push_back(locator);
}
/*
for (int ii = 0; ii < numLocators; ii++) {
CatalogId locator = static_cast<CatalogId>(locators[ii]);
if (m_tables.find(locator) == m_tables.end()) {
char message[256];
snprintf(message, 256,
"getStats() called with selector %d, and"
" an invalid locator %d that does not correspond to"
" a table", selector, locator);
throw SerializableEEException(
VOLT_EE_EXCEPTION_TYPE_EEEXCEPTION, message);
}
}*/
resultTable = m_statsManager.getStats(
(StatisticsSelectorType) selector, locatorIds, interval,
now);
break;
}
default:
char message[256];
@@ -252,6 +252,15 @@ AntiCacheDB* PersistentTable::getAntiCacheDB(int level)
return m_executorContext->getAntiCacheDB(level);
}
std::vector<AntiCacheDB*> PersistentTable::allACDBs() const {
std::vector<AntiCacheDB*> retval;
int numDBs = (int)m_executorContext->getAntiCacheEvictionManager()->getNumAntiCacheDBs();
for (int i = 0; i < numDBs; ++i)
retval.push_back(m_executorContext->getAntiCacheDB(i));
return retval;
}
int32_t PersistentTable::getTuplesEvicted()
{
return m_tuplesEvicted;
@@ -312,6 +312,7 @@ class PersistentTable : public Table {
void clearUnevictedBlockIDs();
char* getUnevictedBlocks(int i);
int unevictedBlocksSize();
std::vector<AntiCacheDB*> allACDBs() const;
#endif
View
@@ -618,4 +618,10 @@ void Table::loadTuplesFrom(bool allowExport,
loadTuplesFromNoHeader( allowExport, serialize_io, stringPool);
}
#ifdef ANTICACHE
std::vector<AntiCacheDB*> Table::allACDBs() const{
return std::vector<AntiCacheDB*>();
}
#endif
}
View
@@ -57,6 +57,7 @@
#include "common/Pool.hpp"
#include "common/tabletuple.h"
#include "common/MMAPMemoryManager.h"
#include "anticache/AntiCacheDB.h"
namespace voltdb {
@@ -221,6 +222,8 @@ class Table {
inline int32_t getTuplesRead() const { return (m_tuplesRead); }
inline int32_t getBlocksRead() const { return (m_blocksRead); }
inline int64_t getBytesRead() const { return (m_bytesRead); }
virtual std::vector<AntiCacheDB*> allACDBs() const;
#endif
int getTupleID(const char* tuple_address);

0 comments on commit e1bca3b

Please sign in to comment.