Use cached study direction and trial for _CachedStorage's get_best_trial#6270
Use cached study direction and trial for _CachedStorage's get_best_trial#6270y0z merged 1 commit intooptuna:masterfrom
_CachedStorage's get_best_trial#6270Conversation
|
@sawa3030 Could you review this PR? |
|
This pull request has not seen any recent activity. |
| ) | ||
| direction = _directions[0] | ||
| trial_id = self._backend._get_best_trial_id(study_id, direction) | ||
| return self.get_trial(trial_id) |
There was a problem hiding this comment.
I'm sorry for keeping you waiting. I have one question: I’m not entirely sure how the trials in the cached storage are updated. I tested locally and confirmed that this PR works as expected, but I’m still unclear why this line works without explicitly calling self._backend.get_trial(trial_id).
There was a problem hiding this comment.
_CachedStorage's get_trial method returns the cached trial data if available, or accesses the remote database if not. This helps reduce unnecessary database access.
There was a problem hiding this comment.
Thank you very much. I have overlooked that point.
y0z
left a comment
There was a problem hiding this comment.
LGTM. In my environment, the speedup was very small, but the code changes are fine and can be merged.
Motivation
Currently,
_CachedStorage'sget_best_trialjust calls the method of the backend storage (RDBStorage). However, performance can be improved by using cached study directions and trials.Description of the changes
_get_best_trial_idinRDBStorage_CachedStorage'sget_best_trialBenchmark