[php-src] PR #23460: Fix GH-23457: imagebmp() is extremely slow when writing to a file
| From: | lazerg | Date: | Tue, 25 Aug 2026 18:21:57 +0000 |
| Subject: | [php-src] PR #23460: Fix GH-23457: imagebmp() is extremely slow when writing to a file | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-38138@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/23460
Author: lazerg
imagebmp() writes its pixel data a byte at a time, and the gd stream context turned each of those
bytes into its own php_stream_write() call. PHP streams do no write buffering, so a 1920x1080
truecolor image cost about six million write syscalls. libgd's own FILE context does not show
this because stdio buffers for it.
Buffering the stream context in 8 KB chunks takes that image from 9.5s to 0.02s here, with
byte-identical output. imagewbmp(), imagegd(), imagegd2() and imagexbm() go through the same context
and were writing per byte too.
Fixes #23457