#1103221 needrestart is slow with /dev/shm/bazel-sandbox...

#1103221#5
Date:
2025-04-15 01:06:55 UTC
From:
To:
Dear Maintainer,

   * What led up to the situation?

I did a `bazel build //... --sandbox_base=/dev/shm` on a repo and
then `apt-get update; apt-get ugprade`

(https://github.com/RealtimeRoboticsGroup/aos, but I have seen nothing
 which indicates it is specific to that repo)

   * What exactly did you do (or not do) that was effective (or
     ineffective)?

needrestart is then very slow to check if anything needs a restart.
Like 30 seconds to 1 minute slow.

   * What was the outcome of this action?

Slow updates

   * What outcome did you expect instead?

I expect needupdate to be fast.

When it was slow, I attached to needupdate with strace, and looked at
what it was doing.  I saw it iterating through all the files in
/dev/shm/bazel-sandbox.[hash], which makes me suspect it is looking for
PIDs in there or something like that.

I believe I've also seen this on Ubuntu 22.04.

strace needrestart ->
...
newfstatat(AT_FDCWD, "/dev/shm/bazel-sandbox.1a8fd8fe52184f204b77ecb09e16bedf91b97f6f4e780924d561d9f0b2bd820d/sandbox_stash/CppCompile/6395/execroot/aos/external/amd64_debian_sysroot/usr/lib/tasksel/tests/laptop", {st_mode=S_IFREG|0755, st_size=259, ...}, 0) = 0
newfstatat(AT_FDCWD, "/dev/shm/bazel-sandbox.1a8fd8fe52184f204b77ecb09e16bedf91b97f6f4e780924d561d9f0b2bd820d/sandbox_stash/CppCompile/6395/execroot/aos/external/amd64_debian_sysroot/usr/lib/tasksel/tests/laptop", {st_mode=S_IFREG|0755, st_size=259, ...}, 0) = 0
...