Skip to content

Reuse the buildroot snapshot when packing libraries - #1306

Closed
andreybolonin wants to merge 1 commit into
crazywhalecc:v3from
andreybolonin:perf/share-buildroot-snapshot
Closed

andreybolonin wants to merge 1 commit into
crazywhalecc:v3from
andreybolonin:perf/share-buildroot-snapshot

Conversation

@andreybolonin

Copy link
Copy Markdown

What does this PR do?

With tracking enabled, dev:pack-lib takes two snapshots of the same buildroot before each package build. Give the pack stage a clone of the tracker's snapshot so both share the baseline file list. Each consumer still scans for additions at its original point in the lifecycle, and resetting the packing snapshot leaves the tracking baseline intact. Packing with tracking disabled still takes its own baseline.

The change applies to the package installer across platforms and requires no recipe, toolchain, or documentation changes. The regression test covers independent snapshot resets and file additions between the packing and tracking scans.

On macOS arm64 with PHP 8.6.0, a benchmark with 20,000 files and 12 snapshot-and-diff cycles per run reduced median time from 3.39 s to 2.55 s (−25%) and median peak RSS from 32.3 MiB to 31.0 MiB (−4%). The benchmark measures the snapshot work only.

Checklist before merging

  • composer cs-fix -- --sequential
  • composer analyse
  • composer test (486 tests)
  • bin/spc dev:lint-config

Validation ran on macOS arm64 with PHP 8.6.0. Full static builds, end-to-end packing time, and other host platforms were outside the local validation.

@crazywhalecc

Copy link
Copy Markdown
Owner

We do not oppose using AI to complete optimization. But regardless of the content of the modification, I still recommend that before submitting the PR, either be able to provide effective "human confirmation", or only include the necessary build-related fixes.

For a large number of unrelated functions that are worth slightly modifying, I suggest merging several PR (only of the same type, like "cli performance") to complete this task, and provide real data to support it.

@andreybolonin

Copy link
Copy Markdown
Author

static-php-cli have many chances to perf gain
What difference does it make how it gets fixed?
Separate PR easy to revert, if needed

@crazywhalecc

Copy link
Copy Markdown
Owner

Review for #1306

It is a safe but it is just a safe change, also virtually useless. We could certainly review and merge it quickly, but it offers no benefit to our core functionality (in terms of the build process).

Review for #1307

This is a useful point, though it warrants further triage. In our CI, we use --version to verify that the initialization process is complete. While this might cause errors in certain edge cases to be overlooked, it does effectively resolve secondary issues—such as the duplication of logs that occurs when --version is executed repeatedly.

However, before proceeding, I would like to understand how this optimization serves your objectives—rather than simply implementing it without any clear rationale.

Review for #1308

Similar to #1306, but slightly more useful, can be merged.

@henderkes henderkes closed this Nov 29, 2026
@henderkes

Copy link
Copy Markdown
Collaborator

static-php-cli have many chances to perf gain What difference does it make how it gets fixed? Separate PR easy to revert, if needed

I don't mind tickling the slop machine for gain, but this is just bloating code and maintenance and stealing reviewers time for no gain whatsoever. It doesn't matter if SPC is even 100ms faster after all your optimizations.

There are very meaningful optimizations that can be explored, tested, and proposed with some effort. For example skipping builds of extensions or sapis that would lead to byte-identical output. Or even running multiple configures at once, in parallel, done in a smart way to minimise build times of libraries. But all this is just meaningless noise. 100 milliseconds, in the matter of a 30-2h compilation time, are noise.

@andreybolonin

Copy link
Copy Markdown
Author

@henderkes just do nothing ) and use this slow lib
I go to work on replace on Go, maybe

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.

3 participants