This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch resource_ctx
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/resource_ctx by this push:
     new 94313688ef4 f
94313688ef4 is described below

commit 94313688ef44a6e6235219aac7e51d7ca1d2ae44
Author: yiguolei <guo...@selectdb.com>
AuthorDate: Fri Dec 6 23:46:29 2024 +0800

    f
---
 be/src/runtime/workload_management/cpu_context.h      | 8 +++++++-
 be/src/runtime/workload_management/io_context.h       | 8 +++++++-
 be/src/runtime/workload_management/memory_context.h   | 8 +++++---
 be/src/runtime/workload_management/resource_context.h | 4 ++++
 4 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/be/src/runtime/workload_management/cpu_context.h 
b/be/src/runtime/workload_management/cpu_context.h
index 05b2c94a64e..6bf9c95bf98 100644
--- a/be/src/runtime/workload_management/cpu_context.h
+++ b/be/src/runtime/workload_management/cpu_context.h
@@ -45,7 +45,13 @@ public:
     CPUContext() {}
     virtual ~CPUContext() = default;
     // Bind current thread to cgroup, only some load thread should do this.
-    void bind_workload_group() {}
+    void bind_workload_group() {
+        // Call workload group method to bind current thread to cgroup
+    }
+    CPUStats* cpu_stats() { return &stats_; }
+
+private:
+    CPUStats stats_;
 };
 
 } // namespace doris
diff --git a/be/src/runtime/workload_management/io_context.h 
b/be/src/runtime/workload_management/io_context.h
index 886e436a3bf..b4dd5a0b6c1 100644
--- a/be/src/runtime/workload_management/io_context.h
+++ b/be/src/runtime/workload_management/io_context.h
@@ -75,7 +75,13 @@ public:
 public:
     IOContext() {}
     virtual ~IOContext() = default;
-    IOThrottle* io_throttle() {}
+    IOThrottle* io_throttle() {
+        // get io throttle from workload group
+    }
+    IOStats* stats() { return &stats_; }
+
+private:
+    IOStats stats_;
 };
 
 } // namespace doris
diff --git a/be/src/runtime/workload_management/memory_context.h 
b/be/src/runtime/workload_management/memory_context.h
index 7e62c1bc687..cf7a80010d4 100644
--- a/be/src/runtime/workload_management/memory_context.h
+++ b/be/src/runtime/workload_management/memory_context.h
@@ -65,7 +65,9 @@ public:
 
     virtual ~MemoryContext() = default;
 
-    MemtrackerLimiter* get_memtracker_limiter() {}
+    MemtrackerLimiter* memtracker_limiter() { return 
memtracker_limiter_.get(); }
+
+    MemoryStats* stats() { return &stats_; }
 
     // Following method is related with spill disk.
     // Compute the number of bytes could be released.
@@ -81,8 +83,8 @@ public:
     virtual Status leave_arbitration(Status reason) { return Status::OK(); }
 
 private:
-    // std::weak_ptr<WorkloadGroup> workload_group_;
-    std::weak_ptr<MemtrackerLimiter> memtracker_limiter_;
+    MemoryStats stats_;
+    std::shared_ptr<MemtrackerLimiter> memtracker_limiter_;
 };
 
 } // namespace doris
diff --git a/be/src/runtime/workload_management/resource_context.h 
b/be/src/runtime/workload_management/resource_context.h
index b5e5400165b..5f910c590d0 100644
--- a/be/src/runtime/workload_management/resource_context.h
+++ b/be/src/runtime/workload_management/resource_context.h
@@ -52,6 +52,7 @@ public:
     }
     virtual ~ResourceContext() = default;
 
+    // The caller should not hold the object, since it is a raw pointer.
     CPUContext* cpu_context() { return cpu_context_.get(); }
     MemoryContext* memory_context() { return memory_context_.get(); }
     IOContext* io_context() { return io_context_.get(); }
@@ -69,6 +70,8 @@ public:
         workload_group_ = wg;
     }
 
+    std::shared_ptr<WorkloadGroup> workload_group() { return 
workload_group_.lock(); }
+
 private:
     // The controller's init value is nullptr, it means the resource context 
will ignore this controller.
     std::shared_ptr<CPUContext> cpu_context_ = nullptr;
@@ -76,6 +79,7 @@ private:
     std::shared_ptr<IOContext> io_context_ = nullptr;
     std::shared_ptr<ResourceReclaimer> reclaimer_ = nullptr;
     // Workload group will own resource context, so that resource context only 
have weak ptr for workload group.
+    // TODO: should use atomic weak ptr to avoid the concurrent modification 
of the pointer.
     std::weak_ptr<WorkloadGroup> workload_group_ = nullptr;
 };
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to