Skip to content

Commit d3f2bd0

Browse files
committed
fix cpp build after sync origin/main with common patches merged
1 parent e21796a commit d3f2bd0

12 files changed

Lines changed: 43 additions & 47 deletions

File tree

cpp/bolt/benchmarks/GenericBenchmark.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ auto BM_Generic = [](::benchmark::State& state,
397397
listener->updateLimit(FLAGS_memory_limit);
398398

399399
auto* listenerPtr = listener.get();
400-
auto* memoryManager = MemoryManager::create(kBoltBackendKind, std::move(listener), "bm-generic");
400+
auto* memoryManager = MemoryManager::create(kBoltBackendKind, std::move(listener));
401401
auto runtime = runtimeFactory(memoryManager);
402402

403403
auto plan = getPlanFromFile("Plan", planFile);
@@ -518,7 +518,7 @@ auto BM_ShuffleWriteRead = [](::benchmark::State& state,
518518
listener->updateLimit(FLAGS_memory_limit);
519519

520520
auto* listenerPtr = listener.get();
521-
auto* memoryManager = MemoryManager::create(kBoltBackendKind, std::move(listener), "bm-shuffle-write-read");
521+
auto* memoryManager = MemoryManager::create(kBoltBackendKind, std::move(listener));
522522
auto runtime = runtimeFactory(memoryManager);
523523

524524
const size_t dirIndex = std::hash<std::thread::id>{}(std::this_thread::get_id()) % localDirs.size();

cpp/bolt/compute/BoltBackend.cc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,8 @@ using namespace bytedance;
7474
namespace gluten {
7575

7676
namespace {
77-
MemoryManager* boltMemoryManagerFactory(
78-
const std::string& kind,
79-
std::unique_ptr<AllocationListener> listener,
80-
const std::string& name) {
81-
return new BoltMemoryManager(kind, std::move(listener), *BoltBackend::get()->getBackendConf(), name);
77+
MemoryManager* boltMemoryManagerFactory(const std::string& kind, std::unique_ptr<AllocationListener> listener) {
78+
return new BoltMemoryManager(kind, std::move(listener), *BoltBackend::get()->getBackendConf(), "");
8279
}
8380

8481
void boltMemoryManagerReleaser(MemoryManager* memoryManager) {
@@ -110,12 +107,11 @@ Runtime* boltRuntimeFactory(
110107
const std::string& kind,
111108
MemoryManager* memoryManager,
112109
ThreadManager* threadManager,
113-
const std::unordered_map<std::string, std::string>& sessionConf,
114-
int64_t taskId) {
110+
const std::unordered_map<std::string, std::string>& sessionConf) {
115111
auto* vmm = dynamic_cast<BoltMemoryManager*>(memoryManager);
116112
GLUTEN_CHECK(vmm != nullptr, "Not a Bolt memory manager");
117113
// new object every time
118-
return new BoltRuntime(kind, vmm, threadManager, sessionConf, taskId);
114+
return new BoltRuntime(kind, vmm, threadManager, sessionConf);
119115
}
120116

121117
void boltRuntimeReleaser(Runtime* runtime) {

cpp/bolt/compute/BoltRuntime.cc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "compute/BoltPlanConverter.h"
3131
#include "config/BoltConfig.h"
3232
#include "config/GlutenConfig.h"
33+
#include "jni/TaskContextJniWrapper.h"
3334
#include "memory/BoltGlutenMemoryManager.h"
3435
#include "operators/serializer/BoltRowToColumnarConverter.h"
3536
#include "utils/ConfigExtractor.h"
@@ -66,18 +67,18 @@ BoltRuntime::BoltRuntime(
6667
const std::string& kind,
6768
BoltMemoryManager* vmm,
6869
ThreadManager* threadManager,
69-
const std::unordered_map<std::string, std::string>& confMap,
70-
int64_t taskId)
71-
: Runtime(kind, vmm, threadManager, confMap, taskId) {
70+
const std::unordered_map<std::string, std::string>& confMap)
71+
: Runtime(kind, vmm, threadManager, confMap) {
7272
// Refresh session config.
7373
boltCfg_ =
7474
std::make_shared<bytedance::bolt::config::ConfigBase>(std::unordered_map<std::string, std::string>(confMap_));
7575

7676
gluten::BoltGlutenMemoryManager::init(BoltBackend::getCombinedConf(boltCfg_)->rawConfigs());
7777

7878
if (gluten::BoltGlutenMemoryManager::enabled()) {
79+
const auto taskAttemptId = gluten::getCurrentSparkTaskAttemptId();
7980
auto holder = gluten::BoltGlutenMemoryManager::getMemoryManagerHolder(
80-
memoryManager()->name(), taskId, reinterpret_cast<int64_t>(memoryManager()));
81+
"", taskAttemptId, reinterpret_cast<int64_t>(memoryManager()));
8182
auto mm = holder->getManager();
8283
leafPool_ = mm->getLeafMemoryPool();
8384
aggregatePool_ = mm->getAggregateMemoryPool();
@@ -217,8 +218,9 @@ std::shared_ptr<ResultIterator> BoltRuntime::createResultIterator(
217218
std::weak_ptr<ResultIterator> weakAns = ans;
218219
auto spiller = std::make_shared<OperatorSpiller>(weakAns);
219220
auto genericSpiller = std::dynamic_pointer_cast<bytedance::bolt::memory::sparksql::Spiller>(spiller);
221+
const auto taskAttemptId = gluten::getCurrentSparkTaskAttemptId();
220222
auto holder = gluten::BoltGlutenMemoryManager::getMemoryManagerHolder(
221-
memoryManager()->name(), taskId(), reinterpret_cast<int64_t>(memoryManager()));
223+
"", taskAttemptId, reinterpret_cast<int64_t>(memoryManager()));
222224
holder->appendSpiller(genericSpiller);
223225
}
224226

@@ -368,8 +370,9 @@ std::shared_ptr<ShuffleWriterBase> BoltRuntime::createShuffleWriter(
368370
auto weakShuffleWriter = std::weak_ptr<ShuffleWriterBase>(shuffleWriter);
369371
auto spiller = std::make_shared<ShuffleSpiller>(weakShuffleWriter);
370372
auto genericSpiller = std::dynamic_pointer_cast<bytedance::bolt::memory::sparksql::Spiller>(spiller);
373+
const auto taskAttemptId = gluten::getCurrentSparkTaskAttemptId();
371374
auto holder = gluten::BoltGlutenMemoryManager::getMemoryManagerHolder(
372-
memoryManager()->name(), taskId(), reinterpret_cast<int64_t>(memoryManager()));
375+
"", taskAttemptId, reinterpret_cast<int64_t>(memoryManager()));
373376
holder->appendSpiller(genericSpiller);
374377
}
375378
return shuffleWriter;

cpp/bolt/compute/BoltRuntime.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ class BoltRuntime final : public Runtime {
4646
const std::string& kind,
4747
BoltMemoryManager* vmm,
4848
ThreadManager* threadManager,
49-
const std::unordered_map<std::string, std::string>& confMap,
50-
int64_t taskId);
49+
const std::unordered_map<std::string, std::string>& confMap);
5150

5251
void setSparkTaskInfo(SparkTaskInfo taskInfo) override {
5352
static std::atomic<uint32_t> vtId{0};

cpp/bolt/compute/WholeStageResultIterator.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "BoltBackend.h"
2424
#include "BoltRuntime.h"
2525
#include "config/BoltConfig.h"
26+
#include "jni/TaskContextJniWrapper.h"
2627
#include "memory/BoltMemoryManager.h"
2728
#include "memory/BoltGlutenMemoryManager.h"
2829
#include "bolt/connectors/hive/HiveConfig.h"
@@ -379,8 +380,9 @@ std::shared_ptr<bolt::core::QueryCtx> WholeStageResultIterator::createNewBoltQue
379380

380381
memory::sparksql::BoltMemoryPoolPtr boltPool;
381382
if (gluten::BoltGlutenMemoryManager::enabled()) {
383+
const auto taskAttemptId = gluten::getCurrentSparkTaskAttemptId();
382384
auto holder = gluten::BoltGlutenMemoryManager::getMemoryManagerHolder(
383-
memoryManager_->name(), taskInfo_.taskId, reinterpret_cast<int64_t>(memoryManager_));
385+
"", taskAttemptId, reinterpret_cast<int64_t>(memoryManager_));
384386
auto mm = holder->getManager();
385387
boltPool = mm->getAggregateMemoryPool();
386388
} else {
@@ -473,8 +475,9 @@ int64_t WholeStageResultIterator::spillFixedSize(int64_t size) {
473475
memory::sparksql::BoltMemoryPoolPtr pool;
474476
memory::sparksql::BoltMemoryManagerPtr manager;
475477
if (gluten::BoltGlutenMemoryManager::enabled()) {
478+
const auto taskAttemptId = gluten::getCurrentSparkTaskAttemptId();
476479
auto holder = gluten::BoltGlutenMemoryManager::getMemoryManagerHolder(
477-
memoryManager_->name(), taskInfo_.taskId, reinterpret_cast<int64_t>(memoryManager_));
480+
"", taskAttemptId, reinterpret_cast<int64_t>(memoryManager_));
478481
manager = holder->getManager();
479482
pool = manager->getAggregateMemoryPool();
480483
} else {

cpp/bolt/memory/BoltMemoryManager.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ BoltMemoryManager::BoltMemoryManager(
223223
std::unique_ptr<AllocationListener> listener,
224224
const bytedance::bolt::config::ConfigBase& backendConf,
225225
const std::string& name)
226-
: MemoryManager(kind, name), listener_(std::move(listener)) {
226+
: MemoryManager(kind), listener_(std::move(listener)) {
227227
auto reservationBlockSize =
228228
backendConf.get<uint64_t>(kMemoryReservationBlockSize, kMemoryReservationBlockSizeDefault);
229229
blockListener_ = std::make_unique<BlockAllocationListener>(listener_.get(), reservationBlockSize);

cpp/bolt/tests/RuntimeTest.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ TEST(TestRuntime, CreateRuntime) {
164164

165165
TEST(TestRuntime, CreateBoltRuntime) {
166166
BoltBackend::create(AllocationListener::noop(), {{kSparkOffHeapMemory, "7516192768"}});
167-
auto mm = MemoryManager::create(kBoltBackendKind, AllocationListener::noop(), "test-bolt-runtime");
167+
auto mm = MemoryManager::create(kBoltBackendKind, AllocationListener::noop());
168168
auto tm = ThreadManager::create(kBoltBackendKind, ThreadInitializer::noop());
169169
auto runtime = Runtime::create(kBoltBackendKind, mm, tm, {{kSparkOffHeapMemory, "7516192768"}}, 1);
170170
ASSERT_EQ(typeid(*runtime), typeid(BoltRuntime));

cpp/bolt/utils/ConfigExtractor.cc

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -228,20 +228,6 @@ void getAbfsHiveConfig(
228228
static const std::string kUseIcuRegex = "spark.gluten.sql.columnar.backend.bolt.useICURegex";
229229
static const std::string kUseIcuRegexDefault = "true";
230230

231-
std::string getConfigValue(
232-
const std::unordered_map<std::string, std::string>& confMap,
233-
const std::string& key,
234-
const std::optional<std::string>& fallbackValue) {
235-
auto got = confMap.find(key);
236-
if (got == confMap.end()) {
237-
if (fallbackValue == std::nullopt) {
238-
throw std::runtime_error("No such config key: " + key);
239-
}
240-
return fallbackValue.value();
241-
}
242-
return got->second;
243-
}
244-
245231
std::shared_ptr<bytedance::bolt::config::ConfigBase> getHiveConfig(
246232
std::shared_ptr<bytedance::bolt::config::ConfigBase> conf,
247233
FileSystemType fsType) {

cpp/bolt/utils/ConfigExtractor.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,12 @@
2525

2626
#include "config/GlutenConfig.h"
2727
#include "bolt/common/config/Config.h"
28+
#include "utils/ConfigResolver.h"
2829

2930
namespace gluten {
3031

3132
enum class FileSystemType : uint8_t { kHdfs, kS3, kAbfs, kGcs, kAll };
3233

33-
std::string getConfigValue(
34-
const std::unordered_map<std::string, std::string>& confMap,
35-
const std::string& key,
36-
const std::optional<std::string>& fallbackValue);
37-
3834
std::shared_ptr<bytedance::bolt::config::ConfigBase> getHiveConfig(
3935
std::shared_ptr<bytedance::bolt::config::ConfigBase> conf,
4036
FileSystemType fsType = FileSystemType::kAll);

cpp/core/jni/JniCommon.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,6 @@ class JniCommonState {
165165

166166
void close();
167167

168-
JavaVM* getJavaVM() const {
169-
return vm_;
170-
}
171-
172168
jmethodID runtimeAwareCtxHandle();
173169

174170
JavaVM* getJavaVM() const {

0 commit comments

Comments
 (0)