This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [FORTRAN PATCH] Reduce gfc_match_strings usage (part 1)
- From: FX Coudert <fxcoudert at gmail dot com>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Sun, 11 Mar 2007 09:29:08 +0100
- Subject: Re: [FORTRAN PATCH] Reduce gfc_match_strings usage (part 1)
- References: <8876.68.35.10.103.1173581638.squirrel@mail.eyesopen.com>
Hi all,
A few days ago, I was wondering how much we could improve gfortran's
compilation speed, and I built a compiler with profiling enabled (./
configure --disable-bootstrap CFLAGS=-pg LDFLAGS=-pg && make). On a -
O0 compilation (the case where the front-end time is probably the
most visible in the total compile time) of F95 intensive code (which
is what tomorrow's code will look like; I chose CP2K for that
fragment), the routines with >1% time are:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
6.81 15.41 15.41 4491770 0.00 0.00 walk_tree
4.19 24.88 9.47 33123518 0.00 0.00 insert_aux
4.09 34.13 9.25 6338750 0.00 0.00
pointer_set_insert
3.75 42.63 8.50 1103855 0.00 0.00 gfc_match_strings
3.19 49.84 7.22 21693724 0.00 0.00
generic_tree_operand
2.26 54.96 5.12 33996539 0.00 0.00
tree_operand_length
2.13 59.77 4.81 1517589 0.00 0.00
gt_ggc_mx_lang_tree_node
1.82 63.89 4.12 9399814 0.00 0.00 ggc_set_mark
1.66 67.65 3.76 33123518 0.00 0.00 hash1
1.65 71.39 3.74 838706 0.00 0.00
expand_expr_real_1
1.54 74.88 3.49 3640277 0.00 0.00 ggc_alloc_stat
1.49 78.24 3.36 925153 0.00 0.00 gimplify_expr
1.23 81.03 2.79 16013192 0.00 0.00 next_char
1.19 83.73 2.70 650548 0.00 0.00 operand_equal_p
1.02 86.04 2.31 12717821 0.00 0.00
gfc_next_char_literal
And if I only write out the Fortran front-end functions, the top of
the list is:
3.75 42.63 8.50 1103855 0.00 0.00 gfc_match_strings
1.02 86.04 2.31 12717821 0.00 0.00
gfc_next_char_literal
0.29 127.21 0.65 7827668 0.00 0.00 gfc_next_char
0.29 127.86 0.65 3191988 0.00 0.00
gfc_gobble_whitespace
0.28 129.13 0.64 631736 0.00 0.00 gfc_match
0.23 141.23 0.52 13132866 0.00 0.00 gfc_at_end
0.15 157.25 0.33 95191 0.00 0.00 gfc_advance_line
0.15 157.58 0.33 296081 0.00 0.00 gfc_find_symtree
0.12 164.39 0.28 954621 0.00 0.00 gfc_getmem
0.11 165.19 0.26 58196 0.00 0.00 gfc_conv_variable
0.11 166.20 0.25 217450 0.00 0.00 gfc_match_name
0.11 166.45 0.25 353188 0.00 0.00 gfc_copy_expr
Anyone can draw his own conclusions, mine are that gfc_match_strings
is indeed the spot where we spend most of our time (together with
related routines like gfc_next_char*), but that only accounts for 5%
of the compilation time. What I also see is that gfc_match_strings()
is only called 3 times in the source, so that specialized
replacements are probably not so bad a solution.
PS-1: My original idea was due to the recent patch about hot and cold
attributes, and I wondered whether we could mark some gfc_ functions
hot. I was about to suggest marking gfc_match_strings, gfc_next_char,
gfc_next_char_literal and gfc_gobble_whitespace hot. What do you
think about it?
PS-2: I also made a list of functions sorted by the number of times
they get called:
13132866 0.23 gfc_at_end
12717821 1.02 gfc_next_char_literal
7827668 0.29 gfc_next_char
3191988 0.29 gfc_gobble_whitespace
1103855 3.75 gfc_match_strings
1041059 0.04 gfc_match_intrinsic_op
954621 0.12 gfc_getmem
755398 0.04 gfc_free
656869 0.05 gfc_clear_ts
631736 0.28 gfc_match
595726 0.04 gfc_free_expr
572279 0.06 gfc_simplify_expr
524067 0.07 gfc_get_expr
(number of times called / total time spent in that function /
function name)
Seeing that, it appears there are very simple functions that are
called very often. gfc_at_end(), for example, might be inline:
int
gfc_at_end (void)
{
return end_flag;
}
So can be gfc_getmem, gfc_free and. Maybe also gfc_clear_ts,
gfc_get_expr and gfc_free_expr?
FX