| Age | Commit message (Collapse) | Author |
|
These patterns shouldn't occur in practice, as their results are tricky
to predict. Generate a warning for now, and maybe an error later.
Reviewed by sjg@.
|
|
No binary change.
|
|
Noticed by sjg.
|
|
Previously, each time a .for directive pushed its buffer on the input
file stack, the current filename was duplicated. This was a waste of
memory.
The name of a file is typically only used while it is read in. There is
one situation when the filename is needed for longer, which is when a
target is defined.
Since .for loops are implemented as a special form of included files,
each .for loop duplicated the current filename as well.
$ cat << EOF > for.mk
.for i in 1 2 3 4 5 6 7 8 9 0
.for i in 1 2 3 4 5 6 7 8 9 0
.for i in 1 2 3 4 5 6 7 8 9 0
.for i in 1 2 3 4 5 6 7 8 9 0
.for i in 1 2 3 4 5 6 7 8 9 0
.for i in 1 2 3 4 5 6 7 8 9 0
.for i in 1 2 3 4 5 6 7 8 9 0
.endfor
.endfor
.endfor
.endfor
.endfor
.endfor
.endfor
all:
@ps -o rsz -p ${.MAKE.PID}
EOF
$ make-2021.12.13.03.55.16 -r -f for.mk
RSZ
10720
$ ./make -r -f for.mk
RSZ
1716
The difference is 8 MB, which amounts to 1 million .for loops.
|
|
The only binary change is the line number of the assertion in
Substring_Sub.
|
|
This affects many operations on variable expressions. Those using
LazyBuf_Done are affected, those using LazyBuf_DoneGet aren't.
$ cat <<'EOF' > lazybuf-memleak.mk
.for i in ${:U:range=5}
. for j in ${:U:range=1000}
. for k in ${:U:range=1000}
. if 0 && ${VAR:Dpattern\: that needs unescaping}
. endif
. endfor
. endfor
.endfor
all:
@ps -o vsz -p ${.MAKE.PID} | sed 1d
EOF
Before using LazyBuf for the modifier ':D':
$ make-2021.04.14.16.12.26 -r -f lazybuf-memleak.mk
VSZ RSZ
1357136 1336432
Using LazyBuf for the modifier ':D':
$ make-2021.04.14.16.59.34 -r -f lazybuf-memleak.mk
VSZ RSZ
1590864 1574164
This commit alone allocates around 150 MB more data, which matches
5_000_000 strings * 30 bytes/string.
It looks very wrong that the above simple makefile uses 1.3 GB of RAM at
all, and it had already done this in 2017, long before LazyBuf was
introduced. Before 2017.01.30.02.46.20, the above test makefile reports
way smaller numbers, but that's because the modifier ':range' did not
exist back then.
|
|
No functional change.
|
|
This saves one memory allocation and a bit of copying, per .for loop.
No functional change.
|
|
This function is only ever used for forming strings of the form
"archive(member)".
No functional change.
|
|
On x86_64, this reduces the binary size by 2 kB.
|
|
|
|
Previously, SysVMatch was quite verbose and felt like hand-optimized
assembler code, which made it difficult to discover the underlying idea
of the code.
All this code was replaced with two simple calls to Substring_HasPrefix
and Substring_HasSuffix. Now that the operands of that modifier are no
longer passed as C strings, there is no need to collect all information
in a single scan through the word and the pattern.
It was not necessary to call Var_Subst unconditionally. Calling it only
when the string contains a '$' saves another memory allocation and two
string copies (because of the Buf_DoneDataCompact).
No functional change.
|
|
The previous O(n^2) time complexity for parsing a long string with many
variable expressions was not meant to last for long. I had hoped to fix
it within a few minutes, but that will take more time.
For now, make LazyBuf simpler by using a traditional C string for the
expected part instead of a Substring. This avoids a strlen call per
Var_Parse.
No functional change, only performance.
|
|
This will reduce memory allocation for modifier parts without the escape
characters '$' or '\'.
No functional change.
|
|
No functional change.
|
|
This benefits the modifiers ':T' and ':H' since these scan the word from
the end. The SysV modifier '.c=.o' does not benefit yet, this will be
done in a follow-up commit.
Currently ModifyWords calls strlen for each single word, which degrades
performance. This will be cleaned up in a follow-up commit as well.
No functional change.
|
|
These will be used for making the string handling more efficient,
avoiding allocations, especially when evaluating variable expressions.
Since the string handling has grown quite a bit in the last months,
extract it into its own header file.
No functional change.
|