diff options
author | Monty <monty@mariadb.org> | 2022-08-11 13:05:23 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2022-08-12 00:47:48 +0300 |
commit | 07ffb3abc1004a102c2c605c7c280913741d5d87 (patch) | |
tree | 17dc111061e19f94c8378962f3e2952197366f03 /include/my_tracker.h | |
parent | 0352e855f1be0e440eb9b7dbd8c6b42151252b88 (diff) | |
download | mariadb-git-10.7-selectivity-old.tar.gz |
TEMPORARY PUSH: Changing all cost calculation to be given in ms10.7-selectivity-old
- Added tests/check_costs.pl, a tool to verify optimizer cost calculations.
- Most costs has been found with this program. All steps to calculate
the new costs are documented in Docs/optimizer.costs
- User optimizer_cost variables are given in usec (as individual
costs can be very small). Internally they are stored in ms.
- Changed DISK_READ_COST (was DISK_SEEK_BASE_COST) from a hard disk cost
(9 ms) to common SSD cost (400MB/sec).
- Changed the following handler functions to return IO_AND_CPU_COST.
This makes it easy to apply different cost modifiers in ha_..time()
functions for io and cpu costs.
- scan_time()
- rndpos_time()
- keyread_time()
- Enhanched keyread_time() to calculate the full cost of reading of a set
of keys with a given number of ranges and optionall number of blocks that
need to be accessed.
- Removed read_time() as keyread_time() + rndpos_time() is the same thing.
- Added the following new optimizer_variables:
- optimizer_scan_lookup_cost
- optimizer_row_lookup_cost
- optimizer_index_lookup_cost
- optimizer_disk_read_cost
- Added include/my_tracker.h ; Useful include file to quickly test costs
of a function.
- Tuned sequence and heap engine costs (rest will be done in an updated
commit)
Diffstat (limited to 'include/my_tracker.h')
-rw-r--r-- | include/my_tracker.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/include/my_tracker.h b/include/my_tracker.h new file mode 100644 index 00000000000..88cefe5ef5d --- /dev/null +++ b/include/my_tracker.h @@ -0,0 +1,41 @@ +/* Copyright (c) 2022, MariaDB Corporation. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ + +/* + Trivial framework to add a tracker to a C function +*/ + +#include "my_rdtsc.h" + +struct my_time_tracker +{ + ulonglong counter; + ulonglong cycles; +}; + +#ifdef HAVE_TIME_TRACKING +#define START_TRACKING ulonglong my_start_time= my_timer_cycles() +#define END_TRACKING(var) \ + { \ + ulonglong my_end_time= my_timer_cycles(); \ + (var)->counter++; \ + (var)->cycles+= (unlikely(my_end_time < my_start_time) ? \ + my_end_time - my_start_time + ULONGLONG_MAX : \ + my_end_time - my_start_time); \ + } +#else +#define START_TRACKING +#define END_TRACKING(var) do { } while(0) +#endif |