-
Notifications
You must be signed in to change notification settings - Fork 0
docs: record footprint and performance metrics #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+127
−0
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c33fd45
docs: record footprint and performance metrics
dknauss 3e619e3
docs: correct wp_options and packages/ footprint claims
dknauss dec30ba
docs: refine transient-cache and DOI-cache accuracy
dknauss 863a6d8
docs: make PHP LOC and footprint metrics clean-checkout reproducible
dknauss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| # Current metrics | ||
|
|
||
| Hand-verified size, footprint, and runtime-overhead metrics for Borges Bibliography Builder. | ||
| Each number carries the exact command used to re-derive it, so the figures can be re-checked | ||
| on demand rather than trusted on faith. Re-run the relevant command and update the number **in | ||
| the same commit** whenever the underlying quantity changes. | ||
|
|
||
| Last verified: **2026-07-05** against `main` (commit `49f623b`). | ||
|
|
||
| ## Lines of code | ||
|
|
||
| | Metric | Value | Re-derivation command | | ||
| |---|---|---| | ||
| | Main plugin file (`bibliography-builder.php`) | **1,881** | `wc -l bibliography-builder.php` | | ||
| | All first-party PHP (excl. vendor, tests, scripts, packages, output, node_modules, generated `build/`) | **1,979** | `find . -name '*.php' -not -path './vendor/*' -not -path './node_modules/*' -not -path './tests/*' -not -path './packages/*' -not -path './scripts/*' -not -path './output/*' -not -path './build/*' -print0 \| xargs -0 wc -l \| tail -1` | | ||
| | JS source (`src/`, excl. `*.test.js`) | **8,851** | `find ./src -name '*.js' -not -name '*.test.js' -print0 \| xargs -0 wc -l \| tail -1` | | ||
| | Shipped frontend runtime (`build/view.js`, minified) | **1,449 bytes** | `npm run build` then `wc -c < build/view.js` | | ||
|
|
||
| The only PHP that executes at runtime on a visitor request path is `bibliography-builder.php` | ||
| (REST registration + block registration); the CSL formatting engine under `vendor/` runs | ||
| **only** for editor-time REST calls. `scripts/*.php` are dev tooling and are not packaged. | ||
|
|
||
| ## Storage footprint (installed) | ||
|
|
||
| Measured from a full release build (`npm run package:release`), which copies the shipped | ||
|
dknauss marked this conversation as resolved.
|
||
| files and installs runtime Composer dependencies with `--no-dev`, then prunes tests/docs/images | ||
| from `vendor/`. | ||
|
|
||
| **Prerequisite:** `build/` is gitignored (produced by `npm run build`), and | ||
| `scripts/package-release.sh` copies it, so run **`npm run build`** first on a clean checkout — | ||
| otherwise `package:release` (and the `du -sh build` row below) fails with `cannot stat build`. | ||
|
|
||
| | Component | Size | Re-derivation command | | ||
| |---|---|---| | ||
| | `vendor/` — citeproc-php engine + `seboettg/collection` + `myclabs/php-enum` + curated `citation-style-language/styles` & `/locales`, pruned | **~1.0 MB** | `du -sh output/release/borges-bibliography-builder/vendor` (after `npm run package:release`) | | ||
| | `languages/` — seed PO/MO/JSON translations | **724 KB** | `du -sh languages` | | ||
| | `build/` — editor + frontend assets | **328 KB** | `du -sh build` | | ||
| | PHP + `block.json` + `readme.txt` + `LICENSE` + `THIRD-PARTY-NOTICES.txt` | **~100 KB** | — | | ||
| | **Total installed** | **~2.1 MB** | `du -sh output/release/borges-bibliography-builder` (after `npm run package:release`) | | ||
| | Distributed ZIP (compressed) | **~0.9–1 MB** | `du -h output/release/borges-bibliography-builder.zip` | | ||
|
|
||
| The source tree's `packages/` directory (60 KB) is **not** a separate shipped component: the | ||
| release script (`scripts/package-release.sh`) Composer-installs those path packages into | ||
| `vendor/citation-style-language/*` and then deletes the staged `packages/` (`rm -rf`). The | ||
| curated CSL styles are therefore counted inside the `vendor/` figure above. | ||
|
|
||
| Notes: | ||
| - `vendor/seboettg/citeproc-php` is **3.2 MB** unpruned and **~536 KB** after the release | ||
| script strips tests/docs. The pruning is what keeps the installed footprint near 2 MB. | ||
| - The bundled `citation-style-language/styles` is a **curated subset** (the nine styles the | ||
| plugin ships), not the full upstream repository (~40 MB). This is a deliberate footprint | ||
| control, not an accident of packaging. | ||
|
|
||
| ## Runtime / query overhead | ||
|
|
||
| The block uses **static `save()` output with no `render_callback`** — formatted bibliography | ||
| HTML, JSON-LD, and COinS are serialized into `post_content` at edit time. The visitor request | ||
| path therefore adds **zero** database queries and **zero** citeproc/PHP formatting work. | ||
|
|
||
| | Overhead on the frontend (per published page) | Value | Re-derivation | | ||
| |---|---|---| | ||
| | Additional database queries | **0** | Static save; nothing on the block runs on the frontend — see audit below | | ||
| | REST calls | **0** | `POST /format` and `GET /pmid/{pmid}` fire only in the editor | | ||
| | `render_callback` invocations | **0** | Block registers no server render | | ||
| | Autoloaded options / registered settings | **0** | No `add_option`/`update_option`/`register_setting` | | ||
| | Cron events | **0** | No `wp_schedule_event` | | ||
| | Custom post types / custom tables | **0** | No `register_post_type` / `dbDelta` | | ||
| | Enqueued frontend assets (only when block present) | `view.js` ~1.4 KB + `style-index.css` ~2.9 KB | `wc -c build/view.js build/style-index.css` | | ||
|
|
||
| Persistence/hook audit — no persistent settings, options, cron, CPTs, or custom tables | ||
| (expected output: **NONE**): | ||
|
|
||
| ``` | ||
| grep -rEl "add_option|update_option|register_setting|register_post_type|dbDelta|wp_schedule_event" \ | ||
|
dknauss marked this conversation as resolved.
|
||
| --include='*.php' . | grep -vE 'vendor|tests|node_modules' | ||
| ``` | ||
|
|
||
| **One caveat on `wp_options`.** On every store, the plugin's editor-time cache | ||
| (`bibliography_builder_cache_set()`) calls **both** `wp_cache_set()` and `set_transient()` — | ||
| they are two independent `if ( function_exists() )` guards, not an object-cache-else-transient | ||
| fallback. With a persistent object cache drop-in active, `set_transient()` also routes to the | ||
| object cache and **no** option row is written; without one, it materializes | ||
| **non-autoloaded, expiring** `_transient_bbb_*` rows in `wp_options`. Either way the write | ||
| happens **only during editor REST calls** (`/format`, `/pmid`) as short-lived caches of | ||
| upstream lookups — never on a visitor request, and never added to the autoload set. So there | ||
| are no long-lived settings and nothing on the autoload path, but "zero rows ever touch | ||
| `wp_options`" would be inaccurate on a site without an external object cache. (DOI imports are | ||
| deduped separately in a browser-session JS `Map` in `src/lib/parser.js` and never reach this | ||
| PHP cache.) | ||
|
|
||
| The "average queries per page" figure is a flat **0 additional queries**, independent of the | ||
| number of bibliography blocks or citations on the page — all expensive resolution (Crossref | ||
| DOI, NCBI/PMC PMID) and CSL formatting happens at edit time and never touches a visitor. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.