Overpass API regression suite coverage (Nova Scotia) / overpass_api/dispatch/resource_manager.cc

overpass_api/dispatch/resource_manager.cc

407 of 531 instrumented lines run by the suite (76.6%) at 8edf11b0419c (this file on GitHub).

runnever runcolumns: line, executions, queries (click for the queries that run the line)

1/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al.
2 *
3 * This file is part of Overpass_API.
4 *
5 * Overpass_API is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as
7 * published by the Free Software Foundation, either version 3 of the
8 * License, or (at your option) any later version.
9 *
10 * Overpass_API is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with Overpass_API. If not, see <http://www.gnu.org/licenses/>.
17 */
19#include "resource_manager.h"
20#include "../data/abstract_processing.h"
21#include "../data/utils.h"
22#include "../statements/statement.h"
24#include <sstream>
27uint64 eval_map(const std::map< Uint32_Index, std::vector< Node_Skeleton > >& nodes)
2841573592 q{
2941573592 q uint64 size(0);
3041573592 q for (std::map< Uint32_Index, std::vector< Node_Skeleton > >::const_iterator
3154559962592 q it(nodes.begin()); it != nodes.end(); ++it)
3254518389312 q size += it->second.size()*8 + 64;
3341573592 q return size;
3441573592 q}
37uint64 eval_map(const std::map< Uint31_Index, std::vector< Way_Skeleton > >& ways)
3839653592 q{
3939653592 q uint64 size(0);
4039653592 q for (std::map< Uint31_Index, std::vector< Way_Skeleton > >::const_iterator
412428063592 q it(ways.begin()); it != ways.end(); ++it)
422388410334 q size += it->second.size()*128 + 64;
4339653592 q return size;
4439653592 q}
47uint64 eval_map(const std::map< Uint31_Index, std::vector< Relation_Skeleton > >& relations)
4839568592 q{
4939568592 q uint64 size(0);
5039568592 q for (std::map< Uint31_Index, std::vector< Relation_Skeleton > >::const_iterator
51265647592 q it(relations.begin()); it != relations.end(); ++it)
52226079212 q size += it->second.size()*192 + 64;
5339568592 q return size;
5439568592 q}
57uint64 eval_map(const std::map< Uint32_Index, std::vector< Attic< Node_Skeleton > > >& nodes)
5841001592 q{
5941001592 q uint64 size(0);
6041001592 q for (std::map< Uint32_Index, std::vector< Attic< Node_Skeleton > > >::const_iterator
6138796519592 q it(nodes.begin()); it != nodes.end(); ++it)
6238755518122 q size += it->second.size()*16 + 64;
6341001592 q return size;
6441001592 q}
67uint64 eval_map(const std::map< Uint31_Index, std::vector< Attic< Way_Skeleton > > >& ways)
6839568592 q{
6939568592 q uint64 size(0);
7039568592 q for (std::map< Uint31_Index, std::vector< Attic< Way_Skeleton > > >::const_iterator
71104890592 q it(ways.begin()); it != ways.end(); ++it)
7265322127 q size += it->second.size()*136 + 64;
7339568592 q return size;
7439568592 q}
77uint64 eval_map(const std::map< Uint31_Index, std::vector< Attic< Relation_Skeleton > > >& relations)
7839568592 q{
7939568592 q uint64 size(0);
8039568592 q for (std::map< Uint31_Index, std::vector< Attic< Relation_Skeleton > > >::const_iterator
81136518592 q it(relations.begin()); it != relations.end(); ++it)
829695097 q size += it->second.size()*200 + 64;
8339568592 q return size;
8439568592 q}
87uint64 eval_map(const std::map< Uint31_Index, std::vector< Area_Skeleton > >& areas)
8839568592 q{
8939568592 q uint64 size(0);
9039568592 q for (std::map< Uint31_Index, std::vector< Area_Skeleton > >::const_iterator
9143093592 q it(areas.begin()); it != areas.end(); ++it)
92352585 q size += it->second.size()*128 + 64;
9339568592 q return size;
9439568592 q}
97uint64 eval_set(const Set& set_)
9839568592 q{
9939568592 q return eval_map(set_.nodes) + eval_map(set_.ways) + eval_map(set_.relations)
10039568592 q + eval_map(set_.attic_nodes) + eval_map(set_.attic_ways)
10139568592 q + eval_map(set_.attic_relations) + eval_map(set_.areas);
10239568592 q}
105Set* Runtime_Stack_Frame::get_set(const std::string& set_name)
10619157586 q{
10719157586 q std::map< std::string, Set >::iterator it = sets.find(set_name);
10819157586 q if (it != sets.end())
10915620584 q return &it->second;
1113537215 q std::map< std::string, Diff_Set >::iterator it_diff = diff_sets.find(set_name);
1123537215 q if (it_diff != diff_sets.end())
1130 return 0;
1153537215 q if (parent)
1162838145 q return parent->get_set(set_name);
118699108 q return 0;
122Diff_Set* Runtime_Stack_Frame::get_diff_set(const std::string& set_name)
12496876 q std::map< std::string, Diff_Set >::iterator it = diff_sets.find(set_name);
12596876 q if (it != diff_sets.end())
1265216 q return &it->second;
12891676 q std::map< std::string, Set >::iterator it_set = sets.find(set_name);
12991676 q if (it_set != sets.end())
13087876 q return 0;
1323812 q if (parent)
133168 q return parent->get_diff_set(set_name);
135226 q return 0;
139void Runtime_Stack_Frame::swap_set(const std::string& set_name, Set& set_)
14036705592 q{
14136705592 q diff_sets.erase(set_name);
14236705592 q key_values.erase(set_name);
14336705592 q Set& to_swap = sets[set_name];
14436705592 q set_.swap(to_swap);
14536705592 q size_per_set[set_name] = eval_set(to_swap);
14636705592 q}
149void Runtime_Stack_Frame::swap_diff_set(const std::string& set_name, Diff_Set& set_)
1511616 q sets.erase(set_name);
1521616 q key_values.erase(set_name);
1531616 q Diff_Set& to_swap = diff_sets[set_name];
1541616 q set_.swap(to_swap);
158const std::string* Runtime_Stack_Frame::get_value(const std::string& set_name, const std::string& key)
1590{
1600 const std::map< std::string, std::string >* key_values = get_set_key_values(set_name);
1610 if (key_values)
1620 {
1630 std::map< std::string, std::string >::const_iterator kvit = key_values->find(key);
1640 return kvit == key_values->end() ? 0 : &kvit->second;
1650 }
1660 return 0;
1670}
170const std::map< std::string, std::string >* Runtime_Stack_Frame::get_set_key_values(const std::string& set_name)
172353 q std::map< std::string, std::map< std::string, std::string > >::iterator it = key_values.find(set_name);
173353 q if (it != key_values.end())
1740 return &it->second;
176353 q std::map< std::string, Set >::iterator it_set = sets.find(set_name);
177353 q if (it_set != sets.end())
178292 q return 0;
17963 q std::map< std::string, Diff_Set >::iterator it_diff = diff_sets.find(set_name);
18063 q if (it_diff != diff_sets.end())
1810 return 0;
18363 q if (parent)
18433 q return parent->get_set_key_values(set_name);
18633 q return 0;
190void Runtime_Stack_Frame::set_value(const std::string& set_name, const std::string& key, const std::string& value)
19241117 q key_values[set_name][key] = value;
196void Runtime_Stack_Frame::erase_set(const std::string& set_name)
1970{
1980 sets.erase(set_name);
1990 diff_sets.erase(set_name);
2000 key_values.erase(set_name);
2010 size_per_set[set_name] = 0;
2020}
205void Runtime_Stack_Frame::clear_sets()
2077676 q sets.clear();
2087676 q diff_sets.clear();
2097676 q key_values.clear();
2107676 q size_per_set.clear();
214void Runtime_Stack_Frame::copy_outward(const std::string& inner_set_name, const std::string& top_set_name)
21615457 q Set* from = 0;
21815457 q if (parent)
21915457 q from = parent->get_set(inner_set_name);
22115457 q if (from)
22215256 q {
22315256 q size_per_set[top_set_name] = eval_set(*from);
22415256 q sets[top_set_name] = *from;
22515256 q }
22621 q else
22821 q size_per_set[top_set_name] = 0;
22921 q sets[top_set_name].clear();
23115457 q diff_sets.erase(top_set_name);
23215457 q key_values.erase(top_set_name);
236void Runtime_Stack_Frame::move_outward(const std::string& inner_set_name, const std::string& top_set_name)
237287374 q{
238287374 q Runtime_Stack_Frame* source = parent;
240318774 q while (source && source->parent)
241280114 q {
242280114 q std::map< std::string, Set >::iterator it = source->sets.find(inner_set_name);
243280114 q if (it != source->sets.end())
24424878 q break;
24631411 q std::map< std::string, Diff_Set >::iterator it_diff = source->diff_sets.find(inner_set_name);
24731411 q if (it_diff != source->diff_sets.end())
2480 break;
25031411 q source = source->parent;
25131411 q }
253287374 q if (source)
254287374 q {
255287374 q size_per_set[top_set_name] = source->size_per_set[inner_set_name];
256287374 q sets[top_set_name].clear();
257287374 q if (source == parent)
258255970 q source->swap_set(inner_set_name, sets[top_set_name]);
25931411 q else
26031411 q sets[top_set_name] = source->sets[inner_set_name];
261287374 q }
262287374 q diff_sets.erase(top_set_name);
263287374 q key_values.erase(top_set_name);
264287374 q}
267bool Runtime_Stack_Frame::union_inward(const std::string& top_set_name, const std::string& inner_set_name)
2692686104 q bool new_elements_found = false;
2702686104 q Set* source = get_set(top_set_name);
2722686104 q if (source && parent)
2732685104 q {
2742685104 q Set& target = parent->sets[inner_set_name];
2762685104 q new_elements_found |= indexed_set_union(target.nodes, source->nodes);
2772685104 q new_elements_found |= indexed_set_union(target.attic_nodes, source->attic_nodes);
2792685104 q new_elements_found |= indexed_set_union(target.ways, source->ways);
2802685104 q new_elements_found |= indexed_set_union(target.attic_ways, source->attic_ways);
2822685104 q new_elements_found |= indexed_set_union(target.relations, source->relations);
2832685104 q new_elements_found |= indexed_set_union(target.attic_relations, source->attic_relations);
2852685104 q new_elements_found |= indexed_set_union(target.areas, source->areas);
2862685104 q new_elements_found |= indexed_set_union(target.deriveds, source->deriveds);
2882685104 q parent->size_per_set[inner_set_name] = eval_set(target);
2892685104 q }
2902686104 q parent->diff_sets.erase(inner_set_name);
2912686104 q parent->key_values.erase(top_set_name);
2932686104 q return new_elements_found;
297void Runtime_Stack_Frame::copy_inward(const std::string& top_set_name, const std::string& inner_set_name)
2992622 q if (!parent)
3000 return;
3022622 q std::map< std::string, Set >::iterator it = sets.find(top_set_name);
3032622 q if (it == sets.end())
3040 {
3050 Set* source = parent->get_set(top_set_name);
3060 if (!source)
3070 parent->sets[inner_set_name] = Set();
3080 else if (source != &parent->sets[inner_set_name])
3090 parent->sets[inner_set_name] = *source;
3100 }
3112622 q else
3122622 q parent->sets[inner_set_name] = it->second;
3142622 q parent->diff_sets.erase(inner_set_name);
3152622 q parent->key_values.erase(inner_set_name);
319void Runtime_Stack_Frame::substract_from_inward(const std::string& top_set_name, const std::string& inner_set_name)
3212622 q Set* source = get_set(top_set_name);
3232622 q if (source && parent)
3252622 q Set& target = parent->sets[inner_set_name];
3272622 q indexed_set_difference(target.nodes, source->nodes);
3282622 q indexed_set_difference(target.ways, source->ways);
3292622 q indexed_set_difference(target.relations, source->relations);
3312622 q indexed_set_difference(target.attic_nodes, source->attic_nodes);
3322622 q indexed_set_difference(target.attic_ways, source->attic_ways);
3332622 q indexed_set_difference(target.attic_relations, source->attic_relations);
3352622 q indexed_set_difference(target.areas, source->areas);
3362622 q indexed_set_difference(target.deriveds, source->deriveds);
3382622 q parent->size_per_set[inner_set_name] = eval_set(target);
3402622 q parent->diff_sets.erase(inner_set_name);
3412622 q parent->key_values.erase(inner_set_name);
345void Runtime_Stack_Frame::move_all_inward()
3477757 q if (parent)
34916857 q for (std::map< std::string, Set >::iterator it = sets.begin(); it != sets.end(); ++it)
3519157 q parent->swap_set(it->first, it->second);
3529157 q parent->diff_sets.erase(it->first);
3539157 q parent->key_values.erase(it->first);
359void Runtime_Stack_Frame::move_all_inward_except(const std::string& set_name)
3612956126 q if (parent)
3622956126 q {
3638396126 q for (std::map< std::string, Set >::iterator it = sets.begin(); it != sets.end(); ++it)
3645440122 q {
3655440122 q if (it->first != set_name)
366252159 q {
367252159 q parent->swap_set(it->first, it->second);
368252159 q parent->diff_sets.erase(it->first);
369252159 q parent->key_values.erase(it->first);
370252159 q }
3715440122 q }
3722956126 q }
376uint64 Runtime_Stack_Frame::total_size()
37774359595 q{
37874359595 q uint64 result = 0;
380238928595 q for (std::map< std::string, uint64 >::const_iterator it = size_per_set.begin(); it != size_per_set.end(); ++it)
381164569592 q result += it->second;
38374359595 q if (parent)
3842808064 q return result + parent->total_size();
38646279595 q return result;
38774359595 q}
390std::vector< std::pair< uint, uint > > Runtime_Stack_Frame::stack_progress() const
3910{
3920 std::vector< std::pair< uint, uint > > result;
3930 if (parent)
3940 parent->stack_progress().swap(result);
3960 result.push_back(std::make_pair(loop_count, loop_size));
3980 return result;
3990}
402Resource_Manager::Resource_Manager(
403 Transaction& transaction_, Parsed_Query* global_settings_, Watchdog_Callback* watchdog_,
404 Error_Output* error_output_)
405493493 q : transaction(&transaction_), error_output(error_output_),
406493493 q area_transaction(0), area_updater_(0),
407493493 q watchdog(watchdog_), global_settings(global_settings_), global_settings_owned(false),
408493493 q start_time(time(NULL)), last_ping_time(0), last_report_time(0),
409493493 q max_allowed_time(0), max_allowed_space(0)
411493493 q if (!global_settings)
4120 {
4130 global_settings = new Parsed_Query();
4140 global_settings_owned = true;
4150 }
417493493 q runtime_stack.push_back(new Runtime_Stack_Frame());
421Resource_Manager::Resource_Manager(
422 Transaction& transaction_, Parsed_Query& global_settings_, Error_Output* error_output_,
423 Transaction& area_transaction_, Watchdog_Callback* watchdog_, Area_Usage_Listener* area_updater__)
424102102 q : transaction(&transaction_), error_output(error_output_),
425102102 q area_transaction(&area_transaction_), area_updater_(area_updater__),
426102102 q watchdog(watchdog_), global_settings(&global_settings_), global_settings_owned(false),
427102102 q start_time(time(NULL)), last_ping_time(0), last_report_time(0),
428102102 q max_allowed_time(0), max_allowed_space(0)
430102102 q runtime_stack.push_back(new Runtime_Stack_Frame());
434const Set* Resource_Manager::get_set(const std::string& set_name)
43513453586 q{
43613453586 q if (runtime_stack.empty())
4370 return 0;
43913453586 q return runtime_stack.back()->get_set(set_name);
44013453586 q}
443const Diff_Set* Resource_Manager::get_diff_set(const std::string& set_name)
44593676 q if (runtime_stack.empty())
4460 return 0;
44893676 q return runtime_stack.back()->get_diff_set(set_name);
452void Resource_Manager::swap_set(const std::string& set_name, Set& set_)
45331518590 q{
45431518590 q if (runtime_stack.empty())
4550 runtime_stack.push_back(new Runtime_Stack_Frame());
45731518590 q sort(set_);
45831518590 q runtime_stack.back()->swap_set(set_name, set_);
45931518590 q}
462void Resource_Manager::swap_diff_set(const std::string& set_name, Diff_Set& set_)
4641616 q if (runtime_stack.empty())
4650 runtime_stack.push_back(new Runtime_Stack_Frame());
4671616 q runtime_stack.back()->swap_diff_set(set_name, set_);
471const std::string* Resource_Manager::get_value(const std::string& set_name, const std::string& key)
4720{
4730 if (runtime_stack.empty())
4740 return 0;
4760 return runtime_stack.back()->get_value(set_name, key);
4770}
480const std::map< std::string, std::string >* Resource_Manager::get_set_key_values(const std::string& set_name)
482323 q if (runtime_stack.empty())
4830 return 0;
485323 q return runtime_stack.back()->get_set_key_values(set_name);
489void Resource_Manager::set_value(const std::string& set_name, const std::string& key, const std::string& value)
49141117 q if (runtime_stack.empty())
4920 runtime_stack.push_back(new Runtime_Stack_Frame());
49441117 q runtime_stack.back()->set_value(set_name, key, value);
498void Resource_Manager::erase_set(const std::string& set_name)
4990{
5000 if (runtime_stack.empty())
5010 runtime_stack.push_back(new Runtime_Stack_Frame());
5030 runtime_stack.back()->erase_set(set_name);
5040}
507void Resource_Manager::clear_sets()
5080{
5090 if (!runtime_stack.empty())
5100 runtime_stack.back()->clear_sets();
5110}
515void Resource_Manager::push_stack_frame()
5173049177 q runtime_stack.push_back(new Runtime_Stack_Frame(runtime_stack.empty() ? 0 : runtime_stack.back()));
521void Resource_Manager::copy_outward(const std::string& inner_set_name, const std::string& top_set_name)
52315457 q if (!runtime_stack.empty())
52415457 q runtime_stack.back()->copy_outward(inner_set_name, top_set_name);
528void Resource_Manager::move_outward(const std::string& inner_set_name, const std::string& top_set_name)
529287374 q{
530287374 q if (!runtime_stack.empty())
531287374 q runtime_stack.back()->move_outward(inner_set_name, top_set_name);
532287374 q}
535bool Resource_Manager::union_inward(const std::string& top_set_name, const std::string& inner_set_name)
5372686104 q if (runtime_stack.empty())
5380 return false;
5402686104 q return runtime_stack.back()->union_inward(top_set_name, inner_set_name);
544void Resource_Manager::copy_inward(const std::string& top_set_name, const std::string& inner_set_name)
5462622 q if (!runtime_stack.empty())
5472622 q runtime_stack.back()->copy_inward(top_set_name, inner_set_name);
551void Resource_Manager::substract_from_inward(const std::string& top_set_name, const std::string& inner_set_name)
5532622 q if (!runtime_stack.empty())
5542622 q runtime_stack.back()->substract_from_inward(top_set_name, inner_set_name);
558void Resource_Manager::move_all_inward()
5607757 q if (!runtime_stack.empty())
5617757 q runtime_stack.back()->move_all_inward();
565void Resource_Manager::move_all_inward_except(const std::string& set_name)
5672956126 q if (!runtime_stack.empty())
5682956126 q runtime_stack.back()->move_all_inward_except(set_name);
572void Resource_Manager::pop_stack_frame()
5743049177 q if (!runtime_stack.empty())
5753049177 q {
5763049177 q delete runtime_stack.back();
5773049177 q runtime_stack.pop_back();
5783049177 q }
582uint count_set(const Set& set_)
5830{
5840 uint size(0);
5850 for (std::map< Uint32_Index, std::vector< Node_Skeleton > >::const_iterator
5860 it(set_.nodes.begin()); it != set_.nodes.end(); ++it)
5870 size += it->second.size();
5880 for (std::map< Uint31_Index, std::vector< Way_Skeleton > >::const_iterator
5890 it(set_.ways.begin()); it != set_.ways.end(); ++it)
5900 size += it->second.size();
5910 for (std::map< Uint31_Index, std::vector< Relation_Skeleton > >::const_iterator
5920 it(set_.relations.begin()); it != set_.relations.end(); ++it)
5930 size += it->second.size();
5950 for (std::map< Uint32_Index, std::vector< Attic< Node_Skeleton > > >::const_iterator
5960 it(set_.attic_nodes.begin()); it != set_.attic_nodes.end(); ++it)
5970 size += it->second.size();
5980 for (std::map< Uint31_Index, std::vector< Attic< Way_Skeleton > > >::const_iterator
5990 it(set_.attic_ways.begin()); it != set_.attic_ways.end(); ++it)
6000 size += it->second.size();
6010 for (std::map< Uint31_Index, std::vector< Attic< Relation_Skeleton > > >::const_iterator
6020 it(set_.attic_relations.begin()); it != set_.attic_relations.end(); ++it)
6030 size += it->second.size();
6050 for (std::map< Uint31_Index, std::vector< Area_Skeleton > >::const_iterator
6060 it(set_.areas.begin()); it != set_.areas.end(); ++it)
6070 size += it->second.size();
6090 return size;
6100}
613void Resource_Manager::count_loop()
6142727445 q{
6152727445 q if (runtime_stack.empty())
6160 return;
6182727445 q runtime_stack.back()->count_loop();
6192727445 q}
622void Resource_Manager::log_and_display_error(std::string message)
6230{
6240 if (error_output)
6250 error_output->runtime_error(message);
6270 Logger logger(transaction->get_db_dir());
6280 logger.annotated_log(message);
6290}
632bool Resource_Manager::health_check(const Statement& stmt, uint32 extra_time, uint64 extra_space)
63346279595 q{
63446279595 q bool extra_space_uses_half_empty = false;
63646279595 q uint32 elapsed_time = 0;
63746279595 q if (max_allowed_time > 0)
63846279595 q elapsed_time = time(NULL) - start_time + extra_time;
64046279595 q if (elapsed_time >= last_ping_time + 5)
6423328 q if (watchdog)
6433328 q watchdog->ping();
6443328 q last_ping_time = elapsed_time;
6463328 q if (elapsed_time >= last_report_time + 15)
6470 {
6480 if (error_output)
6490 {
6500 error_output->display_statement_progress
6510 (elapsed_time, stmt.get_name(), stmt.get_progress(), stmt.get_line_number(),
6520 runtime_stack.back()->stack_progress());
6530 }
6540 last_report_time = elapsed_time;
6550 }
65846279595 q uint64 size = 0;
65946279595 q if (max_allowed_space > 0)
66046279595 q {
66146279595 q if (!runtime_stack.empty())
66246279595 q size += runtime_stack.back()->total_size();
66346279595 q extra_space_uses_half_empty = (extra_space*2 >= max_allowed_space - size);
66446279595 q size += extra_space;
66546279595 q }
66746279595 q if (elapsed_time > max_allowed_time || size > max_allowed_space)
6680 {
6690 if (error_output)
6700 {
6710 error_output->display_statement_progress
6720 (elapsed_time, stmt.get_name(), stmt.get_progress(), stmt.get_line_number(),
6730 runtime_stack.back()->stack_progress());
6740 }
6760 Resource_Error error;
6770 error.timed_out = (elapsed_time > max_allowed_time);
6780 error.stmt_name = stmt.get_name();
6790 error.line_number = stmt.get_line_number();
6800 error.size = size;
6810 error.runtime = elapsed_time;
6830 Logger logger(transaction->get_db_dir());
6840 std::ostringstream out;
6850 if (elapsed_time > max_allowed_time)
6860 out<<"Timeout:";
6870 else
6880 out<<"Oversized:";
6890 out<<" runtime "<<error.runtime<<" seconds, size "<<error.size<<" bytes, "
6900 "in line "<<error.line_number<<", statement "<<error.stmt_name;
6910 logger.annotated_log(out.str());
6930 throw error;
6940 }
69646279595 q return extra_space_uses_half_empty;
69746279595 q}
700uint64 Resource_Manager::get_desired_timestamp() const
70155372591 q{
70255372591 q return runtime_stack.empty() ? NOW : runtime_stack.back()->get_desired_timestamp();
70355372591 q}
706Diff_Action::_ Resource_Manager::get_desired_action() const
7089519585 q return runtime_stack.empty() ? Diff_Action::positive : runtime_stack.back()->get_desired_action();
712uint64 Resource_Manager::get_diff_from_timestamp() const
713130842 q{
714130842 q return runtime_stack.empty() ? NOW : runtime_stack.back()->get_diff_from_timestamp();
715130842 q}
718uint64 Resource_Manager::get_diff_to_timestamp() const
72093042 q return runtime_stack.empty() ? NOW : runtime_stack.back()->get_diff_to_timestamp();
724void Resource_Manager::start_diff(uint64 comparison_timestamp, uint64 desired_timestamp)
7267676 q if (!runtime_stack.empty())
7287676 q runtime_stack.back()->set_desired_action(Diff_Action::collect_lhs);
7297676 q runtime_stack.back()->set_diff_from_timestamp(comparison_timestamp);
7307676 q runtime_stack.back()->set_diff_to_timestamp(desired_timestamp);
7317676 q runtime_stack.back()->set_desired_timestamp(comparison_timestamp);
736void Resource_Manager::switch_diff_rhs(bool add_deletion_information)
7387676 q if (!runtime_stack.empty())
7407676 q runtime_stack.back()->clear_sets();
7417676 q runtime_stack.back()->set_desired_action(
7427676 q add_deletion_information ? Diff_Action::collect_rhs_with_del : Diff_Action::collect_rhs_no_del);
7437676 q runtime_stack.back()->set_desired_timestamp(runtime_stack.back()->get_diff_to_timestamp());
748void Resource_Manager::switch_diff_show_from(const std::string& diff_set_name)
75088 q if (!runtime_stack.empty())
75288 q runtime_stack.back()->set_desired_action(Diff_Action::show_old);
75388 q runtime_stack.back()->set_desired_timestamp(runtime_stack.back()->get_diff_from_timestamp());
75588 q Diff_Set* diff_set = runtime_stack.back()->get_diff_set(diff_set_name);
75688 q if (diff_set)
75888 q Set set = diff_set->make_from_set();
75988 q runtime_stack.back()->swap_set(diff_set_name, set);
765void Resource_Manager::switch_diff_show_to(const std::string& diff_set_name)
76788 q if (!runtime_stack.empty())
76988 q runtime_stack.back()->set_desired_action(Diff_Action::show_new);
77088 q runtime_stack.back()->set_desired_timestamp(runtime_stack.back()->get_diff_to_timestamp());
77288 q Diff_Set* diff_set = runtime_stack.back()->get_diff_set(diff_set_name);
77388 q if (diff_set)
77588 q Set set = diff_set->make_to_set();
77688 q runtime_stack.back()->swap_set(diff_set_name, set);
782void Resource_Manager::set_desired_timestamp(uint64 timestamp)
7841487595 q if (!runtime_stack.empty())
7851487595 q runtime_stack.back()->set_desired_timestamp(timestamp);
789void Resource_Manager::start_cpu_timer(uint index)
79010023595 q{
79110023595 q if (cpu_start_time.size() <= index)
7921687595 q cpu_start_time.resize(index+1, 0);
79310023595 q cpu_start_time[index] = clock()/1000;
79410023595 q}
797void Resource_Manager::stop_cpu_timer(uint index)
79810023595 q{
79910023595 q if (cpu_runtime.size() <= index)
8001097595 q cpu_runtime.resize(index+1, 0);
80110023595 q if (index < cpu_start_time.size())
80210023595 q cpu_runtime[index] += clock()/1000 - cpu_start_time[index];
80310023595 q}