Skip to content

packaging: one chmod spawn per file costs ~6.5s per package #238

Closed

Description

@jwinarske

package_stager.dart:65 spawns one chmod per extra file that has a mode — and expandPackageFiles assigns a mode to every swept file even when the manifest sets none (package_files.dart:133, e.mode ?? modeOf(f)).

Measured on a 2000-file asset tree:

files=2000 modes=2000
chmod invocations: 2001
200 real chmod spawns: 657 ms  =>  2001 spawns ≈ 6573 ms

That is ~6.5 s of pure fork/exec per package, multiplied by formats × backends: deb + ipk + rpm + tarball across 5 backends is roughly two minutes of spawning.

Fix: group destinations by mode and issue one chmod <mode> f1 f2 … per distinct mode, chunked for argv length — typically 2-3 spawns instead of thousands.

Nothing else on that path is O(n²): expandPackageFiles is a single walk, no file is hashed twice, and the per-file statSync/typeSync are unavoidable.

Found while reviewing #227.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions