cider

oyakushev 2024-08-30T07:15:28.419939Z

A recent update of CIDER in the rolling MELPA brought a redesigned cider-trace functionality. We replaced clojure.tools.trace dependency with a custom tracer in Orchard, and its output now looks like this (image #1). I would appreciate you replying in the comments whether you ever use CIDER tracer and if you like the new more spacious look (the old one looked like this – see image #2).

3
πŸ‘ 3
bozhidar 2024-08-31T11:27:43.845319Z

Down the road we might do a version of this that prints to a buffer and allows you to drill selectively into the traced output (something like the inspector in a way). Still, I think the recent improvements are pretty great, and of course now that the tracing code lives in Orchard it's easier to improve it. (unlike with the contrib libraries)

πŸ‘ 2
Harold 2024-08-31T17:49:03.440629Z

Drilling sounds cool πŸ‘

2024-09-10T08:29:40.201399Z

I also don't use the tracer as much as I would like. Mostly because of the wall of text when data structures get larger. SLY seems to have a trace dialog which is integrated with their inspector: https://joaotavora.github.io/sly/#Trace-Dialog

πŸ‘€ 1
Drew Verlee 2024-09-12T13:21:26.507909Z

is the tracing functionality more-or-less sayid? (i haven't used it in a while but by the time i feel i need it i have usually muddied through without)

bozhidar 2024-09-12T13:22:11.981319Z

It’s not - sayid is a lot more sophisticated, but it’s basically abandonware at this point. I never had much time for it.

πŸ‘ 1
Macroz 2024-09-02T09:20:01.902249Z

I like the idea of using the CIDER inspector for this with drilling into details, and then spending time improving the inspector more.

πŸ‘ 1
Macroz 2024-09-02T09:21:45.076129Z

I'm able to produce a (possibly deeply nested) map of interesting data trivially in Clojure as a user. But then to be able to inspect it nicely is kind of the most important thing an "IDE" could do.

Macroz 2024-09-02T09:26:06.454659Z

Here's some context in a screenshot. I'm inspecting the app DB here in two ways, but both have some rough edges.

oyakushev 2024-09-02T10:36:28.001159Z

In the inspector example, you are supposed to click the value to the right, and then it will be rendered nicely

Macroz 2024-09-02T10:40:22.104919Z

Since it always renders a "preview" of what the contents are, and that can not usually be nicely formatted, I think it keeps being a little bit confusing in then too. A regular "tree component" usually doesn't spend so much effort in showing the insides but allows one to just keep opening levels as needed. Like in this screenshot you can see it doesn't make the inspector much clearer?

Macroz 2024-09-02T10:41:24.266429Z

Maybe it's for another thread, but it would be really nice to see some examples of people who find the UX works for them well. Maybe I'm just not familiar with it or doing something suboptimal. I feel like a good "inspector component" would be worth its weight in gold.

oyakushev 2024-09-02T10:47:18.970869Z

You can press C (Shift-C) to set the desired nested level to be printed. So you can go from this to this to this to this. You can always customize cider-inspector-max-nested-depth to set the default value so that you don't have to change it every time you reinspect.

Macroz 2024-09-02T10:48:39.302149Z

Cool, that's a worthwhile tip indeed! I was reading this https://docs.cider.mx/cider/debugging/inspector.html and didn't realize that it's useful for this. Maybe some of those keys things are also out of date (should 0 and 9 still work?)

oyakushev 2024-09-02T10:48:40.739649Z

I'm free to suggestions how to improve the inspector; in fact, we're in a constant process of improving it – there is always something to do better.

oyakushev 2024-09-02T10:49:34.640849Z

0 and 9 do work in linear collections. Try inspecting an individual number in (range 100) and then you can go through them by pressing 0 and 9

Macroz 2024-09-02T10:49:40.208449Z

Yeah, I first wanted to just point out that it could be an important part of CIDER, to show trace, profiling results, inspecting random user data etc.

Macroz 2024-09-02T10:51:40.974459Z

The nicely formatted trace is something that I would see as an upgrade of the inspector, and then all is just plain old data to be looked at in the inspector.

oyakushev 2024-09-02T10:52:09.816259Z

Integrating tracer with inspector is not so straightforward (even though it may be considered). For the inspector to work for this, the traced function arguments and return values have to be retained in memory. Given that those objects can be arbitrarily big, such a tracer risks running the process into OOM in a general case.

oyakushev 2024-09-02T10:53:23.296529Z

Again, it may be possible to use weak references or some other safety net for this. Just some careful design is necessary for such a feature.

Macroz 2024-09-02T10:53:24.316249Z

I guess my data is small since it fits my memory, so I tend to just trace data into an atom and then use multiple tools to visualize what is going on (e.g. trace stack and record execution time to have a flow graph and output with Graphviz etc.)

oyakushev 2024-09-02T10:55:00.186599Z

Sure; I also do that often (save function args into an atom and inspect the atom later). But in that case, I know what I'm doing and what the implications are. I also have an explicit atom that I can clear. If this were possible as a CIDER feature, it may not be so obvious for the user what is the cost and what are the dangers.

Macroz 2024-09-02T10:56:07.232699Z

Here is an old example of what I make possible with it. So I kind of would like to see a choice of "side channel" where stuff can be output. It could be just stdout (with nice print) but could be an atom. At least I feel like for CIDER it could be just a value in the REPL it's running in.

πŸ”₯ 2
oyakushev 2024-09-02T10:59:27.524299Z

Nice viz! The side channel that you describe sounds like tap>. I don't use tap> much, so I'm not fully aware how well CIDER leverages it, but I've seen there are a couple of integration points.

Macroz 2024-09-02T10:59:59.785509Z

I don't use tap> either but I can see there is some similarity. I'm happy to use whatever mechanism CIDER would adopt.

Macroz 2024-09-02T11:01:20.964799Z

My workflow is most often though just saving a random sexp with a hotkey, and using another hotkey to evaluate that sexp whenever I do changes, from whichever buffer I'm at now. And use the cider--pprint-eval-form to other buffer so I can "keep watching" the same result. Using the inspector instead would be what I'm thinking of an upgrade as long as it can provide me that useful drilldown. I haven't touched my workflow for some years so I'll try using the inspector more. Thanks for the tips.

πŸ‘ 1
oyakushev 2024-09-02T11:03:40.040109Z

BTW, by default, if the inspector buffer stays visible, the inspector should re-inspect any value returned by any CIDER eval command.

oyakushev 2024-09-02T11:05:48.480399Z

Pretty printing is convenient for cases where the printed data is exactly between being too small to need pretty-printing to being too big for the pretty-printed output to be useful. This is why the inspector is much better as a generic solution for any case. But there are still ways to improve its output.

2024-09-02T11:18:30.695069Z

Nice ideas. I will play with some of these in https://github.com/flow-storm/cider-storm/ which is a Cider front-end for the recordings made by http://www.flow-storm.org/ which already does the tracing part. Tracing as retaining pointers without serializing them in any way (unless when you need to deal with mutable values). FlowStorm currently records function calls, return values and all intermediate expressions in a timeline which also can be navigated as a call tree, which gives this "digging" already. All this (and much more) is already possible with the FlowStorm UI, but it would be nice to also have it available on Cider

πŸ‘ 2
1
Ben Sless 2024-09-02T12:47:31.551969Z

@bozhidar done https://github.com/clojure-emacs/cider/issues/3737

πŸ‘ 2
2024-09-02T13:01:10.773489Z

it may be possible to use weak references or some other safety net for this@alexyakushev I remember exploring this path (soft references) some time ago, but I couldn't make it work when tracing a call tree, since there is a structure and dependencies between each fn-call/fn-return trace and their childs, so I couldn't use soft references for the nodes themselves. I also tried to use soft references for the value references instead of the tracing nodes, but then you can still get OOM, and a soft reference for each value pointer also has a lot of overhead

solf 2024-08-30T08:52:36.652299Z

I've used it only a few times, and not in recent memory. The new version is still CLJ-only, right? Regarding the look, I would prefer a more compact look, even in my 32" monitor I sometimes run out of vertical space, never mind when I work from my 13" laptop.

πŸ‘ 1
2
oyakushev 2024-08-30T09:00:56.839769Z

Yeah, I think it's CLJ-only, nothing has changed in that department. Fair point about the vertical space. Initially, I wanted to make this spacious configurable at some point, but maybe a compact look is better and all that's needed.

2024-08-30T12:44:11.677729Z

> whether you ever use CIDER tracer I find it could only be useful in a very reduced number of cases, like when functions deals with very simple values like numbers. As soon as your functions receive and return complex data structures is hard to read. And it also mixes with stuff begin written to *out* . It is also easy to freez my emacs if it prints a lot.

oyakushev 2024-08-30T12:45:30.130099Z

All valid points! With one difference now: the new tracer uses orchard.print for arguments and results, so it should no longer freeze on huge/infinite values.

πŸ™Œ 1
2024-08-30T12:46:10.857039Z

nice, those freezings are quite annoying

Ben Sless 2024-09-01T13:27:09.703269Z

This sounds right - give me the trace as Just Data (TM) and I can use the Inspector on it

bozhidar 2024-09-02T05:21:18.399579Z

@ben.sless Good point. Please, open a ticket about this and we'll see what we can do about this.

πŸ‘ 1