Skip to content

zip: skip the entry name allocation when there is no add_path - #210

Closed
iliaal wants to merge 1 commit into
masterfrom
perf/zip-entry-name-no-alloc
Closed

zip: skip the entry name allocation when there is no add_path#210
iliaal wants to merge 1 commit into
masterfrom
perf/zip-entry-name-no-alloc

Conversation

@iliaal

@iliaal iliaal commented Jul 31, 2026

Copy link
Copy Markdown
Owner

php_zip_add_file() takes a char*/length pair, so without a prefix to concatenate the entry name was allocated and released once per file only to pass one through. Hand it file_stripped directly, and hold basename until after the call because file_stripped can point into it.

Measured on 4000 files with addGlob(): 22.2/22.2/22.8 ms patched against 23.8/22.2/22.1 ms before, so the saving is under the noise of the expand_filepath() and stat() the loop already does per entry. This is about the redundant work, not about a number.

@iliaal
iliaal force-pushed the perf/zip-entry-name-no-alloc branch from e72f433 to 8adcb24 Compare July 31, 2026 14:43
php_zip_add_file() takes a char*/size_t pair, so without a prefix to
concatenate the zend_string was allocated and released once per entry only
to pass one through. Pass file_stripped directly, and hold basename until
after the call because file_stripped can point into it.

Closes phpGH-22975
@iliaal
iliaal force-pushed the perf/zip-entry-name-no-alloc branch from 8adcb24 to 9b362a3 Compare July 31, 2026 14:44
@iliaal

iliaal commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

Promoted upstream as php#22975.

@iliaal iliaal closed this Jul 31, 2026
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