Skip to content
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

Feature/supercharger #95

Merged
merged 17 commits into from
Jan 16, 2025
Merged

Feature/supercharger #95

merged 17 commits into from
Jan 16, 2025

Conversation

justinwilaby
Copy link
Owner

@justinwilaby justinwilaby commented Jan 15, 2025

3x increase in speed - Major speed improvement

Drastic increase in performance over previous versions - both in speed and memory consumption

  1. Considerable reduction in the number of function calls for each iteration, minimizing the call stack size and complexity
  2. No longer copies graphemes as they are being processed on each write leading to decreased mem usage and overall increased performance
  3. Simplified branching statements to reduce cache misses and allow for better compiler optimizations
  4. Data sent across the FFI boundary is now read directly from structs within WASM memory using raw pointers (removed serialization which cloned a lot of bytes and was quite expensive)
  5. Moved to using raw bytes (u8) instead of String types in Rust eliminating Rust's internal grapheme boundary and broken surrogate checks (these are handled by sax-wasm at a low level)
  6. Whitespace between tags is intelligently skipped leading to a huge performance gain on large formatted documents with deeply nested tags

Breaking changes

  1. Data sent across the FFI boundary is not persisted unless toJSON() is called on the dispatched object. WASM data associated with each Tag, Attribute, ProcInst and Text objects received from the parsing operation have a 'lifetime' that is limited to the eventHandler() or the generator function loop body for *parse().
  • If you need to store your event data for use outside the eventHandler() or *parse() operation, use the object returned from the toJSON() function.
  • If you are getting junk when reading properties of the dispatched event data or are seeing both junk and slow reads, chances are you are accessing data outside the scope of the eventHandler() or *parse() operation and need to call toJSON() otherwise, this is not needed.
  1. On the Rust side, the event handler signature has been updated to use Enums that allow mutable references to the structs.
  2. TypeScript Types have been updated to better reflect data return from toJSON() calls.

@justinwilaby justinwilaby added enhancement New feature or request Documentation Documentation correctness/thouroughness issue labels Jan 16, 2025
@justinwilaby justinwilaby merged commit 8629e1b into master Jan 16, 2025
2 checks passed
@justinwilaby justinwilaby deleted the feature/supercharger branch January 16, 2025 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Documentation correctness/thouroughness issue enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant