|
|
Chromium Code Reviews
DescriptionRefactor the resource_prefetch_predictor.
This removes ResourceRow object and uses proto message ResourceData instead of
it. It allows to get rid of the boilerplate conversion from the DB to an
internal structure.
Plus adds lost ResourceData::RESOURCE_TYPE_FONT_RESOURCE case in
chrome/browser/ui/webui/predictors/predictors_handler.cc
BUG=631966
Committed: https://crrev.com/68ebcad9d6ab7491ee1f2f5c5a28e7eac1c4987f
Cr-Commit-Position: refs/heads/master@{#420935}
Patch Set 1 #
Total comments: 1
Patch Set 2 : Minor changes #Patch Set 3 : BUILD.gn after rebase #
Total comments: 5
Patch Set 4 : Simplify sorting #
Total comments: 2
Patch Set 5 : Nit fix #Patch Set 6 : rebase #Dependent Patchsets: Messages
Total messages: 67 (46 generated)
alexilin@chromium.org changed reviewers: + lizeb@chromium.org
Hi Benoit, I've finished with refactoring of ResourcePrefetchPredictor. I'm not sure about the way I solved problem with score storage. At first, I thought about to add score field in proto declaration and always clean it before saving in database. As it turned out, we pass ResourceData objects by constant reference (because ResourcePrefetchPredictorTables::UpdateData takes constant reference and this is right). So I would have to copy of ResourceData every time, when I'm trying to keep it in database only to clean score field. Of course, it is possible to use const_cast but it doesn't look right. So afterwards I noticed, we use score only when we need to sort resources. So I don't even store scores together with ResourceData and calculate them only in sort function. But I'm not sure that nobody else will want to use it in the future.
On 2016/09/20 11:11:53, alexilin wrote: > Hi Benoit, > > I've finished with refactoring of ResourcePrefetchPredictor. > > I'm not sure about the way I solved problem with score storage. > > At first, I thought about to add score field in proto declaration and always > clean it before saving in database. As it turned out, we pass ResourceData > objects by constant reference (because > ResourcePrefetchPredictorTables::UpdateData takes constant reference and this is > right). So I would have to copy of ResourceData every time, when I'm trying to > keep it in database only to clean score field. Of course, it is possible to use > const_cast but it doesn't look right. > > So afterwards I noticed, we use score only when we need to sort resources. So I > don't even store scores together with ResourceData and calculate them only in > sort function. But I'm not sure that nobody else will want to use it in the > future. Thanks! Just one question before I start reviewing this in more details: is this mostly a rebase of https://codereview.chromium.org/2268283005/ ? If not, can you quickly sum up the differences?
On 2016/09/20 11:34:16, Benoit L wrote: > On 2016/09/20 11:11:53, alexilin wrote: > > Hi Benoit, > > > > I've finished with refactoring of ResourcePrefetchPredictor. > > > > I'm not sure about the way I solved problem with score storage. > > > > At first, I thought about to add score field in proto declaration and always > > clean it before saving in database. As it turned out, we pass ResourceData > > objects by constant reference (because > > ResourcePrefetchPredictorTables::UpdateData takes constant reference and this > is > > right). So I would have to copy of ResourceData every time, when I'm trying to > > keep it in database only to clean score field. Of course, it is possible to > use > > const_cast but it doesn't look right. > > > > So afterwards I noticed, we use score only when we need to sort resources. So > I > > don't even store scores together with ResourceData and calculate them only in > > sort function. But I'm not sure that nobody else will want to use it in the > > future. > > Thanks! > > Just one question before I start reviewing this in more details: is this mostly > a rebase of https://codereview.chromium.org/2268283005/ ? > If not, can you quickly sum up the differences? Almost yes. The main difference is the way of handling score of ResourceData. There are also some minor differences (e.g. namespacing) but generally this is the only change.
The CQ bit was checked by lizeb@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
lgtm, thanks. Since I'm not an owner of this directory, and that this is mostly a self high-five, please add pasko@ in the reviewer list. https://codereview.chromium.org/2357593002/diff/1/chrome/browser/predictors/r... File chrome/browser/predictors/resource_prefetch_predictor_tables.h (right): https://codereview.chromium.org/2357593002/diff/1/chrome/browser/predictors/r... chrome/browser/predictors/resource_prefetch_predictor_tables.h:58: std::string primary_key; // is_host() ? main frame url : host. Looking at this, I believe that this comment is incorrect. (the clauses should be flipped). Can you change this as well?
alexilin@chromium.org changed reviewers: + pasko@chromium.org
alexilin@chromium.org changed required reviewers: + pasko@chromium.org
Hi Egor, I resurrected refactoring was proposed in https://codereview.chromium.org/2268283005. We need it to manage databases in a uniform manner later, when we'll add redirects table. Look at this CL (https://codereview.chromium.org/2321343002/) to familiarize with the problem. ResourcePrefetchPredictorTables class too swelled.
The CQ bit was checked by lizeb@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
overall looks good, thank you, asking only for a few small changes https://codereview.chromium.org/2357593002/diff/40001/chrome/browser/predicto... File chrome/browser/predictors/resource_prefetch_predictor_tables.cc (right): https://codereview.chromium.org/2357593002/diff/40001/chrome/browser/predicto... chrome/browser/predictors/resource_prefetch_predictor_tables.cc:106: // Sort indices instead of ResourceData objects and then apply resulting Why not just this: std::sort(resources->begin(), resources->end(), [](const ResourceData& x, const ResourceData& y) { return ComputeScore(x) > ComputeScore(y); }); ? Performance wins of this are not obvious: 1. vector<ResourceData> is going to be <100 entries 2. probably mostly sorted already, so there is not many swaps 3. creating new vectors will create heap allocations I think your implementation will be faster, and heap fragmentation is hard to evaluate, so I am OK with it. I would still slightly prefer shorter code until we prove that extra copying is actually a performance bottleneck. https://codereview.chromium.org/2357593002/diff/40001/chrome/browser/predicto... File chrome/browser/predictors/resource_prefetch_predictor_tables.h (right): https://codereview.chromium.org/2357593002/diff/40001/chrome/browser/predicto... chrome/browser/predictors/resource_prefetch_predictor_tables.h:116: // Computes score of |data| Except for end-of-line case, all comments should be written as complete sentences, including a period at the end. See: https://google.github.io/styleguide/cppguide.html#Punctuation,_Spelling_and_G... Please do it in all comments you added/modified in this change. https://codereview.chromium.org/2357593002/diff/40001/chrome/browser/ui/webui... File chrome/browser/ui/webui/predictors/predictors_handler.cc (right): https://codereview.chromium.org/2357593002/diff/40001/chrome/browser/ui/webui... chrome/browser/ui/webui/predictors/predictors_handler.cc:38: case ResourceData::RESOURCE_TYPE_FONT_RESOURCE: this seems like a bigfix (yay!) But then the description of the change is not fully correct by saying that it is refactoring. Feel free to mention it in the description or sending this as a separate change.
Description was changed from ========== Refactor the resource_prefetch_predictor. This removes ResourceRow object and uses proto message ResourceData instead of it. It allows to get rid of the boilerplate conversion from the DB to an internal structure. BUG=631966 ========== to ========== Refactor the resource_prefetch_predictor. This removes ResourceRow object and uses proto message ResourceData instead of it. It allows to get rid of the boilerplate conversion from the DB to an internal structure. Plus adds lost ResourceData::RESOURCE_TYPE_FONT_RESOURCE case in chrome/browser/ui/webui/predictors/predictors_handler.cc BUG=631966 ==========
Description was changed from ========== Refactor the resource_prefetch_predictor. This removes ResourceRow object and uses proto message ResourceData instead of it. It allows to get rid of the boilerplate conversion from the DB to an internal structure. Plus adds lost ResourceData::RESOURCE_TYPE_FONT_RESOURCE case in chrome/browser/ui/webui/predictors/predictors_handler.cc BUG=631966 ========== to ========== Refactor the resource_prefetch_predictor. This removes ResourceRow object and uses proto message ResourceData instead of it. It allows to get rid of the boilerplate conversion from the DB to an internal structure. Plus adds lost ResourceData::RESOURCE_TYPE_FONT_RESOURCE case in chrome/browser/ui/webui/predictors/predictors_handler.cc BUG=631966 ==========
Hello Egor, I worked on yours comments. Waiting for your approval. https://codereview.chromium.org/2357593002/diff/40001/chrome/browser/predicto... File chrome/browser/predictors/resource_prefetch_predictor_tables.cc (right): https://codereview.chromium.org/2357593002/diff/40001/chrome/browser/predicto... chrome/browser/predictors/resource_prefetch_predictor_tables.cc:106: // Sort indices instead of ResourceData objects and then apply resulting On 2016/09/21 17:38:36, pasko wrote: > Why not just this: > > std::sort(resources->begin(), resources->end(), [](const ResourceData& x, const > ResourceData& y) { return ComputeScore(x) > ComputeScore(y); }); > > ? > > Performance wins of this are not obvious: > 1. vector<ResourceData> is going to be <100 entries > 2. probably mostly sorted already, so there is not many swaps > 3. creating new vectors will create heap allocations > > I think your implementation will be faster, and heap fragmentation is hard to > evaluate, so I am OK with it. I would still slightly prefer shorter code until > we prove that extra copying is actually a performance bottleneck. Yeah, I agree. I simply overlooked this more convenient way. https://codereview.chromium.org/2357593002/diff/40001/chrome/browser/predicto... File chrome/browser/predictors/resource_prefetch_predictor_tables.h (right): https://codereview.chromium.org/2357593002/diff/40001/chrome/browser/predicto... chrome/browser/predictors/resource_prefetch_predictor_tables.h:116: // Computes score of |data| On 2016/09/21 17:38:36, pasko wrote: > Except for end-of-line case, all comments should be written as complete > sentences, including a period at the end. > > See: > https://google.github.io/styleguide/cppguide.html#Punctuation,_Spelling_and_G... > > Please do it in all comments you added/modified in this change. Feel free to leave more grammar-nazi comments!
The CQ bit was checked by alexilin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
lgtm, thank you, Alexandr
The CQ bit was unchecked by alexilin@chromium.org
The CQ bit was checked by alexilin@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from lizeb@chromium.org Link to the patchset: https://codereview.chromium.org/2357593002/#ps60001 (title: "Simplify sorting")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: chromium_presubmit on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presub...)
alexilin@chromium.org changed reviewers: + pkasting@chromium.org
alexilin@chromium.org changed required reviewers: + pkasting@chromium.org - pasko@chromium.org
pkasting@chromium.org: Please review changes in chrome/browser/ui/webui/predictors/predictors_handler.cc
LGTM https://codereview.chromium.org/2357593002/diff/60001/chrome/browser/ui/webui... File chrome/browser/ui/webui/predictors/predictors_handler.cc (right): https://codereview.chromium.org/2357593002/diff/60001/chrome/browser/ui/webui... chrome/browser/ui/webui/predictors/predictors_handler.cc:28: using ResourceType = ResourceData::ResourceType; Nit: Avoid these. They don't significantly improve readability and they cost LOC. https://codereview.chromium.org/2357593002/diff/60001/chrome/browser/ui/webui... chrome/browser/ui/webui/predictors/predictors_handler.cc:118: for (const auto& p : data_map) { Good small cleanups! Range-based for FTW.
The CQ bit was checked by alexilin@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from pasko@chromium.org, lizeb@chromium.org, pkasting@chromium.org Link to the patchset: https://codereview.chromium.org/2357593002/#ps80001 (title: "Nit fix")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: android_arm64_dbg_recipe on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_arm6...) linux_android_rel_ng on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_androi...) cast_shell_linux on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/cast_shell_linu...) chromeos_daisy_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_daisy_...) linux_chromium_chromeos_compile_dbg_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...) linux_chromium_chromeos_ozone_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...) linux_chromium_clobber_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...) linux_chromium_compile_dbg_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...) mac_chromium_compile_dbg_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_comp...) mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
The CQ bit was checked by alexilin@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from pasko@chromium.org, lizeb@chromium.org, pkasting@chromium.org Link to the patchset: https://codereview.chromium.org/2357593002/#ps100001 (title: ".")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: win_chromium_x64_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_x64_...)
The CQ bit was checked by alexilin@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: win_chromium_x64_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_x64_...)
The CQ bit was checked by alexilin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_...)
The CQ bit was checked by alexilin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_android_rel_ng on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_androi...)
The CQ bit was checked by alexilin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_x64_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_x64_...)
The CQ bit was checked by alexilin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by alexilin@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Description was changed from ========== Refactor the resource_prefetch_predictor. This removes ResourceRow object and uses proto message ResourceData instead of it. It allows to get rid of the boilerplate conversion from the DB to an internal structure. Plus adds lost ResourceData::RESOURCE_TYPE_FONT_RESOURCE case in chrome/browser/ui/webui/predictors/predictors_handler.cc BUG=631966 ========== to ========== Refactor the resource_prefetch_predictor. This removes ResourceRow object and uses proto message ResourceData instead of it. It allows to get rid of the boilerplate conversion from the DB to an internal structure. Plus adds lost ResourceData::RESOURCE_TYPE_FONT_RESOURCE case in chrome/browser/ui/webui/predictors/predictors_handler.cc BUG=631966 ==========
Message was sent while issue was closed.
Committed patchset #6 (id:100001)
Message was sent while issue was closed.
Description was changed from ========== Refactor the resource_prefetch_predictor. This removes ResourceRow object and uses proto message ResourceData instead of it. It allows to get rid of the boilerplate conversion from the DB to an internal structure. Plus adds lost ResourceData::RESOURCE_TYPE_FONT_RESOURCE case in chrome/browser/ui/webui/predictors/predictors_handler.cc BUG=631966 ========== to ========== Refactor the resource_prefetch_predictor. This removes ResourceRow object and uses proto message ResourceData instead of it. It allows to get rid of the boilerplate conversion from the DB to an internal structure. Plus adds lost ResourceData::RESOURCE_TYPE_FONT_RESOURCE case in chrome/browser/ui/webui/predictors/predictors_handler.cc BUG=631966 Committed: https://crrev.com/68ebcad9d6ab7491ee1f2f5c5a28e7eac1c4987f Cr-Commit-Position: refs/heads/master@{#420935} ==========
Message was sent while issue was closed.
Patchset 6 (id:??) landed as https://crrev.com/68ebcad9d6ab7491ee1f2f5c5a28e7eac1c4987f Cr-Commit-Position: refs/heads/master@{#420935} |
