From ba76567d3ee18f54fa3a400c607464e3f2c38588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Tue, 26 May 2026 20:01:51 +0100 Subject: [PATCH] Add native extension GitHub Pages demo --- index.html | 45 +++++++++++++++++++++++++ native-extension/benchmark.json | 36 ++++++++++++++++++++ native-extension/blueprint.json | 36 ++++++++++++++++++++ native-extension/index.html | 60 +++++++++++++++++++++++++++++++++ 4 files changed, 177 insertions(+) create mode 100644 index.html create mode 100644 native-extension/benchmark.json create mode 100644 native-extension/blueprint.json create mode 100644 native-extension/index.html diff --git a/index.html b/index.html new file mode 100644 index 00000000..d2fd33c1 --- /dev/null +++ b/index.html @@ -0,0 +1,45 @@ + + + + + +SQLite Database Integration + + + +
+
+

WordPress + SQLite + Native parser extension

+

SQLite Database Integration

+

Run WordPress on SQLite and try the optional native MySQL parser extension in your browser with WordPress Playground.

+Test in Playground +Native extension details +
+
+

Native PHP extension

wp_mysql_parser accelerates the MySQL lexer/parser path while keeping the pure-PHP implementation as the fallback.

+

WASM build

The Playground build is published as PHP 8.0–8.5 JSPI side modules and loaded with the php-extension query parameter.

+

Benchmarks

The demo page verifies that the extension is loaded and runs a small in-browser benchmark.

+
+
+ + diff --git a/native-extension/benchmark.json b/native-extension/benchmark.json new file mode 100644 index 00000000..eedb98b1 --- /dev/null +++ b/native-extension/benchmark.json @@ -0,0 +1,36 @@ +{ + "updated": "2026-05-26", + "environment": "Apple Silicon macOS, PHP 8.4.5 CLI, Rust release build of wp_mysql_parser loaded with php -d extension", + "artifact_manifest": "https://wordpress.github.io/sqlite-database-integration/wp_mysql_parser-wasm-extension/latest/manifest.json", + "results": [ + { + "name": "MySQL lexer", + "implementation": "Pure PHP", + "queries": 69577, + "duration": 0.9885420799255371, + "qps": 70383.44792084213, + "speedup": null, + "notes": "Measured by tests/tools/run-native-extension-benchmark.php --json." + }, + { + "name": "MySQL lexer", + "implementation": "Native extension", + "queries": 69577, + "duration": 0.20811200141906738, + "qps": 334324.7843736575, + "speedup": 4.7500484027105525, + "notes": "Measured by tests/tools/run-native-extension-benchmark.php --json with wp_mysql_parser loaded." + }, + { + "name": "MySQL parser", + "implementation": "Pure PHP", + "queries": 69577, + "duration": 9.678236961364746, + "qps": 7189.015962075475, + "speedup": null, + "failures": 9, + "exceptions": 0, + "notes": "Measured by tests/tools/run-parser-benchmark.php --json." + } + ] +} diff --git a/native-extension/blueprint.json b/native-extension/blueprint.json new file mode 100644 index 00000000..b5ab5355 --- /dev/null +++ b/native-extension/blueprint.json @@ -0,0 +1,36 @@ +{ + "$schema": "https://playground.wordpress.net/blueprint-schema.json", + "landingPage": "/native-extension-demo.php", + "meta": { + "title": "SQLite Database Integration: Native Parser Extension", + "description": "Loads the wp_mysql_parser WASM extension and runs a small in-browser benchmark.", + "author": "WordPress" + }, + "preferredVersions": { + "php": "8.4", + "wp": "latest" + }, + "features": { + "networking": true + }, + "login": true, + "steps": [ + { + "step": "installPlugin", + "pluginData": { + "resource": "url", + "url": "https://github.com/WordPress/sqlite-database-integration/releases/download/v3.0.0-rc.3/plugin-sqlite-database-integration.zip" + }, + "options": { + "activate": false, + "targetFolderName": "sqlite-database-integration" + }, + "ifAlreadyInstalled": "overwrite" + }, + { + "step": "writeFile", + "path": "/wordpress/native-extension-demo.php", + "data": " false, 'reason' => 'WP_MySQL_Lexer was not found in the installed plugin.');\n }\n $start = microtime(true);\n foreach ($workload as $query) {\n $lexer = new WP_MySQL_Lexer($query);\n $tokens = $lexer->remaining_tokens();\n if (count($tokens) === 0) {\n throw new Exception('Pure PHP lexer returned no tokens.');\n }\n }\n $duration = microtime(true) - $start;\n return array('available' => true, 'duration' => $duration, 'qps' => count($workload) / $duration);\n}\n\nfunction bench_native_lexer($workload) {\n if (!class_exists('WP_MySQL_Native_Lexer', false)) {\n return array('available' => false, 'reason' => 'WP_MySQL_Native_Lexer is not available. Check that the php-extension URL loaded before PHP started.');\n }\n $start = microtime(true);\n foreach ($workload as $query) {\n $lexer = new WP_MySQL_Native_Lexer($query);\n $tokens = $lexer->native_token_stream();\n if ($tokens->count() === 0) {\n throw new Exception('Native lexer returned no tokens.');\n }\n }\n $duration = microtime(true) - $start;\n return array('available' => true, 'duration' => $duration, 'qps' => count($workload) / $duration);\n}\n\n$error = null;\ntry {\n $php = bench_php_lexer($workload);\n $native = bench_native_lexer($workload);\n} catch (Throwable $e) {\n $error = $e->getMessage();\n $php = array('available' => false, 'reason' => $error);\n $native = array('available' => false, 'reason' => $error);\n}\n$speedup = (!empty($php['available']) && !empty($native['available'])) ? $native['qps'] / $php['qps'] : null;\n?>\n\n\n\n\nwp_mysql_parser Playground demo\n\n\n
\n

Native MySQL Parser Extension

\n

This Playground was opened with the published wp_mysql_parser WASM extension manifest.

\n
\n

Extension status

\n
    \n
  • Manifest: \">
  • \n
  • extension_loaded('wp_mysql_parser'): \">
  • \n
  • WP_MySQL_Native_Lexer: \">
  • \n
  • WP_MySQL_Lexer fallback: \">
  • \n
\n
\n
\n

In-browser lexer benchmark

\n

Workload: sample WordPress/MySQL queries.

\n\n\n\n
ImplementationStatusDurationQPS
Pure PHP lexer
Native WASM lexer
\n

Speedup: x

\n
\n
\n

Published benchmark data

\n
Loading \u2026
\n
\n

Open wp-admin

\n\n
\n" + } + ] +} diff --git a/native-extension/index.html b/native-extension/index.html new file mode 100644 index 00000000..57532b25 --- /dev/null +++ b/native-extension/index.html @@ -0,0 +1,60 @@ + + + + + +Native MySQL Parser Extension + + + +
+
+

wp_mysql_parser

+

Native MySQL Parser Extension

+

Load the published WASM build in WordPress Playground, verify the extension, and run a lightweight benchmark without installing anything locally.

+Test in Playground +View manifest +
+

Published artifacts

+ +

Latest published benchmark

+
Loading benchmark.json…
+

Reproduce locally

+
php tests/tools/run-lexer-benchmark.php
+php tests/tools/run-parser-benchmark.php
+php -d extension=/path/to/libwp_mysql_parser.so tests/tools/run-native-extension-benchmark.php
+ +
+ +