Skip to content

Commit 67b01ec

Browse files
committed
add components information to the serviceMeta
1 parent b40bb5d commit 67b01ec

File tree

37 files changed

+122
-75
lines changed

37 files changed

+122
-75
lines changed

cpp/tools/build_ppc.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,8 @@ generate_node_config_ini() {
411411
; data_location = data
412412
; task_timeout_minutes = 180
413413
; thread_count = 8
414+
; GB, reject task if available memory is less than min_needed_memory
415+
; min_needed_memory = 1
414416
415417
[transport]
416418
; the endpoint information
@@ -458,8 +460,6 @@ generate_node_config_ini() {
458460
; ssl connection switch, if disable the ssl connection, default: false
459461
;disable_ssl = true
460462
;disable_db = true
461-
; GB, reject task if available memory is less than min_needed_memory
462-
; min_needed_memory = 5
463463
464464
[cert]
465465
; directory the certificates located in

cpp/tools/build_wedpr_cem.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,6 @@ generate_config_ini() {
351351
sm_ssl=${sm_mode}
352352
; ssl connection switch, if disable the ssl connection, default: false
353353
;disable_ssl = true
354-
; GB, reject task if available memory is less than min_needed_memory
355-
; min_needed_memory = 5
356354
357355
[hdfs_storage]
358356
; the hdfs configuration

cpp/tools/ppc-builder/src/tpl/config.ini.node

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
; data_location = data
1010
; task_timeout_minutes = 180
1111
; thread_count = 8
12+
; GB, reject task if available memory is less than min_needed_memory
13+
; min_needed_memory = 1
1214

1315
[crypto]
1416
sm_crypto = false
@@ -23,8 +25,6 @@
2325
; ssl connection switch, if disable the ssl connection, default: true
2426
disable_ssl = true
2527
; disable_db = true
26-
; GB, reject task if available memory is less than min_needed_memory
27-
; min_needed_memory = 5
2828

2929
[cert]
3030
; directory the certificates located in

cpp/wedpr-computing/ppc-psi/src/Common.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* @date 2022-12-26
1919
*/
2020
#pragma once
21+
#include "ppc-framework/Common.h"
2122
#include "ppc-tools/src/common/MemInfo.h"
2223
#include <cstdint>
2324
#include <sstream>
@@ -151,13 +152,14 @@ inline std::ostream& operator<<(std::ostream& _out, CacheState const& _state)
151152
return _out;
152153
}
153154

154-
inline void checkHostResource()
155+
inline void checkHostResource(uint64_t minNeededMemoryGB)
155156
{
156157
#ifdef __linux__
157-
if (!hasAvailableMem(m_minNeededMemoryGB))
158+
if (!ppc::tools::hasAvailableMem(minNeededMemoryGB))
158159
{
159-
BOOST_THROW_EXCEPTION(
160-
BCOS_ERROR((int64_t)RpcError::LackOfMemory, "Lack of memory, please try again later."));
160+
BOOST_THROW_EXCEPTION(WeDPRException() << bcos::errinfo_comment(
161+
"Lack of memory, please try again later. minNeededMemoryGB: " +
162+
std::to_string(minNeededMemoryGB)));
161163
}
162164
#endif
163165
}

cpp/wedpr-computing/ppc-psi/src/PSIConfig.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,31 @@ class PSIConfig
3737
public:
3838
using Ptr = std::shared_ptr<PSIConfig>;
3939
PSIConfig(ppc::protocol::TaskAlgorithmType _algorithmType,
40-
ppc::io::DataResourceLoader::Ptr _dataResourceLoader)
41-
: m_algorithmType(_algorithmType), m_dataResourceLoader(std::move(_dataResourceLoader))
40+
ppc::io::DataResourceLoader::Ptr _dataResourceLoader, uint32_t minNeededMemoryGB = 1)
41+
: m_algorithmType(_algorithmType),
42+
m_dataResourceLoader(std::move(_dataResourceLoader)),
43+
m_minNeededMemoryGB(minNeededMemoryGB)
4244
{}
4345

4446
PSIConfig(ppc::protocol::TaskAlgorithmType _algorithmType, const std::string& _selfParty,
4547
ppc::front::FrontInterface::Ptr _front,
4648
ppc::front::PPCMessageFaceFactory::Ptr _ppcMsgFactory,
47-
ppc::io::DataResourceLoader::Ptr _dataResourceLoader, int _holdingMessageMinutes)
49+
ppc::io::DataResourceLoader::Ptr _dataResourceLoader, int _holdingMessageMinutes,
50+
uint32_t minNeededMemoryGB = 1)
4851
: m_algorithmType(_algorithmType),
4952
m_selfParty(_selfParty),
5053
m_front(std::move(_front)),
5154
m_ppcMsgFactory(std::move(_ppcMsgFactory)),
5255
m_dataResourceLoader(std::move(_dataResourceLoader)),
5356
m_networkTimeout(_holdingMessageMinutes * 60 * 1000),
54-
m_taskExpireTime(m_networkTimeout)
57+
m_taskExpireTime(m_networkTimeout),
58+
m_minNeededMemoryGB(minNeededMemoryGB)
5559
{
5660
PSI_LOG(INFO) << LOG_DESC("create PSIConfig") << LOG_KV("algorithmType", m_algorithmType)
5761
<< LOG_KV("holdingMessageMinutes", _holdingMessageMinutes)
5862
<< LOG_KV("networkTimeout", m_networkTimeout)
59-
<< LOG_KV("taskExpireTime", m_taskExpireTime);
63+
<< LOG_KV("taskExpireTime", m_taskExpireTime)
64+
<< LOG_KV("minNeededMemoryGB", m_minNeededMemoryGB);
6065
}
6166

6267
virtual ~PSIConfig() = default;
@@ -128,6 +133,8 @@ class PSIConfig
128133

129134
std::vector<std::string> agencyList() const { return m_front->agencies(); }
130135

136+
uint32_t minNeededMemoryGB() const { return m_minNeededMemoryGB; }
137+
131138
protected:
132139
ppc::front::PPCMessageFace::Ptr generatePPCMsg(
133140
std::string const& _taskID, PSIMessageInterface::Ptr const& _msg, uint32_t _seq)
@@ -161,5 +168,7 @@ class PSIConfig
161168

162169
// the task-expire time
163170
int m_taskExpireTime = 10000;
171+
172+
uint32_t m_minNeededMemoryGB = 1;
164173
};
165174
} // namespace ppc::psi

cpp/wedpr-computing/ppc-psi/src/bs-ecdh-psi/BsEcdhPSIFactory.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ class BsEcdhPSIFactory
3434
virtual ~BsEcdhPSIFactory() = default;
3535

3636
virtual BsEcdhPSIImpl::Ptr buildBsEcdhPSI(bcos::ThreadPool::Ptr _threadPool,
37-
ppc::io::DataResourceLoader::Ptr _dataResourceLoader, uint32_t _timeoutMinutes)
37+
ppc::io::DataResourceLoader::Ptr _dataResourceLoader, uint32_t _timeoutMinutes,
38+
uint32_t minNeededMemoryGB = 1)
3839
{
39-
auto config = std::make_shared<PSIConfig>(
40-
ppc::protocol::TaskAlgorithmType::BS_ECDH_PSI, std::move(_dataResourceLoader));
40+
auto config = std::make_shared<PSIConfig>(ppc::protocol::TaskAlgorithmType::BS_ECDH_PSI,
41+
std::move(_dataResourceLoader), minNeededMemoryGB);
4142
return std::make_shared<BsEcdhPSIImpl>(
4243
std::move(config), std::move(_threadPool), _timeoutMinutes);
4344
}

cpp/wedpr-computing/ppc-psi/src/bs-ecdh-psi/BsEcdhPSIImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void BsEcdhPSIImpl::asyncRunTask(
148148
auto taskState = std::make_shared<BsEcdhTaskState>(
149149
_request->taskID, TaskStatus::PENDING, m_timeoutMinutes);
150150
// check the memory
151-
checkHostResource();
151+
checkHostResource(m_config->minNeededMemoryGB());
152152
// create ecdh cache
153153
auto cache = std::make_shared<BsEcdhCache>(
154154
_request->taskID, m_threadPool, m_taskGuarder, _request->dataResource,

cpp/wedpr-computing/ppc-psi/src/cm2020-psi/CM2020PSIConfig.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ class CM2020PSIConfig : public PSIConfig
4141
CM2020PSIConfig(std::string const& _selfPartyID, ppc::front::FrontInterface::Ptr _front,
4242
ppc::crypto::CryptoBox::Ptr _cryptoBox, bcos::ThreadPool::Ptr _threadPool,
4343
ppc::io::DataResourceLoader::Ptr _dataResourceLoader, int _holdingMessageMinutes,
44-
uint16_t _parallelism = 3,
44+
uint32_t minNeededMemoryGB = 1, uint16_t _parallelism = 3,
4545
const front::PPCMessageFactory::Ptr& _msgFactory =
4646
std::make_shared<front::PPCMessageFactory>())
4747
: PSIConfig(ppc::protocol::TaskAlgorithmType::CM_PSI_2PC, _selfPartyID, std::move(_front),
48-
_msgFactory, std::move(_dataResourceLoader), _holdingMessageMinutes),
48+
_msgFactory, std::move(_dataResourceLoader), _holdingMessageMinutes, minNeededMemoryGB),
4949
m_cryptoBox(std::move(_cryptoBox)),
5050
m_threadPool(std::move(_threadPool)),
5151
m_parallelism(_parallelism)

cpp/wedpr-computing/ppc-psi/src/cm2020-psi/CM2020PSIFactory.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ class CM2020PSIFactory
3434
virtual CM2020PSIImpl::Ptr buildCM2020PSI(std::string const& _selfParty,
3535
ppc::front::FrontInterface::Ptr _front, ppc::crypto::CryptoBox::Ptr _cryptoBox,
3636
bcos::ThreadPool::Ptr _threadPool, ppc::io::DataResourceLoader::Ptr _dataResourceLoader,
37-
int _holdingMessageMinutes, uint16_t _parallelism)
37+
int _holdingMessageMinutes, uint16_t _parallelism, uint32_t minNeededMemoryGB = 1)
3838
{
3939
auto config = std::make_shared<CM2020PSIConfig>(_selfParty, std::move(_front),
4040
std::move(_cryptoBox), std::move(_threadPool), std::move(_dataResourceLoader),
41-
_holdingMessageMinutes, _parallelism);
41+
_holdingMessageMinutes, minNeededMemoryGB, _parallelism);
4242
return std::make_shared<CM2020PSIImpl>(config);
4343
}
4444
};

cpp/wedpr-computing/ppc-psi/src/cm2020-psi/CM2020PSIImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void CM2020PSIImpl::asyncRunTask()
156156
psi->noticePeerToFinish(task);
157157
});
158158
// check the memory
159-
checkHostResource();
159+
checkHostResource(m_config->minNeededMemoryGB());
160160
addPendingTask(taskState);
161161

162162
try

0 commit comments

Comments
 (0)