-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
[inspect] Extract inspect-value into a separate printer implementation #241
Conversation
Seems like a good batch of refinements! Probably the best 'review' I can provide is suggesting that you |
9469f2d
to
b76e7c0
Compare
b76e7c0
to
99e64a7
Compare
f4391e4
to
75feee6
Compare
Change of plans.
The extracted printer contains the previous performance improvements and new truncation logic. Now it supports:
@vemv The inspector has a pretty good test coverage, so I'm quite optimistic about the changes. Something might change visually but not structurally. Anyway, I would appreciate even a brief review. |
04a1b04
to
1b98aa9
Compare
* | ||
* This class is not thread-safe. | ||
*/ | ||
public class TruncatingStringWriter extends StringWriter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems something nice to unit-test in isolation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somewhat agree, but I also believe that test/orchard/print_test.clj
unit tests cover this quite well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would seem more of a side coverage, in a unit test maintainers can have isolated examples and explicitly going over the edge cases
(and pigging back on the topic of today's another PR, not everyone wants to read Java all the time - worth optimizing for that)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
02b1d0b
to
33ec43a
Compare
33ec43a
to
84dd9ca
Compare
I'd say that by default, on an average monitor we should strive to show one line of text at most - or maybe a handful, IDK. The reason being, such large k-v entries can easily bury other k-v entries. User can always drill deeper into the data if they need more detail. (For clarity - before this PR the behavior doesn't seem ideal to me at all) Perhaps we can leave this aspect essentially unaltered in this PR? I'm not a fan of big PRs anyway. |
Do you mean disabling long printed value truncation for now? |
I'd simply try to keep behavior as close to the current one as possible. But we can certainly try to refine it afterwards. |
I've never gotten a SO in practice. |
It happens sometimes when you work with Java object hierarchies. |
Regarding why I want this for the debugger: Around 40% of the time when I use CIDER debugger, I need to perform an extra dance to avoid the step debugger landing on a piece of data that is big (say, ~50-100Mb) because it tries rendering it which hurts both Clojure and Emacs side of the debugger. By unifying the printers that Inspector and Debugger use, and by constraining how much work they do when displaying values, we can greatly improve the UX. |
8eadc85
to
7424001
Compare
Here's my proposal to take it piecemeal. First step:
Later, we can think whether changing these defaults is necessary and what are the optimal values. |
7424001
to
6ec6e69
Compare
I agree. @alexander-yakushev I'm fine with your piecemeal proposal, although I'd also be OK with making all changes at once. I really doubt this will affect someone negatively. |
@@ -0,0 +1,185 @@ | |||
(ns orchard.print |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to add some :added
metadata for this ns.
src/orchard/inspect.clj
Outdated
@@ -82,7 +82,7 @@ | |||
[inspector] | |||
(merge (reset-index inspector) | |||
{:value nil, :stack [], :path [], :pages-stack [], | |||
:current-page 0, :rendered '(), :indentation 0})) | |||
:current-page 0, :rendered [], :indentation 0})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have existing patterns in this ns such as (update-in [:rendered] concat (list expr))
so I'd rather not have this touched.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed that as well. Concat is generally an antipattern. https://stuartsierra.com/2015/04/26/clojure-donts-concat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright
Either way, any change that has the risk of going wrong deserves its own commit, if not its own PR.
PRs which aren't constrained to a single topic are harder to review.
Please don't make maintainers squint/head-scratch at changes - present them nicely so that it's all safe and streamlined.
Hope it helps for future occasions!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed that commit from this PR.
6ec6e69
to
1619300
Compare
Great work - thanks! |
Before submitting a PR make sure the following things have been done:
Thanks!