Repository navigation
perf(app): mine Event Patterns with the TypeScript Drain port instead of Pyodide - #6
Draft
karljohang wants to merge 4 commits into
Draft
karljohang wants to merge 4 commits into
karljohang wants to merge 4 commits into
Conversation
… of Pyodide Event Patterns loaded a 14 MB Python runtime and ran drain3 in it on the main thread, freezing the page for up to 760 ms on first use (1.3 s on a 4x throttled CPU). The TypeScript port the CLI and MCP server already use gives the same clusters and templates and mines 10,000 lines in under 50 ms. The port masks dates by default since ClickHouse#3551, so the app clears the masks to match drain3's default config. With punctuation delimiters a masked date is one word where the log has three, which would misalign the pattern display, Denoise and pattern filters. mineEventPatterns.test.ts checks that dates stay unmasked.
Event Patterns now mines with the TypeScript Drain port, which splits on JS `\s`. Pattern filters still split on Python's str.split() whitespace, so an event with a BOM between words fell out of an include filter of its own pattern, and one with \x1e or NEL matched a pattern it was never mined into. Filters built before this change still filter the same and still read back as pattern filters. The filter options now sit next to the shared delimiter list in drainDelimiters.ts. The list was already shared, but the filter's whitespace was set on its own, so nothing moved it when the miner did.
…mplate patternFilter.test.ts mines two JSON lines and two that start with dates, and checks that every template's filter and Denoise matcher match every line mined into it. Putting back the default date masks fails both tests.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Event Patterns ran
drain3inside Pyodide on the main thread: a 14 MB Python runtime that froze the page for up to 760 ms on first use (1.3 s on a 4× throttled CPU). It now mines with the TypeScript Drain port incommon-utils, which the CLI and MCP server already use. It gives the same clusters and templates asdrain3, and it mines 10,000 lines in under 50 ms.drain3's default config; otherwise a masked date is one token where the log has three, which misaligns the pattern display, Denoise, and pattern filters.mineEventPatterns.test.tschecks that dates stay unmasked.str.split()whitespace to matchdrain3. They now split on JS\s, like the miner, so an event with a BOM between words no longer falls out of an include filter for its own pattern. Filters saved underdrain3still apply and still read back as pattern filters. The filter options now sit next to the shared delimiter list indrainDelimiters.ts, so the miner and the filters can't drift apart again.patternFilter.test.tsmines JSON lines and dated lines and checks that every template's filter and Denoise matcher match every line mined into it._document.tsxstill loadspyodide.js; a follow-up removes it and the unused runtime and wheels.Screenshots or video
No visual change.
How to reproduce
Starting point:
yarn app:dev:localconnected to the demo server (onboarding → "Connect to Demo Server").On
main:/searchwith a logs source.pyodide.asm.wasm,python_stdlib.zip, and thedrain3andjsonpicklewheels download, and the page freezes while they load and mining runs.On this branch:
How to test on Vercel preview
Preview routes: /search
Steps:
References