# Measurement

> Produces numbers: method, environment and metrics are on the record.

- Record count: 8
- Source: https://www.muhammetsafak.com.tr/en/research/kind/measurement/
- Language: en-US
- Author: Muhammet Şafak

---
## Findings ledger

### Laravel's preload curve: 123 files buy eight times what the last 1,912 do

- Question: How far can a curated preload take Laravel, and what does each slice cost in start-up time?
- Finding: The curve is not proportional to volume. The first 1,592 files — Laravel's own framework — buy 30 ms and add 1.2 seconds to start-up. The next 1,094 Symfony files buy 9.5 ms for free. The **123 files** after that (psr, carbon) buy 15.7 ms, more than the 1,094 before them. And the last 1,912 buy 1.8 ms while adding another 1.2 seconds. So the blanket preload the earlier record measured as a ceiling is the worst point on the curve that is not the origin: stopping at 2,809 files gives 12.77 ms for 1,514 ms of start-up, while 4,721 files ask 2,691 ms to reach 10.96 ms.
- https://www.muhammetsafak.com.tr/en/research/laravel-preload-curve/
- Markdown: https://www.muhammetsafak.com.tr/en/research/laravel-preload-curve.md

### A partial index makes a queue table forty-one times smaller — for as long as the planner picks it

- Question: On a Postgres queue table with millions of dead rows, what does a partial index buy, and when does the planner refuse to use it?
- Finding: At 10 million dead rows a partial index sustains 11,537 claims per second where the same table without one manages 7. Against a composite index the throughput difference is small (6.9%) but the size difference is not: 7.6 MB against 310.4 MB, and the partial one does not grow with the table because it indexes only the 5,000 live rows. None of that is the real finding. The moment the planner switches a prepared statement to a generic plan the partial index stops being used at all — 11,752 tps becomes 7, and 0.68 ms becomes 1.1 seconds. A factor of 1,673. The composite index is untouched under the same conditions.
- https://www.muhammetsafak.com.tr/en/research/partial-index-queue-table/
- Markdown: https://www.muhammetsafak.com.tr/en/research/partial-index-queue-table.md

### The partial index grew three hundred and eighty times in fifteen minutes — and autovacuum never ran

- Question: Under sustained churn, does a partial index stay small on a queue table, and do the default autovacuum settings keep up with it?
- Finding: With the live set holding steady at five thousand rows the partial index went from 0.1 MB to 38.2 MB — three hundred and eighty times. Its smallness comes from the live set, its bloat rate comes from throughput, and nothing connects the two. The composite index bloated less in proportion (42%) and more in absolute terms (+126 MB), and while bloating it stopped fitting in memory: its latency went from 0.52 ms to 61 seconds and its backlog climbed to 126,000. Fifteen minutes produced 1.75 million dead rows and autovacuum **did not run once** — the default threshold scales with the whole table (50 + 0.2 × 10 million ≈ 2 million) while the churn happens in a tiny subset.
- https://www.muhammetsafak.com.tr/en/research/queue-table-bloat-and-autovacuum/
- Markdown: https://www.muhammetsafak.com.tr/en/research/queue-table-bloat-and-autovacuum.md

### Postgres never turned the partial index into a generic plan: forty executions, forty custom plans

- Question: Does Postgres switch a partial-index query to a generic plan on its own inside a prepared statement — or is the 1,673-fold cliff something you have to opt into?
- Finding: Postgres declines. On the partial index all forty executions used a custom plan — the counter reads 40/0. The reason it declines is the disaster itself: a generic plan cannot use the partial index, so its estimated cost comes out high and the planner does not choose it. The composite index switches at the sixth execution exactly as documented (5/35) and loses nothing by it. So the 1,673-fold cliff is real but fenced: reaching it takes writing `plan_cache_mode = force_generic_plan`.
- https://www.muhammetsafak.com.tr/en/research/when-does-the-planner-go-generic/
- Markdown: https://www.muhammetsafak.com.tr/en/research/when-does-the-planner-go-generic.md

### How you import Chart.js decides how many kilobytes the visitor downloads

- Question: In a real production build, what is the difference between `chart.js/auto` and a selective `Chart.register()` — in kilobytes?
- Finding: Selective registration saves 9.7 kB gzip over `chart.js/auto` (67.8 → 58.1 kB, 14.3%). The larger drop is not in the library core but in leaving unused controllers out: a page that registers only the bar chart falls to 46.0 kB — two thirds of auto.
- https://www.muhammetsafak.com.tr/en/research/chartjs-import-strategy/
- Markdown: https://www.muhammetsafak.com.tr/en/research/chartjs-import-strategy.md

### opcache preload cuts the deploy bill by up to fourteen times — but five of seven frameworks do not hand it to you

- Question: With `opcache.preload` on, how long is the first request seven PHP frameworks serve after a deploy, what does the gain cost, and who can actually have it?
- Finding: Preload shortens the cold first request by between 3.5× and 14.2×: Symfony drops from 35.58 ms to 2.50 ms, down to Phalcon's bare figure. But only two of the seven candidates — Symfony and CodeIgniter — publish a preload file of their own; for the other five the gain sits on the table waiting for the user to write one. Writing one is not as easy as it looks: a preload generated blindly from the classmap never brings Symfony up at all, and on CodeIgniter it does worse (5.29 ms) than the hand-picked official file (3.13 ms). And the cost does not vanish: Laravel's classmap preload takes the 62 ms it saves each visitor and writes it back as 2,340 ms of php-fpm start-up.
- https://www.muhammetsafak.com.tr/en/research/opcache-preload-deploy-bill/
- Markdown: https://www.muhammetsafak.com.tr/en/research/opcache-preload-deploy-bill.md

### The fixed cost of installing a PHP framework: disk size tells you nothing

- Question: How many megabytes on disk, how many files per request and how many milliseconds on the first request do seven PHP frameworks cost — and which of those numbers actually predicts throughput under load?
- Finding: Disk size predicts nothing: Yii2 has the largest vendor tree at 34.1 MB and loads only 62 files per request, among the fewest in the field. Files per request predicts nothing either: CodeIgniter loads 96 files and serves 6,431 req/s, Symfony loads 224 and serves 13,067. The one number that genuinely separates them is the first request served with a cold opcache: 2.2 ms for Phalcon, 72.2 ms for Laravel — thirty-three times. That is the compile bill the first visitor pays after every deploy, and it is measured in tens of milliseconds, not kilobytes.
- https://www.muhammetsafak.com.tr/en/research/php-framework-footprint/
- Markdown: https://www.muhammetsafak.com.tr/en/research/php-framework-footprint.md

### Seven PHP frameworks under identical load: the gap narrows as soon as the request does real work

- Question: On the same hardware, the same PHP build and the same seven routes, how many requests a second do Laravel, Symfony, CodeIgniter, Yii2, Phalcon, Laminas and Slim serve, and at what latency?
- Finding: On an empty route the fastest is 4.4× the slowest (Slim 25,975, Laravel 5,966 req/s). As soon as the request does real work the gap closes: 3.7× for a single row from the database, 3.5× for twenty rows. Phalcon is third on an empty route and fifth once a query is involved — being a C extension buys nothing while the process waits on MySQL. And the expensive decision is not the framework: Laravel's own default `web` middleware group takes the same response from 5,858 to 2,176 req/s, so one default costs more than most of the distance between the frameworks.
- https://www.muhammetsafak.com.tr/en/research/php-framework-load-test/
- Markdown: https://www.muhammetsafak.com.tr/en/research/php-framework-load-test.md
