mirror of https://gitee.com/bigwinds/arangodb
control RocksDB block cache filling for the primary and edge indexes (#2532)
This commit is contained in:
parent
4a0ec64668
commit
c176a11930
|
@ -61,6 +61,10 @@
|
||||||
using namespace arangodb;
|
using namespace arangodb;
|
||||||
using namespace arangodb::basics;
|
using namespace arangodb::basics;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
constexpr bool EdgeIndexFillBlockCache = false;
|
||||||
|
}
|
||||||
|
|
||||||
RocksDBEdgeIndexIterator::RocksDBEdgeIndexIterator(
|
RocksDBEdgeIndexIterator::RocksDBEdgeIndexIterator(
|
||||||
LogicalCollection* collection, transaction::Methods* trx,
|
LogicalCollection* collection, transaction::Methods* trx,
|
||||||
ManagedDocumentResult* mmdr, arangodb::RocksDBEdgeIndex const* index,
|
ManagedDocumentResult* mmdr, arangodb::RocksDBEdgeIndex const* index,
|
||||||
|
@ -69,15 +73,17 @@ RocksDBEdgeIndexIterator::RocksDBEdgeIndexIterator(
|
||||||
_keys(keys.get()),
|
_keys(keys.get()),
|
||||||
_keysIterator(_keys->slice()),
|
_keysIterator(_keys->slice()),
|
||||||
_index(index),
|
_index(index),
|
||||||
_iterator(
|
|
||||||
rocksutils::toRocksMethods(trx)->NewIterator(index->columnFamily())),
|
|
||||||
_bounds(RocksDBKeyBounds::EdgeIndex(0)),
|
_bounds(RocksDBKeyBounds::EdgeIndex(0)),
|
||||||
_cache(cache),
|
_cache(cache),
|
||||||
_builderIterator(arangodb::basics::VelocyPackHelper::EmptyArrayValue()) {
|
_builderIterator(arangodb::basics::VelocyPackHelper::EmptyArrayValue()) {
|
||||||
keys.release(); // now we have ownership for _keys
|
keys.release(); // now we have ownership for _keys
|
||||||
TRI_ASSERT(_keys != nullptr);
|
TRI_ASSERT(_keys != nullptr);
|
||||||
TRI_ASSERT(_keys->slice().isArray());
|
TRI_ASSERT(_keys->slice().isArray());
|
||||||
resetInplaceMemory();
|
|
||||||
|
auto* rocksMethods = rocksutils::toRocksMethods(trx);
|
||||||
|
rocksdb::ReadOptions options = rocksMethods->readOptions(); // intentional copy of the options
|
||||||
|
options.fill_cache = EdgeIndexFillBlockCache;
|
||||||
|
_iterator = std::move(rocksMethods->NewIterator(options, index->columnFamily()));
|
||||||
}
|
}
|
||||||
|
|
||||||
RocksDBEdgeIndexIterator::~RocksDBEdgeIndexIterator() {
|
RocksDBEdgeIndexIterator::~RocksDBEdgeIndexIterator() {
|
||||||
|
@ -620,6 +626,10 @@ void RocksDBEdgeIndex::warmup(arangodb::transaction::Methods* trx) {
|
||||||
ManagedDocumentResult mmdr;
|
ManagedDocumentResult mmdr;
|
||||||
bool needsInsert = false;
|
bool needsInsert = false;
|
||||||
|
|
||||||
|
// intentional copy of the read options
|
||||||
|
RocksDBMethods* mthds = rocksutils::toRocksMethods(trx);
|
||||||
|
auto options = mthds->readOptions();
|
||||||
|
options.fill_cache = EdgeIndexFillBlockCache;
|
||||||
cache::Cache* cc = _cache.get();
|
cache::Cache* cc = _cache.get();
|
||||||
rocksutils::iterateBounds(
|
rocksutils::iterateBounds(
|
||||||
bounds,
|
bounds,
|
||||||
|
@ -691,7 +701,8 @@ void RocksDBEdgeIndex::warmup(arangodb::transaction::Methods* trx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
RocksDBColumnFamily::edge());
|
RocksDBColumnFamily::edge(),
|
||||||
|
options);
|
||||||
|
|
||||||
if (!previous.empty() && needsInsert) {
|
if (!previous.empty() && needsInsert) {
|
||||||
// We still have something to store
|
// We still have something to store
|
||||||
|
|
|
@ -61,7 +61,7 @@ DocumentIdentifierToken RocksDBFulltextIndex::toDocumentIdentifierToken(
|
||||||
RocksDBFulltextIndex::RocksDBFulltextIndex(
|
RocksDBFulltextIndex::RocksDBFulltextIndex(
|
||||||
TRI_idx_iid_t iid, arangodb::LogicalCollection* collection,
|
TRI_idx_iid_t iid, arangodb::LogicalCollection* collection,
|
||||||
VPackSlice const& info)
|
VPackSlice const& info)
|
||||||
: RocksDBIndex(iid, collection, info, RocksDBColumnFamily::geo()),
|
: RocksDBIndex(iid, collection, info, RocksDBColumnFamily::geo(), false),
|
||||||
_minWordLength(TRI_FULLTEXT_MIN_WORD_LENGTH_DEFAULT) {
|
_minWordLength(TRI_FULLTEXT_MIN_WORD_LENGTH_DEFAULT) {
|
||||||
TRI_ASSERT(iid != 0);
|
TRI_ASSERT(iid != 0);
|
||||||
|
|
||||||
|
|
|
@ -235,7 +235,7 @@ void RocksDBGeoIndexIterator::reset() { replaceCursor(nullptr); }
|
||||||
RocksDBGeoIndex::RocksDBGeoIndex(TRI_idx_iid_t iid,
|
RocksDBGeoIndex::RocksDBGeoIndex(TRI_idx_iid_t iid,
|
||||||
arangodb::LogicalCollection* collection,
|
arangodb::LogicalCollection* collection,
|
||||||
VPackSlice const& info)
|
VPackSlice const& info)
|
||||||
: RocksDBIndex(iid, collection, info, RocksDBColumnFamily::geo()),
|
: RocksDBIndex(iid, collection, info, RocksDBColumnFamily::geo(), false),
|
||||||
_variant(INDEX_GEO_INDIVIDUAL_LAT_LON),
|
_variant(INDEX_GEO_INDIVIDUAL_LAT_LON),
|
||||||
_geoJson(false),
|
_geoJson(false),
|
||||||
_geoIndex(nullptr) {
|
_geoIndex(nullptr) {
|
||||||
|
|
|
@ -53,12 +53,12 @@ class RocksDBIndex : public Index {
|
||||||
attributes,
|
attributes,
|
||||||
bool unique, bool sparse,
|
bool unique, bool sparse,
|
||||||
rocksdb::ColumnFamilyHandle* cf,
|
rocksdb::ColumnFamilyHandle* cf,
|
||||||
uint64_t objectId = 0,
|
uint64_t objectId,
|
||||||
bool useCache = false);
|
bool useCache);
|
||||||
|
|
||||||
RocksDBIndex(TRI_idx_iid_t, LogicalCollection*,
|
RocksDBIndex(TRI_idx_iid_t, LogicalCollection*,
|
||||||
arangodb::velocypack::Slice const&, rocksdb::ColumnFamilyHandle* cf,
|
arangodb::velocypack::Slice const&, rocksdb::ColumnFamilyHandle* cf,
|
||||||
bool useCache = false);
|
bool useCache);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~RocksDBIndex();
|
~RocksDBIndex();
|
||||||
|
|
|
@ -30,6 +30,11 @@
|
||||||
|
|
||||||
using namespace arangodb;
|
using namespace arangodb;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
constexpr bool AllIteratorFillBlockCache = true;
|
||||||
|
constexpr bool AnyIteratorFillBlockCache = false;
|
||||||
|
}
|
||||||
|
|
||||||
// ================ All Iterator ==================
|
// ================ All Iterator ==================
|
||||||
|
|
||||||
RocksDBAllIndexIterator::RocksDBAllIndexIterator(
|
RocksDBAllIndexIterator::RocksDBAllIndexIterator(
|
||||||
|
@ -49,7 +54,7 @@ RocksDBAllIndexIterator::RocksDBAllIndexIterator(
|
||||||
rocksdb::ReadOptions options = mthds->readOptions();
|
rocksdb::ReadOptions options = mthds->readOptions();
|
||||||
TRI_ASSERT(options.snapshot != nullptr);
|
TRI_ASSERT(options.snapshot != nullptr);
|
||||||
TRI_ASSERT(options.prefix_same_as_start);
|
TRI_ASSERT(options.prefix_same_as_start);
|
||||||
options.fill_cache = true;
|
options.fill_cache = AllIteratorFillBlockCache;
|
||||||
options.verify_checksums = false; // TODO evaluate
|
options.verify_checksums = false; // TODO evaluate
|
||||||
// options.readahead_size = 4 * 1024 * 1024;
|
// options.readahead_size = 4 * 1024 * 1024;
|
||||||
_iterator = mthds->NewIterator(options, cf);
|
_iterator = mthds->NewIterator(options, cf);
|
||||||
|
@ -161,12 +166,12 @@ RocksDBAnyIndexIterator::RocksDBAnyIndexIterator(
|
||||||
static_cast<RocksDBCollection*>(col->getPhysical())->objectId())),
|
static_cast<RocksDBCollection*>(col->getPhysical())->objectId())),
|
||||||
_total(0),
|
_total(0),
|
||||||
_returned(0) {
|
_returned(0) {
|
||||||
// intentional copy of the read options
|
|
||||||
RocksDBMethods* mthds = rocksutils::toRocksMethods(trx);
|
RocksDBMethods* mthds = rocksutils::toRocksMethods(trx);
|
||||||
|
// intentional copy of the read options
|
||||||
auto options = mthds->readOptions();
|
auto options = mthds->readOptions();
|
||||||
TRI_ASSERT(options.snapshot != nullptr);
|
TRI_ASSERT(options.snapshot != nullptr);
|
||||||
TRI_ASSERT(options.prefix_same_as_start);
|
TRI_ASSERT(options.prefix_same_as_start);
|
||||||
options.fill_cache = false;
|
options.fill_cache = AnyIteratorFillBlockCache;
|
||||||
options.verify_checksums = false; // TODO evaluate
|
options.verify_checksums = false; // TODO evaluate
|
||||||
_iterator = mthds->NewIterator(options, RocksDBColumnFamily::documents());
|
_iterator = mthds->NewIterator(options, RocksDBColumnFamily::documents());
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,10 @@
|
||||||
|
|
||||||
using namespace arangodb;
|
using namespace arangodb;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
constexpr bool PrimaryIndexFillBlockCache = false;
|
||||||
|
}
|
||||||
|
|
||||||
// ================ Primary Index Iterator ================
|
// ================ Primary Index Iterator ================
|
||||||
|
|
||||||
/// @brief hard-coded vector of the index attributes
|
/// @brief hard-coded vector of the index attributes
|
||||||
|
@ -185,7 +189,8 @@ RocksDBToken RocksDBPrimaryIndex::lookupKey(transaction::Methods* trx,
|
||||||
|
|
||||||
// acquire rocksdb transaction
|
// acquire rocksdb transaction
|
||||||
RocksDBMethods* mthds = rocksutils::toRocksMethods(trx);
|
RocksDBMethods* mthds = rocksutils::toRocksMethods(trx);
|
||||||
auto& options = mthds->readOptions();
|
auto options = mthds->readOptions(); // intentional copy
|
||||||
|
options.fill_cache = PrimaryIndexFillBlockCache;
|
||||||
TRI_ASSERT(options.snapshot != nullptr);
|
TRI_ASSERT(options.snapshot != nullptr);
|
||||||
|
|
||||||
arangodb::Result r = mthds->Get(_cf, key, value.buffer());
|
arangodb::Result r = mthds->Get(_cf, key, value.buffer());
|
||||||
|
|
|
@ -171,7 +171,7 @@ uint64_t RocksDBVPackIndex::HashForKey(const rocksdb::Slice& key) {
|
||||||
RocksDBVPackIndex::RocksDBVPackIndex(TRI_idx_iid_t iid,
|
RocksDBVPackIndex::RocksDBVPackIndex(TRI_idx_iid_t iid,
|
||||||
arangodb::LogicalCollection* collection,
|
arangodb::LogicalCollection* collection,
|
||||||
arangodb::velocypack::Slice const& info)
|
arangodb::velocypack::Slice const& info)
|
||||||
: RocksDBIndex(iid, collection, info, RocksDBColumnFamily::index()),
|
: RocksDBIndex(iid, collection, info, RocksDBColumnFamily::index(), false),
|
||||||
_useExpansion(false),
|
_useExpansion(false),
|
||||||
_allowPartialIndex(true),
|
_allowPartialIndex(true),
|
||||||
_estimator(nullptr) {
|
_estimator(nullptr) {
|
||||||
|
|
Loading…
Reference in New Issue