Skip to content

Instantly share code, notes, and snippets.

@nim65s
Created February 20, 2025 08:52
Show Gist options
  • Save nim65s/b605252a05cfea5d32a07d4576e3db3b to your computer and use it in GitHub Desktop.
Save nim65s/b605252a05cfea5d32a07d4576e3db3b to your computer and use it in GitHub Desktop.
pinocchio ROS build infos

time pinocchio build

on ros humble & jazzy, with gcc/clang & bfd/lld/mold

for dist in humble jazzy
do
    docker build --build-arg ROS=$dist -t timepin:$dist .
    docker run --rm -it timepin:$dist > $dist
done
./parse.py | tee results
ARG ROS_DISTRO=humble
FROM ros:$ROS_DISTRO
ARG ROS_DISTRO=humble
WORKDIR /src
ADD https://github.com/stack-of-tasks/pinocchio/releases/download/v3.4.0/pinocchio-3.4.0.tar.gz .
RUN tar xf "pinocchio-3.4.0.tar.gz" --strip-components=1
SHELL ["/bin/bash", "-eux", "-c"]
RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \
--mount=type=cache,sharing=locked,target=/var/lib/apt \
--mount=type=cache,sharing=locked,target=/root/.cache \
apt-get update -y && DEBIAN_FRONTEND=noninteractive apt-get install -qqy --no-install-recommends \
bc \
clang \
libboost-all-dev \
libeigen3-dev \
liburdfdom-dev \
lld \
mold \
python-is-python3 \
python3-numpy \
python3-pip \
python3-venv \
ros-$ROS_DISTRO-hpp-fcl \
ros-$ROS_DISTRO-eigenpy \
time \
&& python -m venv --system-site-packages --upgrade-deps /venv \
&& source /venv/bin/activate \
&& python -m pip install cmake
ENV CMAKE_PREFIX_PATH=/opt/ros/$ROS_DISTRO
ENV LD_LIBRARY_PATH=/opt/ros/$ROS_DISTRO/lib:/opt/ros/$ROS_DISTRO/lib/x86_64-linux-gnu
ENV ROS_PYTHON_VERSION=3 ROS_VERSION=2
RUN find /opt/ros/$ROS_DISTRO -name '*-packages' > $(find /usr/local/lib -name '*-packages')/ros.pth
# Wait, WHAT ?
RUN sed -i 's/hpp-fcl 2.1.2 REQUIRED "hpp-fcl >= 2.1.2"/hpp-fcl/' "CMakeLists.txt"
RUN source /venv/bin/activate \
&& for compiler in gcc clang; do \
for linker in BFD LLD MOLD; do \
for testing in ON OFF; do \
[[ "${compiler}" == "gcc" && "${linker}" == "MOLD" && "${ROS_DISTRO}" == "humble" ]] && continue; \
LOG="${compiler}-${linker}-${testing}.log"; \
cmake -B build \
-DBUILD_TESTING=${testing} \
-DBUILD_WITH_COLLISION_SUPPORT=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER="${compiler}" \
-DCMAKE_CXX_COMPILER="${compiler/cc}++" \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_LINKER_TYPE="${linker}" \
-DPYTHON_DEB_LAYOUT=ON \
-Wno-dev; \
/usr/bin/time -v cmake --build build 2>> $LOG; \
echo -ne "\ttotal-size: " >> $LOG; \
find build -name \*.so -exec sh -c 'stat -c %s $(realpath {})' \;| xargs | tr ' ' + | bc >> $LOG; \
cmake --build build -t install; \
echo -ne "\tpinocchio: " >> $LOG; \
(python -c "import pinocchio; print('ok')" 2>&1 || true) >> $LOG; \
cmake --build build -t uninstall; \
rm -rf build; \
done; \
done; \
done
CMD tail -n 30 *.log
#!/usr/bin/env python
import pandas as pd
TIME = " Elapsed (wall clock) time (h:mm:ss or m:ss): "
MRSS = " Maximum resident set size (kbytes): "
SIZE = " total-size: "
PINO = " pinocchio: "
compiler = ""
linker = ""
testing = ""
time = 0
dists = []
compilers = []
linkers = []
testings = []
times = []
mrsss = []
sizes = []
pinos = []
for dist in ["humble", "jazzy"]:
with open(dist) as f:
for line in f.readlines():
match line:
case line if "==>" in line:
compiler, linker, testing = (
line.split()[1].removesuffix(".log").split("-")
)
case line if line.startswith(TIME):
m, s = line.removeprefix(TIME).strip().split(":")
time = int(m) * 60 + float(s)
case line if line.startswith(MRSS):
mrss = int(line.removeprefix(MRSS).strip())
case line if line.startswith(SIZE):
size = int(line.removeprefix(SIZE).strip())
case line if line.startswith(PINO):
pino = line.removeprefix(PINO).strip()
dists.append(dist)
compilers.append(compiler)
linkers.append(linker)
testings.append(testing)
times.append(time)
mrsss.append(mrss)
sizes.append(size)
pinos.append(pino)
arrays = [dists, compilers, linkers, testings]
tuples = list(zip(*arrays))
index = pd.MultiIndex.from_tuples(
tuples, names=["dist", "compiler", "linker", "testing"]
)
df = pd.DataFrame(
{"time": times, "mrss": mrsss, "size": sizes, "import": pinos}, index=index
)
print(df)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment