Skip to content

Commit 67df437

Browse files
jgates108iagaponenko
authored andcommitted
Added family map option to not use chunk size for distribution.
1 parent ecdff0f commit 67df437

4 files changed

Lines changed: 22 additions & 6 deletions

File tree

src/cconfig/CzarConfig.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ class CzarConfig {
221221
/// Return the sleep time (in milliseconds) between messages sent to active workers.
222222
int getMonitorSleepTimeMilliSec() const { return _monitorSleepTimeMilliSec->getVal(); }
223223

224+
/// Return true if family map chunk distribution should depend on chunk size.
225+
bool getFamilyMapUsingChunkSize() const { return _familyMapUsingChunkSize->getVal(); }
226+
224227
// Parameters of the Czar management service
225228

226229
std::string const& replicationInstanceId() const { return _replicationInstanceId->getVal(); }
@@ -424,6 +427,10 @@ class CzarConfig {
424427
CVTIntPtr _monitorSleepTimeMilliSec = util::ConfigValTInt::create(
425428
_configValMap, "activeworker", "monitorSleepTimeMilliSec", notReq, 15'000);
426429

430+
// FamilyMap
431+
CVTBoolPtr _familyMapUsingChunkSize =
432+
util::ConfigValTBool::create(_configValMap, "familymap", "usingChunkSize", notReq, 0);
433+
427434
/// This may impact `_resultMaxHttpConnections` as too many connections may cause kernel memory issues.
428435
CVTIntPtr _commandMaxHttpConnections =
429436
util::ConfigValTInt::create(_configValMap, "uberjob", "commandMaxHttpConnections", notReq, 2000);

src/czar/CzarChunkMap.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
// Qserv headers
3333
#include "qmeta/QMeta.h"
34+
#include "cconfig/CzarConfig.h"
3435
#include "czar/Czar.h"
3536
#include "czar/CzarRegistry.h"
3637
#include "qmeta/Exceptions.h"
@@ -342,7 +343,9 @@ bool CzarFamilyMap::_read() {
342343
}
343344

344345
// Make the new maps.
345-
shared_ptr<CzarFamilyMap::FamilyMapType> familyMapPtr = makeNewMaps(qChunkMap);
346+
auto czConfig = cconfig::CzarConfig::instance();
347+
bool usingChunkSize = czConfig->getFamilyMapUsingChunkSize();
348+
shared_ptr<CzarFamilyMap::FamilyMapType> familyMapPtr = makeNewMaps(qChunkMap, usingChunkSize);
346349

347350
verify(familyMapPtr);
348351

@@ -355,7 +358,7 @@ bool CzarFamilyMap::_read() {
355358
}
356359

357360
std::shared_ptr<CzarFamilyMap::FamilyMapType> CzarFamilyMap::makeNewMaps(
358-
qmeta::QMetaChunkMap const& qChunkMap) {
361+
qmeta::QMetaChunkMap const& qChunkMap, bool usingChunkSize) {
359362
// Create new maps.
360363
std::shared_ptr<FamilyMapType> newFamilyMap = make_shared<FamilyMapType>();
361364

@@ -370,7 +373,10 @@ std::shared_ptr<CzarFamilyMap::FamilyMapType> CzarFamilyMap::makeNewMaps(
370373
for (qmeta::QMetaChunkMap::ChunkInfo const& chunkInfo : chunks) {
371374
try {
372375
int64_t chunkNum = chunkInfo.chunk;
373-
CzarChunkMap::SizeT sz = chunkInfo.size;
376+
CzarChunkMap::SizeT sz = 1;
377+
if (usingChunkSize) {
378+
sz = chunkInfo.size;
379+
}
374380
LOGS(_log, LOG_LVL_DEBUG,
375381
cName(__func__) << "workerdId=" << workerId << " db=" << dbName << " table="
376382
<< tableName << " chunk=" << chunkNum << " sz=" << sz);

src/czar/CzarChunkMap.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,13 @@ class CzarFamilyMap {
298298

299299
/// Make a new FamilyMapType map including ChunkMap and WorkerChunkMap from the data
300300
/// in `qChunkMap`. Each family has its own ChunkMap and WorkerChunkMap.
301+
/// @param qChunkMap - data source for the family map
302+
/// @param usingChunkSize - true if the distribution of chunks will depend on the
303+
/// size of the chunks/
301304
///
302305
/// NOTE: This is likely an expensive operation and should probably only
303306
/// be called if new workers have been added or chunks have been moved.
304-
std::shared_ptr<FamilyMapType> makeNewMaps(qmeta::QMetaChunkMap const& qChunkMap);
307+
std::shared_ptr<FamilyMapType> makeNewMaps(qmeta::QMetaChunkMap const& qChunkMap, bool usingChunkSize);
305308

306309
/// Insert the new element described by the parameters into the `newFamilyMap` as appropriate.
307310
void insertIntoMaps(std::shared_ptr<FamilyMapType> const& newFamilyMap, std::string const& workerId,

src/czar/testCzar.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,13 @@ BOOST_AUTO_TEST_CASE(CzarChunkMap) {
191191

192192
auto jsTest1 = nlohmann::json::parse(test1);
193193
qmeta::QMetaChunkMap qChunkMap1 = convertJsonToChunkMap(jsTest1);
194-
auto familyMap = czFamMap.makeNewMaps(qChunkMap1);
194+
auto familyMap = czFamMap.makeNewMaps(qChunkMap1, true);
195195
czar::CzarFamilyMap::verify(familyMap); // Throws on failure.
196196
LOGS(_log, LOG_LVL_DEBUG, "CzarFamilyMap test 1 passed");
197197

198198
auto jsTest2 = nlohmann::json::parse(test2);
199199
qmeta::QMetaChunkMap qChunkMap2 = convertJsonToChunkMap(jsTest2);
200-
auto familyMap2 = czFamMap.makeNewMaps(qChunkMap2);
200+
auto familyMap2 = czFamMap.makeNewMaps(qChunkMap2, true);
201201
czar::CzarFamilyMap::verify(familyMap2); // Throws on failure.
202202
LOGS(_log, LOG_LVL_DEBUG, "CzarFamilyMap test 2 passed");
203203
}

0 commit comments

Comments
 (0)