From c7e79030dddbff465e4237cff9e5b5afc0957e39 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Sat, 29 Jun 2019 18:56:31 +0200 Subject: [PATCH] sculpt: limit rate of depot queries The triggering of a new depot query can happen more than once per activation of the sculpt manager if multiple conditions call for updated information about the depot. When this happens, the depot-query component produces intermediate results, which are not consumed by the sculpt manager. By deferring depot queries for a few milliseconds, we avoid such intermediate queries, relieving the workload of the depot-query component at system boot time. Issue #3436 --- repos/gems/src/app/sculpt_manager/main.cc | 29 ++++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/repos/gems/src/app/sculpt_manager/main.cc b/repos/gems/src/app/sculpt_manager/main.cc index 5494d316f..65dae97bf 100644 --- a/repos/gems/src/app/sculpt_manager/main.cc +++ b/repos/gems/src/app/sculpt_manager/main.cc @@ -18,6 +18,7 @@ #include #include #include +#include /* included from depot_deploy tool */ #include @@ -213,14 +214,15 @@ struct Sculpt::Main : Input_event_handler, return _query_version; } - /** - * Depot_query interface - */ - void trigger_depot_query() override - { - _query_version.value++; + Timer::Connection _timer { _env }; + Timer::One_shot_timeout
_deferred_depot_query_handler { + _timer, *this, &Main::_handle_deferred_depot_query }; + + void _handle_deferred_depot_query(Duration) + { if (_deploy._arch.valid()) { + _query_version.value++; _depot_query_reporter.generate([&] (Xml_generator &xml) { xml.attribute("arch", _deploy._arch); xml.attribute("version", _query_version.value); @@ -233,6 +235,21 @@ struct Sculpt::Main : Input_event_handler, } } + /** + * Depot_query interface + */ + void trigger_depot_query() override + { + /* + * Defer the submission of the query for a few milliseconds because + * 'trigger_depot_query' may be consecutively called several times + * while evaluating different conditions. Without deferring, the depot + * query component would produce intermediate results that take time + * but are ultimately discarded. + */ + _deferred_depot_query_handler.schedule(Microseconds{5000}); + } + /********************* ** Blueprint query **