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

Optimize (not) printing empty string from formatter #113

Merged
merged 1 commit into from
Oct 8, 2024

Conversation

gomoripeti
Copy link
Contributor

Sometimes it is handy to implement some additional filtering in a custom formatter function. In this case the formatter can return the empty string if it wants to ignore a trace message. Optimize the formatting so in the empty string case it does not send an io request to the IO server. This saves some message passing and avoids a "flickering prompt" effect (when the empty string is printed) in case of 1000s of ignored trace messages per second.

Tested manually in rebar3 shell (before this patch prompt 4> used to "flicker"):

1> F = fun F() -> lists:nth(2, [1,2,3]), timer:sleep(1), F() end.
#Fun<erl_eval.20.125776118>
2> spawn(fun() -> F() end).
<0.198.0>
3> recon_trace:calls({lists, nth, 2}, 1000, [{formatter, fun(_) -> "" end}]).
1
Recon tracer rate limit tripped.
4>

Sometimes it is handy to implement some additional filtering in a
custom formatter function. In this case the formatter can return the
empty string if it wants to ignore a trace message. Optimize the
formatting so in the empty string case it does not send an io request
to the IO server. This avoids a "flickering prompt" effect (when the
empty string is printed) in case of 1000s of ignored trace messages
per second.
Copy link
Owner

@ferd ferd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems all good and safe.

@ferd ferd merged commit ec66057 into ferd:master Oct 8, 2024
0 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants