History log of /netbsd/usr.bin/make/str.h (Results 1 – 17 of 17)
Revision Date Author Comments
# acecf207 23-Jun-2023 rillig <rillig@NetBSD.org>

make: warn about malformed patterns in ':M', ':N' and '.if make(...)'

These patterns shouldn't occur in practice, as their results are tricky
to predict. Generate a warning for now, and maybe an er

make: warn about malformed patterns in ':M', ':N' and '.if make(...)'

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@.

show more ...


# 8463742c 05-Dec-2022 rillig <rillig@NetBSD.org>

make: inline LazyBuf_AddBytesBetween

No binary change.


# fe62f560 15-Dec-2021 rillig <rillig@NetBSD.org>

make: in CLEANUP mode, free interned strings at the very end

Noticed by sjg.


# f642d734 13-Dec-2021 rillig <rillig@NetBSD.org>

make: fix memory leak for filenames in .for loops (since 2013-06-18)

Previously, each time a .for directive pushed its buffer on the input
file stack, the current filename was duplicated. This was

make: fix memory leak for filenames in .for loops (since 2013-06-18)

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.

show more ...


# 5cec5d1d 12-Dec-2021 rillig <rillig@NetBSD.org>

make: remove unused type MFStr

The only binary change is the line number of the assertion in
Substring_Sub.


# 48c0f4ba 12-Dec-2021 rillig <rillig@NetBSD.org>

make: fix memory leak in LazyBuf

This affects many operations on variable expressions. Those using
LazyBuf_Done are affected, those using LazyBuf_DoneGet aren't.

$ cat <<'EOF' > lazybuf-memleak.mk

make: fix memory leak in LazyBuf

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.

show more ...


# 3e6bd2fc 05-Dec-2021 rillig <rillig@NetBSD.org>

make: save a memory allocation in each modifier ':O' and ':u'

No functional change.


# 39fc55b2 05-Dec-2021 rillig <rillig@NetBSD.org>

make: inline Str_Words into .for loop handling

This saves one memory allocation and a bit of copying, per .for loop.

No functional change.


# 87eef6f2 30-May-2021 rillig <rillig@NetBSD.org>

make: inline str_concat4

This function is only ever used for forming strings of the form
"archive(member)".

No functional change.


# 2234229e 14-Apr-2021 rillig <rillig@NetBSD.org>

make: let the compiler decide whether to inline string functions

On x86_64, this reduces the binary size by 2 kB.


# 0efce342 14-Apr-2021 rillig <rillig@NetBSD.org>

make: reduce memory allocations in the modifiers ':D' and ':U'


# 163fe177 12-Apr-2021 rillig <rillig@NetBSD.org>

make: reduce memory allocation and strlen calls in modifier ':from=to'

Previously, SysVMatch was quite verbose and felt like hand-optimized
assembler code, which made it difficult to discover the un

make: reduce memory allocation and strlen calls in modifier ':from=to'

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.

show more ...


# 45ceab83 11-Apr-2021 rillig <rillig@NetBSD.org>

make: improve performance for LazyBuf

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

make: improve performance for LazyBuf

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.

show more ...


# 4ef78b0d 11-Apr-2021 rillig <rillig@NetBSD.org>

make: migrate ParseModifierPart to use Substring

This will reduce memory allocation for modifier parts without the escape
characters '$' or '\'.

No functional change.


# e0bcad00 11-Apr-2021 rillig <rillig@NetBSD.org>

make: avoid unnecessary calls to strlen when evaluating modifiers

No functional change.


# 213d0a50 11-Apr-2021 rillig <rillig@NetBSD.org>

make: migrate ModifyWord functions to use Substring

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
do

make: migrate ModifyWord functions to use Substring

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.

show more ...


# b606e75a 11-Apr-2021 rillig <rillig@NetBSD.org>

make: add types Substring and LazyBuf

These will be used for making the string handling more efficient,
avoiding allocations, especially when evaluating variable expressions.

Since the string handl

make: add types Substring and LazyBuf

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.

show more ...