[MDEV-30437] Run gcov on spider code Created: 2023-01-20  Updated: 2023-01-25  Resolved: 2023-01-25

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - Spider
Fix Version/s: 11.0.1

Type: Task Priority: Major
Reporter: Yuchen Pei Assignee: Yuchen Pei
Resolution: Fixed Votes: 0
Labels: None

Attachments: Text File unused-functions.txt    

 Description   

https://mariadb.org/gcov-in-mariadb/

Start with 11.0



 Comments   
Comment by Yuchen Pei [ 2023-01-20 ]

Run cmake with -DENABLE_GCOV=ON, then do

./mysql-test/mtr --suite spider,spider/*,spider/*/* --skip-test="spider/oracle.*|.*/t\..*" --parallel=auto --big-test --force --max-test-fail=0 --skip-core-file --gcov
find . -iname *.gc* | xargs gcov
ls *.gcov

To find un-exercised spider functions according to gcov, and print them grouped by file and sorted by length:

for f in ./storage/spider/CMakeFiles/spider.dir/*.gcda; do ff="${f##*/}" && echo "${ff%.gcda}" && gcov -i "$f" > /dev/null && gunzip -c "$ff".gcov.json.gz | jq '."files" | .[0] | ."functions" | [.[] | select(.blocks_executed == 0) | {"demangled_name", "start_line", "length": (."end_line" - ."start_line")}] | sort_by(-."length")'; done

The output is something like

ha_spider.cc
[
{
  "demangled_name": "ha_spider::read_range_first_internal(unsigned char*, st_key_range const*, st_key_range const*, bool, bool)",
  "start_line": 2738,
  "length": 303
},
{
  "demangled_name": "ha_spider::index_read_last_map_internal(unsigned char*, unsigned char const*, unsigned long)",
  "start_line": 1616,
  "length": 298
},
...

Attached is the full output at 11.0 (c37ebaf6c22).

Comment by Yuchen Pei [ 2023-01-23 ]

Running on 11.0 c37ebaf6c22

c37ebaf6c22

File '/home/ycp/source/mariadb-server/mdev-30437/src/storage/spider/spd_trx.cc'
Lines executed:44.41% of 2110
Creating 'spd_trx.cc.gcov'
 
File '/home/ycp/source/mariadb-server/mdev-30437/src/storage/spider/spd_include.h'
No executable lines
Removing 'spd_include.h.gcov'
 
File '/home/ycp/source/mariadb-server/mdev-30437/src/storage/spider/spd_db_conn.cc'
Lines executed:50.58% of 5749
Creating 'spd_db_conn.cc.gcov'
 
File '/home/ycp/source/mariadb-server/mdev-30437/src/storage/spider/spd_param.cc'
Lines executed:87.35% of 427
Creating 'spd_param.cc.gcov'
 
File '/home/ycp/source/mariadb-server/mdev-30437/src/storage/spider/spd_ping_table.cc'
Lines executed:57.39% of 934
Creating 'spd_ping_table.cc.gcov'
 
File '/home/ycp/source/mariadb-server/mdev-30437/src/storage/spider/spd_copy_tables.cc'
Lines executed:55.52% of 661
Creating 'spd_copy_tables.cc.gcov'
 
File '/home/ycp/source/mariadb-server/mdev-30437/src/storage/spider/spd_table.h'
Lines executed:71.43% of 105
Creating 'spd_table.h.gcov'
 
File '/home/ycp/source/mariadb-server/mdev-30437/src/storage/spider/spd_db_include.cc'
Lines executed:15.93% of 113
Creating 'spd_db_include.cc.gcov'
 
File '/home/ycp/source/mariadb-server/mdev-30437/src/storage/spider/spd_db_include.h'
Lines executed:88.89% of 18
Creating 'spd_db_include.h.gcov'
 
File '/home/ycp/source/mariadb-server/mdev-30437/src/storage/spider/spd_direct_sql.cc'
Lines executed:59.45% of 1021
Creating 'spd_direct_sql.cc.gcov'
 
File '/home/ycp/source/mariadb-server/mdev-30437/src/storage/spider/spd_sys_table.cc'
Lines executed:57.85% of 1993
Creating 'spd_sys_table.cc.gcov'
 
File '/home/ycp/source/mariadb-server/mdev-30437/src/storage/spider/spd_table.cc'
Lines executed:60.26% of 5176
Creating 'spd_table.cc.gcov'
 
File '/home/ycp/source/mariadb-server/mdev-30437/src/storage/spider/ha_spider.cc'
Lines executed:53.25% of 7093
Creating 'ha_spider.cc.gcov'
 
File '/home/ycp/source/mariadb-server/mdev-30437/src/storage/spider/spd_conn.cc'
Lines executed:49.17% of 2282
Creating 'spd_conn.cc.gcov'
 
File '/home/ycp/source/mariadb-server/mdev-30437/src/storage/spider/spd_group_by_handler.cc'
Lines executed:75.76% of 1213
Creating 'spd_group_by_handler.cc.gcov'

Generated at Thu Feb 08 10:16:15 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.