Repository navigation
Speed up import preflight and SQLite inserts (0.8.1) - #18
Conversation
The shared SQL preflight ran up to eight namespaced is_*/is_finite calls per cell. Branch on the value type first, so a numeric cell costs two type tests and one finiteness test. Rules, order and messages are unchanged for list rows; a new data-provider test pins each rejection and its order and passes against both the old and the new loop. The SQLite importer bound every cell through a named placeholder. Use positional placeholders with the same values and encoding. 50k x 201 SAV, SQLite: preflight 2.5s -> 0.9s, import 19-20s -> 12-13s.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Follow-up to the Python finding that SAV import spent most of its time in per-cell validation. This checks whether the PHP adapter has the same problem and fixes the parts that measured as real.
What profiling showed (50,000 cases x 200 numeric + 1 string var, value labels, 10 MB SAV)
AbstractPdoSqlProfile::assertDatasetpreflightcaseRows/caseValue)PreparedCaseBatchsize bookkeepingThe PHP adapter has the same pattern but a much smaller share than Python: the preflight was 11-13% of a SQLite import and about 4% of a Dolt import. MySQL and PostgreSQL already batch rows. SQLite bound each cell through a named placeholder, and that was the biggest PHP-side cost.
What changed
AbstractPdoSqlProfile::assertDataset): the old loop ran up to eight namespacedis_*/is_finitecalls per cell. These calls are resolved at runtime, so the compiler cannot turn them into type-check opcodes. The new loop branches on the value type first, so a numeric cell costs two type tests and one finiteness test. A microbenchmark on the same 10M cells: 2.46 s -> 0.93 s. The@paramfor rows now sayslist<array<mixed>>, because this method is the type gate for untrusted cells.insertCases: switched from named to positional placeholders. The values,Binary64encoding and the null-string guard are unchanged.What was kept, and why
SpssEngineis pluggable. php-spssDatasetdocuments that "string nullability is validated by the SAV adapter". php-spss can also return non-finite doubles.testPreflightRejectsInvalidCellsInSourceOrderdata provider passes against both the old and the new loop. One difference: name-keyed rows (outside the documentedlist<list<...>>contract, and already raising "Undefined array key" warnings in preflight) now get numeric type and finiteness checks in preflight instead of later. They can only be rejected earlier, never accepted where they used to be rejected.caseValuere-checks in MySQL/PostgreSQL were kept. Removing them saves about 0.2 s. They are the only check for name-keyed rows.PreparedCaseBatchrow sizing was kept. It measures encoded wire bytes for grouping, which is not the preflight quantity. Computing it with builtins saved only 0.12 s.Timings (same file, same machine,
SpssAdapter::import)Checks
composer checkon the staged tree (validate, lint, php-cs-fixer, phpstan level 8, phpunit): 769 tests OK, 112 skipped (server DSNs not set), with the specification pinned at864e844.dolthub/dolt-sql-server:2.2.3: 99 tests OK, 48 skipped.No version bump, tag or release.
Summary by CodeRabbit