Skip to content

[assemble_cvd] Replace slow lsof for file cleanup#2489

Open
bridadan wants to merge 1 commit intogoogle:mainfrom
bridadan:optimize_prior_files_check
Open

[assemble_cvd] Replace slow lsof for file cleanup#2489
bridadan wants to merge 1 commit intogoogle:mainfrom
bridadan:optimize_prior_files_check

Conversation

@bridadan
Copy link
Copy Markdown
Collaborator

CleanPriorFiles called lsof to ensure files weren't in use before deletion, but this was taking ~5 seconds, significantly slowing down startup. lsof was slow because it scanned all processes on the system and performed name resolutions by default.

Replacing it with a targeted C++ scan of /proc/*/fd for the current user's processes avoids these overheads and reduces the execution time to ~132 ms.

Bug: 401259067
Test: cvd create
check launcher.log for ~5s speed up to UBOOT start

CleanPriorFiles called lsof to ensure files weren't in use before
deletion, but this was taking ~5 seconds, significantly slowing down
startup. lsof was slow because it scanned all processes on the
system and performed name resolutions by default.

Replacing it with a targeted C++ scan of /proc/*/fd for the current
user's processes avoids these overheads and reduces the execution time
to ~132 ms.

Bug: 401259067
Test: cvd create
      check launcher.log for ~5s speed up to UBOOT start
@bridadan bridadan requested a review from Databean April 30, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant