Repository navigation
Conversation
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.
I found that sentiment screening was embedding and classifying the same text repeatedly. In one 10,000-trace workload, 81,729 message occurrences contained only 28,319 distinct encoder inputs. At a batch size of 64, that means 1,278 embedding requests instead of 443.
I changed screen_user_messages to embed and classify each distinct effective input once per screening call, then copy the result back to every original occurrence. Matching uses the existing
text[:20000]encoder limit and preserves whitespace. Every message keeps its position and trace association, and each occurrence gets an independent result object. The original message evidence stays intact. Reuse is limited to that call; there is no persistent cache. Timing instrumentation is in PR #127.I estimate that the deduplication structures could add roughly 50–150 MB of peak memory for a 10,000-trace workload with 97,251 message occurrences and 69,034 unique embedding inputs. This is an estimate from the object structures and input counts; I have not measured memory usage. The extra memory holds lookup tables, unique embeddings, and cached classifications. Short message strings remain shared with the original input, while truncating long messages creates new strings that can add more: 1,000 distinct 20,000-character ASCII strings would use about 20 MB for their text alone. The per-occurrence output results were already required before this change.
I tested complete Compass runs with normal extraction, applicable signals, validation, and compilation. Each pair used the same input and model configuration:
Dataset A used the earlier combined optimization and tracing revision. Sentiment took 46m46s before and 30m16s after. Both runs produced six insights, but their findings and evidence differed. This was one sequential pair on a shared machine, and oversized exports dropped telemetry batches, so I cannot attribute the entire runtime difference to deduplication.
Dataset B used this PR's final deduplication-only revision. The after run crossed about 11 minutes of machine sleep and spent substantially longer in compilation. Its active timer was also slower: 48m54s versus 31m21s. Sentiment fell from 9m44s to 6m08s, but ethos remained the slowest signal. The baseline produced one valid insight; the after run produced three, including one invalid insight with only one supporting trace. These results do not establish an end-to-end speedup or equivalent insight quality.
Verified locally: The full suite passed on the final revision. Separate fixed-input screening comparisons preserved all message labels and trace flags. For Dataset B's identical extracted messages, requests fell from nine to two and screening took 4.1–4.3s versus 7.8–11.5s in two pairs with reversed execution order. Those measurements isolate screening savings; the complete-run results above describe the end-to-end behavior.