Skip to content

Commit 3ce90e4

Browse files
committed
address comments
1 parent a3f43f4 commit 3ce90e4

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

src/lib/homestore_backend/gc_manager.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,15 @@ void GCManager::pdev_gc_actor::start() {
131131
LOGERROR("pdev gc actor for pdev_id={} is already started, no need to start again!", m_pdev_id);
132132
return;
133133
}
134+
RELEASE_ASSERT(RESERVED_CHUNK_NUM_PER_PDEV > RESERVED_CHUNK_NUM_DEDICATED_FOR_EGC,
135+
"reserved chunk number {} per pdev should be greater than {}", RESERVED_CHUNK_NUM_PER_PDEV,
136+
RESERVED_CHUNK_NUM_DEDICATED_FOR_EGC);
134137
// thread number is the same as reserved chunk, which can make sure every gc thread can take a reserved chunk
135138
// for gc
136-
m_gc_executor = std::make_shared< folly::IOThreadPoolExecutor >(RESERVED_CHUNK_NUM_PER_PDEV);
139+
m_gc_executor = std::make_shared< folly::IOThreadPoolExecutor >(RESERVED_CHUNK_NUM_PER_PDEV -
140+
RESERVED_CHUNK_NUM_DEDICATED_FOR_EGC);
141+
m_egc_executor = std::make_shared< folly::IOThreadPoolExecutor >(RESERVED_CHUNK_NUM_DEDICATED_FOR_EGC);
142+
137143
LOGINFO("pdev gc actor for pdev_id={} has started", m_pdev_id);
138144
}
139145

@@ -144,8 +150,10 @@ void GCManager::pdev_gc_actor::stop() {
144150
return;
145151
}
146152
m_gc_executor->stop();
147-
m_gc_executor->join();
148153
m_gc_executor.reset();
154+
155+
m_egc_executor->stop();
156+
m_egc_executor.reset();
149157
LOGINFO("pdev gc actor for pdev_id={} has stopped", m_pdev_id);
150158
}
151159

@@ -157,13 +165,18 @@ folly::SemiFuture< bool > GCManager::pdev_gc_actor::add_gc_task(uint8_t priority
157165
if (m_chunk_selector->try_mark_chunk_to_gc_state(move_from_chunk,
158166
priority == static_cast< uint8_t >(task_priority::emergent))) {
159167
auto [promise, future] = folly::makePromiseContract< bool >();
160-
m_gc_executor->addWithPriority(
161-
[this, priority, move_from_chunk, promise = std::move(promise)]() mutable {
168+
169+
if (sisl_unlikely(priority == static_cast< uint8_t >(task_priority::emergent))) {
170+
m_egc_executor->add([this, priority, move_from_chunk, promise = std::move(promise)]() mutable {
162171
LOGERROR("start gc task : move_from_chunk_id={}, priority={}", move_from_chunk, priority);
163172
process_gc_task(move_from_chunk, priority, std::move(promise));
164-
},
165-
priority);
166-
173+
});
174+
} else {
175+
m_gc_executor->add([this, priority, move_from_chunk, promise = std::move(promise)]() mutable {
176+
LOGERROR("start gc task : move_from_chunk_id={}, priority={}", move_from_chunk, priority);
177+
process_gc_task(move_from_chunk, priority, std::move(promise));
178+
});
179+
}
167180
return std::move(future);
168181
}
169182

src/lib/homestore_backend/gc_manager.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ class HSHomeObject;
2323
// TODO:: make those #define below configurable
2424

2525
// Default number of chunks reserved for GC per pdev
26-
#define RESERVED_CHUNK_NUM_PER_PDEV 4
26+
#define RESERVED_CHUNK_NUM_PER_PDEV 6
27+
// reserved chunk number dedicated for emergent GC
28+
#define RESERVED_CHUNK_NUM_DEDICATED_FOR_EGC 2
2729
// GC interval in seconds, this is used to schedule the GC timer
2830
#define GC_SCAN_INTERVAL_SEC 10llu
2931
// Garbage rate threshold, bigger than which, a gc task will be scheduled for a chunk
@@ -148,6 +150,7 @@ class GCManager {
148150
HSHomeObject* m_hs_home_object{nullptr};
149151
RateLimiter m_rate_limiter{MAX_READ_WRITE_BLOCK_COUNT_PER_SECOND};
150152
std::shared_ptr< folly::IOThreadPoolExecutor > m_gc_executor;
153+
std::shared_ptr< folly::IOThreadPoolExecutor > m_egc_executor;
151154
std::atomic_bool m_is_stopped{true};
152155
};
153156

0 commit comments

Comments
 (0)