From 49ee105c685cb84bc3057e8b7666fc0cc7090047 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Wed, 13 Apr 2005 03:16:33 +0000 Subject: Fix performance degradation introduced by the second expansion feature. I did this by adding intelligence into the algorithm such that the second expansion was only actually performed when the prerequisite list contained at least one "$", so we knew it is actually needed. Without this we were using up a LOT more memory, since every single target (even ones never used by make) had their file variables initialized. This also used a lot more CPU, since we needed to create and populate a new variable hash table for every target. There is one issue remaining with this feature: it leaks memory. In pattern_search() we now initialize the file variables for every pattern target, which allocates a hash table, etc. However, sometimes we recursively invoke pattern_search() (for intermediate files) with an automatic variable (alloca() I believe) as the file. When that function returns, obviously, the file variable hash memory is lost. --- ChangeLog | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'ChangeLog') diff --git a/ChangeLog b/ChangeLog index 03cb071..4d443eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2005-04-12 Paul D. Smith + + The second expansion feature causes significant slowdown. Timing + a complex makefile (GCC 4.1) shows a slowdown from .25s to just + read the makefile before the feature, to 11+s to do the same + operations after the feature. Additionally, memory usage + increased drastically. To fix this I added some intelligence that + avoids the overhead of the second expansion unless it's required. + + * dep.h: Add a new boolean field, need_2nd_expansion. + + * read.c (eval): When creating the struct dep for the target, + check if the name contains a "$"; if so set need_2nd_expansion to 1. + (record_files): If there's a "%" in a static pattern rule, it gets + converted to "$*" so set need_2nd_expansion to 1. + + * file.c (expand_deps): Rework to be more efficient. Only perform + initialize_file_variables(), set_file_variables(), and + variable_expand_for_file() if the need_2nd_expansion is set. + + * implicit.c (pattern_search): Default need_2nd_expansion to 0. + (pattern_search): Ditto. + * main.c (handle_non_switch_argument): Ditto. + (main): Ditto. + * read.c (read_all_makefiles): Ditto. + (eval_makefile): Ditto. + 2005-04-07 Paul D. Smith * main.c (main) [WINDOWS32]: Export PATH to sub-shells, not Path. -- cgit v1.2.3