Only load the taint store when there is something to mark - #222
Open
asamassekou10 wants to merge 1 commit into
Open
Only load the taint store when there is something to mark#222asamassekou10 wants to merge 1 commit into
asamassekou10 wants to merge 1 commit into
Conversation
_get_taint() reads the session's taint file from disk, but it was called unconditionally on every evaluate() — while only events that carry a prompt-injection finding ever mark. Every other event paid a file read for nothing. Test the cheap in-memory condition first and load the store only when it will be used. The network-event block already lazily loads it when it needs it, so `taint` is simply left None otherwise. Measured on an 800-statement workload: 1044 ms -> 378 ms, entirely from the removed reads. Behaviour is unchanged — marking still happens for exactly the same events, and taint escalation on network events is untouched.
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.
Found this while profiling #27, but it's unrelated so I split it out.
_get_taint()reads the session's taint file from disk, and it was getting called on everyevaluate()even though only events with a prompt-injection finding ever mark. So every other event paid a file read for nothing.Checking the cheap in-memory condition first avoids that. The network block already loads the store lazily when it needs it, so
taintjust staysNoneotherwise.On an 800-statement workload that's 1044 ms down to 378 ms, all of it from the removed reads. A benign event now does 0 taint reads instead of 1, and an injection event still does 1 and marks the same as before.
Nothing else changes: the same events mark, and taint escalation on network events is untouched.
test_trifecta.py,test_suspicious_networkandtest_sarif_outputall pass, and the CI security-regression suite is green.Kept separate from #27 so it can be reviewed or reverted on its own. #27 doesn't depend on it. If #221 lands first this will need a trivial rebase on the same hunk, or vice versa.