Commit 77d54240 authored by TousakaRin's avatar TousakaRin

delete Describe() from ConcurrencyLimiter, Optimize the cacheline alignment of…

delete Describe() from ConcurrencyLimiter, Optimize the cacheline alignment of the Gradient ConcurrencyLimiter, fix code style
parent 97ab9440
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
namespace brpc { namespace brpc {
class ConcurrencyLimiter : public NonConstDescribable, public Destroyable { class ConcurrencyLimiter : public Destroyable {
public: public:
ConcurrencyLimiter() {} ConcurrencyLimiter() {}
......
...@@ -474,15 +474,15 @@ static void GlobalInitializeOrDieImpl() { ...@@ -474,15 +474,15 @@ static void GlobalInitializeOrDieImpl() {
exit(1); exit(1);
} }
// Use Macro is more straight forward than weak link technology(becasue of static link issue) + // Register Thrift framed protocol if linked // Use Macro is more straight forward than weak link technology(becasue of static link issue)
#ifdef ENABLE_THRIFT_FRAMED_PROTOCOL #ifdef ENABLE_THRIFT_FRAMED_PROTOCOL
Protocol thrift_binary_protocol = { Protocol thrift_binary_protocol = {
policy::ParseThriftMessage, policy::ParseThriftMessage,
policy::SerializeThriftRequest, policy::PackThriftRequest, policy::SerializeThriftRequest, policy::PackThriftRequest,
policy::ProcessThriftRequest, policy::ProcessThriftResponse, policy::ProcessThriftRequest, policy::ProcessThriftResponse,
policy::VerifyThriftRequest, NULL, NULL, policy::VerifyThriftRequest, NULL, NULL,
CONNECTION_TYPE_POOLED_AND_SHORT, "thrift" }; CONNECTION_TYPE_POOLED_AND_SHORT, "thrift" };
if (RegisterProtocol(PROTOCOL_THRIFT, thrift_binary_protocol) != 0) { if (RegisterProtocol(PROTOCOL_THRIFT, thrift_binary_protocol) != 0) {
exit(1); exit(1);
} }
#endif #endif
......
...@@ -52,17 +52,5 @@ void ConstantConcurrencyLimiter::Destroy() { ...@@ -52,17 +52,5 @@ void ConstantConcurrencyLimiter::Destroy() {
delete this; delete this;
} }
void ConstantConcurrencyLimiter::Describe(
std::ostream& os, const DescribeOptions& options) {
if (!options.verbose) {
os << "constant_cl";
return;
}
os << "Constant{";
os << "current_max_concurrency:"
<< _max_concurrency;
os << '}';
}
} // namespace policy } // namespace policy
} // namespace brpc } // namespace brpc
...@@ -38,7 +38,6 @@ public: ...@@ -38,7 +38,6 @@ public:
int Expose(const butil::StringPiece& prefix) override; int Expose(const butil::StringPiece& prefix) override;
ConstantConcurrencyLimiter* New() const override; ConstantConcurrencyLimiter* New() const override;
void Destroy() override; void Destroy() override;
void Describe(std::ostream&, const DescribeOptions& options) override;
private: private:
int32_t _max_concurrency; int32_t _max_concurrency;
......
...@@ -69,23 +69,11 @@ GradientConcurrencyLimiter::GradientConcurrencyLimiter() ...@@ -69,23 +69,11 @@ GradientConcurrencyLimiter::GradientConcurrencyLimiter()
, _unused_max_concurrency(0) , _unused_max_concurrency(0)
, _max_concurrency_bvar(cast_max_concurrency, &_max_concurrency) , _max_concurrency_bvar(cast_max_concurrency, &_max_concurrency)
, _last_sampling_time_us(0) , _last_sampling_time_us(0)
, _total_succ_req(0)
, _max_concurrency(FLAGS_gradient_cl_initial_max_concurrency) , _max_concurrency(FLAGS_gradient_cl_initial_max_concurrency)
, _total_succ_req(0)
, _current_concurrency(0) { , _current_concurrency(0) {
} }
void GradientConcurrencyLimiter::Describe(
std::ostream& os, const DescribeOptions& options) {
if (!options.verbose) {
os << "gradient_cl";
return;
}
os << "Gradient{";
os << "current_max_concurrency:"
<< _max_concurrency.load(butil::memory_order_relaxed);
os << '}';
}
int GradientConcurrencyLimiter::MaxConcurrency() const { int GradientConcurrencyLimiter::MaxConcurrency() const {
return _max_concurrency.load(butil::memory_order_relaxed); return _max_concurrency.load(butil::memory_order_relaxed);
} }
......
...@@ -36,7 +36,6 @@ public: ...@@ -36,7 +36,6 @@ public:
int Expose(const butil::StringPiece& prefix) override; int Expose(const butil::StringPiece& prefix) override;
GradientConcurrencyLimiter* New() const override; GradientConcurrencyLimiter* New() const override;
void Destroy() override; void Destroy() override;
void Describe(std::ostream&, const DescribeOptions& options) override;
private: private:
struct SampleWindow { struct SampleWindow {
...@@ -76,9 +75,9 @@ private: ...@@ -76,9 +75,9 @@ private:
butil::Mutex _sw_mutex; butil::Mutex _sw_mutex;
bvar::PassiveStatus<int32_t> _max_concurrency_bvar; bvar::PassiveStatus<int32_t> _max_concurrency_bvar;
butil::atomic<int64_t> BAIDU_CACHELINE_ALIGNMENT _last_sampling_time_us; butil::atomic<int64_t> BAIDU_CACHELINE_ALIGNMENT _last_sampling_time_us;
butil::atomic<int32_t> _max_concurrency;
butil::atomic<int32_t> BAIDU_CACHELINE_ALIGNMENT _total_succ_req; butil::atomic<int32_t> BAIDU_CACHELINE_ALIGNMENT _total_succ_req;
butil::atomic<int32_t> BAIDU_CACHELINE_ALIGNMENT _max_concurrency; butil::atomic<int32_t> _current_concurrency;
butil::atomic<int32_t> BAIDU_CACHELINE_ALIGNMENT _current_concurrency;
}; };
} // namespace policy } // namespace policy
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment