-
Notifications
You must be signed in to change notification settings - Fork 37
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
&try / backtrack() usage too expensive due to unconditional stack unwinding #1565
Comments
I think it's the exception being thrown by That said, I also wouldn't want encourage such use of try/backtrack(); it's meant as an last-resort mechanism if there's nothing better available, usually to step back across some layers of parsing (hence the exception mechanism). |
Yep, Linux. For the unhandled
Yep, not arguing. Performance can likely be fixed, but also the issue in understanding control flow in anything more complex. But then, for a beginner it's an easy to understand tool in reach also for simple cases. In the docs, it's also just before the "Changing Input" section that has the better alternatives. A warning/info box in the documentation suggesting to use the The spicy-postgres parser also has a |
Improves performance processing pure QUIC traffic by ~20% Relates to zeek/spicy#1565.
Improves performance processing pure QUIC traffic by ~20% Relates to zeek/spicy#1565.
Turns out these backtraces aren't used anywhere by default anyways, only if requested explicitly through a runtime option. I'll limit capture to debug builds. |
They can be expensive to capture, and aren't used anywhere by default unless explicitly requested. Closes #1565.
They can be expensive to capture, and aren't used anywhere by default unless explicitly requested. Closes #1565.
The initial implementation of the QUIC parser uses two
&try / backtrack()
constructs for parsing the initial byte and a second one for capturing all the data. During tests, the output ofperf report --no-children
indicates 8.5% of the samples fall into_Unwind_GetTextRelBase
which seems surprising: The pcap in question produces a single analyzer.log entry only.Concretely, processing a a 274MB pure QUIC traffic pcap with latest Zeek master (v6.1.0-dev-487-ge22bf8ebb6, RelWithDebInfo, frame pointers enabled) and latest spicy-quic parser takes ~30seconds.
Replacing the two
&try / backtrack()
constructs with&parse-at=self.input()
and resetting the input reduces the processing time to ~24seconds. That's 20% faster for that specific pcap (and not using try/backtrack() looks actually better).Light grepping through Spicy makes me believe that for every
&try
andbacktrack()
execution a newBacktrace
object is instantiated, which unconditionally callsbacktrace()
and then_Unwind_GetTextRelBase
. For thetry / backtrack()
mechanism that is unproductive work. Flamegraphs before/after below. They look quite bit different, so wonder if the backtrack() also triggers something with the fiber execution.Anyway,
try/backtrack()
should probably not come with such a huge overhead or otherwise cause a warning with discouragement and alternatives to use instead.Flamegraphs
try-backtrack (before)
parse-at (after)
The text was updated successfully, but these errors were encountered: