Andrew Wong has posted comments on this change. ( 
http://gerrit.cloudera.org:8080/18447 )

Change subject: [threadpool] KUDU-3364 Add TimerThread for thread pool
......................................................................


Patch Set 13:

(13 comments)

http://gerrit.cloudera.org:8080/#/c/18447/13//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/18447/13//COMMIT_MSG@12
PS13, Line 12: trigge
nit: trigger


http://gerrit.cloudera.org:8080/#/c/18447/13//COMMIT_MSG@14
PS13, Line 14: refact
nit: refactor


http://gerrit.cloudera.org:8080/#/c/18447/13/src/kudu/util/threadpool.h
File src/kudu/util/threadpool.h:

http://gerrit.cloudera.org:8080/#/c/18447/13/src/kudu/util/threadpool.h@126
PS13, Line 126: enable_timer
nit: how about "enable_scheduling" or somesuch


http://gerrit.cloudera.org:8080/#/c/18447/13/src/kudu/util/threadpool.h@127
PS13, Line 127: precise_ms
nit: precise_ms isn't particularly descriptive. How about 
"set_scheduler_period_ms" or something

Same for L143, L153, and L180


http://gerrit.cloudera.org:8080/#/c/18447/13/src/kudu/util/threadpool.h@150
PS13, Line 150: periodic
nit: maybe I'm missing something -- I don't see any periodic scheduling 
happening in this patch.


http://gerrit.cloudera.org:8080/#/c/18447/13/src/kudu/util/threadpool.h@151
PS13, Line 151: TimerThread
nit: "timer" makes it seem like this should be measuring the time of tasks. How 
about instead calling this SchedulerThread or somesuch?


http://gerrit.cloudera.org:8080/#/c/18447/13/src/kudu/util/threadpool.h@156
PS13, Line 156:
              :   Status Start();
              :
              :   Status Shutdown();
nit: please do your best to describe the behaviors of these methods in comments


http://gerrit.cloudera.org:8080/#/c/18447/13/src/kudu/util/threadpool.h@168
PS13, Line 168: timepoint
nit: I think "start_time" would be more descriptive


http://gerrit.cloudera.org:8080/#/c/18447/13/src/kudu/util/threadpool.h@178
PS13, Line 178:   std::string thread_pool_name_;
              :   // timer's period checking time.
              :   uint32_t precise_ms_;
These can be const


http://gerrit.cloudera.org:8080/#/c/18447/13/src/kudu/util/threadpool.h@238
PS13, Line 238:     NORMAL,
              :     TEST
nit: these names are not very descriptive. How about something like

enum class ScheduledTaskWaitType {
  WAIT,
  NO_WAIT,
};

Though frankly, I'm not sure it's worth adding this enum in general just for 
the sake of saving a second in one unit test.


http://gerrit.cloudera.org:8080/#/c/18447/13/src/kudu/util/threadpool.cc
File src/kudu/util/threadpool.cc:

http://gerrit.cloudera.org:8080/#/c/18447/13/src/kudu/util/threadpool.cc@142
PS13, Line 142:     MutexLock auto_lock(mutex_);
              :     while (true) {
              :       const auto it = tasks_.begin();
              :       if (it != tasks_.end() && it->first <= now) {
              :         ThreadPoolToken* token = it->second.thread_pool_token_;
              :         CHECK_OK(token->Submit(it->second.f));
              :         tasks_.erase(it);
              :         task_size_--;
              :       } else {
              :         break;
              :       }
              :     }
              :   }
nit: I think it'd be a bit more understandable as

MutexLock l(mutex_);
while (!tasks_.empty()) {
  auto it = tasks_.begin();
  if (it->first > now) {
    break;
  }
  ThreadPoolToken* token = it->second.thread_pool_token_;
  CHECK_OK(token->Submit(it->second.f));
  tasks_.erase(it);
  task_size_--;
}


http://gerrit.cloudera.org:8080/#/c/18447/13/src/kudu/util/threadpool.cc@246
PS13, Line 246: if (mode() != ThreadPool::ExecutionMode::SERIAL) {
              :     return Status::NotSupported(Substitute("unsupported mode: 
CONCURRENT"));
              :   }
nit: this isn't behavior we ever expect to reach in production -- it is a bug 
to write code that calls Schedule() when not set to SERIAL. So, let's use a 
CHECK or DCHECK instead.


http://gerrit.cloudera.org:8080/#/c/18447/13/src/kudu/util/threadpool.cc@641
PS13, Line 641: timer_->task_size_ > 0
nit: if this is the only usage of task_size_, maybe get rid of it and instead 
just use !tasks_.empty()



--
To view, visit http://gerrit.cloudera.org:8080/18447
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If51fce48ae6a45a0bf3314f8a102ee373c5c442e
Gerrit-Change-Number: 18447
Gerrit-PatchSet: 13
Gerrit-Owner: Yuqi Du <shenxingwuy...@gmail.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Khazar Mammadli <mammadli.kha...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Reviewer: Yuqi Du <shenxingwuy...@gmail.com>
Gerrit-Comment-Date: Sat, 07 May 2022 06:50:58 +0000
Gerrit-HasComments: Yes

Reply via email to