Files
swift-mirror/utils/gen-static-stdlib-link-args
John McCall 038303b1b1 Switch MetadataCache to use a global slab allocator.
This seems to more than fix a performance regression that we
detected on a metadata-allocation microbenchmark.

A few months ago, I improved the metadata cache representation
and changed the metadata allocation scheme to primarily use malloc.
Previously, we'd been using malloc in the concurrent tree data
structure but a per-cache slab allocator for the metadata itself.
At the time, I was concerned about the overhead of per-cache
allocators, since many metadata patterns see only a small number
of instantiations.  That's still an important factor, so in the
new scheme we're using a global allocator; but instead of using
malloc for individual allocations, we're using a slab allocator,
which should have better peak, single-thread performance, at the
cost of not easily supporting deallocation.  Deallocation is
only used for metadata when there's contention on the cache, and
specifically only when there's contention for the same key, so
leaking a little isn't the worst thing in the world.

The initial slab is a 64K globally-allocated buffer.
Successive slabs are 16K and allocated with malloc.

rdar://28189496
2017-02-14 11:10:44 -05:00

84 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Generate the static-stdlib-args.lnk used by the -static-stdlib option for
# 'GenericUnix' (eg linux) plaforms. Tries to find static .a files for libs
# not normally installed by default (currently libicu)
# If libicu is built locally then include libicudata
#
# SDK=$1
OUTPUTFILE=$2
ICU_STATIC_LIB=$3
# libdirs from pkg-config
ICU_UC_LIBDIR=$4
ICU_I18N_LIBDIR=$5
# Try and find the libicu .a library files to directly link in using the
# fullpath to the files otherwise fullback to the default
function find_static_iculibs {
if [ -n "${ICU_I18N_LIBDIR}" ]; then
LIBICU_I18N_A=${ICU_I18N_LIBDIR}/libicui18n.a
fi
if [ -n "${ICU_UC_LIBDIR}" ]; then
LIBICU_UC_A=${ICU_UC_LIBDIR}/libicuuc.a
LIBICU_DATA_A=${ICU_UC_LIBDIR}/libicudata.a
fi
if [ -f "${LIBICU_I18N_A}" ] && [ -f "${LIBICU_UC_A}" ] &&
[ -f "${LIBICU_DATA_A}" ]; then
read -d '' ICU_LIBS <<EOF
$LIBICU_I18N_A
$LIBICU_UC_A
$LIBICU_DATA_A
EOF
else
read -d '' ICU_LIBS <<EOF
-licui18n
-licuuc
EOF
fi
}
# If libicu was compiled as part of the swift build then link the libs as normal
function use_local_iculibs {
read -d '' ICU_LIBS <<EOF
-licui18n
-licuuc
-licudata
EOF
}
function write_linkfile {
if [ -z "${OUTPUTFILE}" ]; then
echo $0: No outputfile specified
exit 1
fi
cat >$OUTPUTFILE <<EOF
-ldl
-lpthread
-lswiftCore
-latomic
-lswiftImageInspectionShared
$ICU_LIBS
-Xlinker
-export-dynamic
-Xlinker
--exclude-libs
-Xlinker
ALL
EOF
}
if [ "${ICU_STATIC_LIB}" == "TRUE" ]; then
use_local_iculibs
else
find_static_iculibs
fi
write_linkfile