empiredan commented on code in PR #2078:
URL:
https://github.com/apache/incubator-pegasus/pull/2078#discussion_r1897061545
##########
src/replica/replica_stub.cpp:
##########
@@ -495,75 +683,18 @@ void replica_stub::initialize(const replication_options
&opts, bool clear /* = f
// Start to load replicas in available data directories.
LOG_INFO("start to load replicas");
- std::map<dir_node *, std::vector<std::string>> dirs_by_dn;
- for (const auto &dn : _fs_manager.get_dir_nodes()) {
- // Skip IO error dir_node.
- if (dsn_unlikely(dn->status == disk_status::IO_ERROR)) {
- continue;
- }
- std::vector<std::string> sub_directories;
- CHECK(dsn::utils::filesystem::get_subdirectories(dn->full_dir,
sub_directories, false),
- "fail to get sub_directories in {}",
- dn->full_dir);
- dirs_by_dn.emplace(dn.get(), sub_directories);
- }
-
- replicas rps;
- utils::ex_lock rps_lock;
- std::deque<task_ptr> load_tasks;
- uint64_t start_time = dsn_now_ms();
- for (const auto &dn_dirs : dirs_by_dn) {
- const auto dn = dn_dirs.first;
- for (const auto &dir : dn_dirs.second) {
- if (dsn::replication::is_data_dir_invalid(dir)) {
- LOG_WARNING("ignore dir {}", dir);
- continue;
- }
- load_tasks.push_back(tasking::create_task(
- LPC_REPLICATION_INIT_LOAD,
- &_tracker,
- [this, dn, dir, &rps, &rps_lock] {
- LOG_INFO("process dir {}", dir);
+ replicas reps;
- auto r = load_replica(dn, dir.c_str());
- if (r == nullptr) {
- return;
- }
- LOG_INFO("{}@{}: load replica '{}' success, <durable, "
- "commit> = <{}, {}>, last_prepared_decree = {}",
- r->get_gpid(),
- dsn_primary_host_port(),
- dir,
- r->last_durable_decree(),
- r->last_committed_decree(),
- r->last_prepared_decree());
-
- utils::auto_lock<utils::ex_lock> l(rps_lock);
- CHECK(rps.find(r->get_gpid()) == rps.end(),
- "conflict replica dir: {} <--> {}",
- r->dir(),
- rps[r->get_gpid()]->dir());
-
- rps[r->get_gpid()] = r;
- },
- load_tasks.size()));
- load_tasks.back()->enqueue();
- }
- }
- for (auto &tsk : load_tasks) {
- tsk->wait();
- }
- uint64_t finish_time = dsn_now_ms();
+ utils::chronograph chrono;
Review Comment:
OK, use `SCOPED_LOG_TIMING` instead.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]