This repository has been archived by the owner on Nov 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Optimize expensive XPath expressions in HTML transform #165
Merged
eyelidlessness
merged 7 commits into
enketo:master
from
eyelidlessness:performance/expensive-xpath-exprs
Feb 7, 2023
Merged
Optimize expensive XPath expressions in HTML transform #165
eyelidlessness
merged 7 commits into
enketo:master
from
eyelidlessness:performance/expensive-xpath-exprs
Feb 7, 2023
Commits on Feb 6, 2023
-
Add snapshot tests to catch regressions not covered in tests
This commit has been cherry picked from its original appearance in enketo#164, with the following changes: - Include all enketo-core fixtures in preparation for adding benchmarks to establish a performance baseline. - Temporarily increase the timeout for snapshot tests so that the longer running enketo-core fixtures can generate initial snapshots. - Restore test shuffling (turning that off was a mistake in the original TypeScript PR). - Switch the default test reporter to `dot` to improve visibility of progress during test runs (it's still not great, mainly due to performance). - Move `linkedom` stuff to `/test/shared.ts` as it will only be used in tests. - Accept updates to `package-lock.json` with SHA-512 integrity hashes. - Excludes formatting of XML/XSL. About snapshot serialization: Snapshots use a custom serializer designed to identify only meaningful differences. This means that a snapshot matches if: - the value is exactly equal - the value is equal, apart from insignificant changes to whitespace and/or attribute order The serialization logic: 1. Manually ensures consistent attribute order (using `linkedom` as a DOM compatibility library, primarily because its types are much better than those for `@xmldom/xmldom`). 2. Uses `prettier` to normalize whitespace. 3. Uses `pretty-format` (`vitest`'s default) for final serialization. Apart from adding snapshots, tests have been updated to reference `linkedom`'s types (corrected where necessary) and to its behavior (which is semantically equivalent to the previous `@xmldom/xmldom` usage, but more consistent with a real DOM environment).
Configuration menu - View commit details
-
Copy full SHA for 485730c - Browse repository at this point
Copy the full SHA 485730cView commit details -
This is almost entirely different from the original in enketo#164. Instead it: - uses benchmark.js rather than implementing our own - mostly defers to benchmark.js stats logic for reporting - skips `@actions/core` for generating the GitHub Actions summary, it wasn't really doing a lot for us
Configuration menu - View commit details
-
Copy full SHA for 3048222 - Browse repository at this point
Copy the full SHA 3048222View commit details
Commits on Feb 7, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 0f826fb - Browse repository at this point
Copy the full SHA 0f826fbView commit details -
Optimize expensive XPath expressions in HTML transform
This should have little impact on forms which already transform quickly, but it dramatically improves the time to transform forms which are particularly slow. In my testing, this is especially the case for forms with a large number of translations/itext values. The improvement comes from using `xsl:key` elements to reference the expressions identified as expensive, and to look them up with the corresponding `key` XPath function. My strong assumption is that the reason this has such a big impact is that the non-key references are rerun on each visit to their respective `xsl:template` or upon each reference to a top-level `xsl:variable`, whereas `key` presumably pre-caches the expression's nodeset and only filters based on the `use` argument.
Configuration menu - View commit details
-
Copy full SHA for a450673 - Browse repository at this point
Copy the full SHA a450673View commit details -
Configuration menu - View commit details
-
Copy full SHA for ba6f59a - Browse repository at this point
Copy the full SHA ba6f59aView commit details -
Fix: ensure snapshots match when version matches the current package.…
…json version Otherwise snapshots will not match as soon as we prepare release
Configuration menu - View commit details
-
Copy full SHA for 004d045 - Browse repository at this point
Copy the full SHA 004d045View commit details -
Fix: prepare script ensures build before release
This has been validated locally in enketo-core and enketo-transformer using `npm link`.
Configuration menu - View commit details
-
Copy full SHA for 03fbafa - Browse repository at this point
Copy the full SHA 03fbafaView commit details
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.