pathom

:pathom: https://github.com/wilkerlucio/pathom/ & https://pathom3.wsscode.com & https://roamresearch.com/#/app/wsscode
henrik 2021-06-23T12:25:57.107800Z

I'm having trouble getting Pathom(3) to make use of batch resolvers. I seem to be fulfilling the criteria for batch resolvers to kick in (maps are returned, or rather, a vector of maps), but Pathom seems to split them into individual calls anyway. I'm not sure what to look for while investigating this issue, what should I be looking out for?

2021-06-23T12:31:07.108800Z

can you share some code? we use batch resolvers on pathom3 and havent’ had such problem.

henrik 2021-06-23T12:43:01.109500Z

wilkerlucio 2021-06-24T15:02:35.121100Z

good to hear about this case

👍 1
wilkerlucio 2021-06-24T17:01:15.121600Z

I've been giving second thoughs around the plugins, because batching also suffers from the limitations of the "wrapping pattern"

wilkerlucio 2021-06-24T17:02:02.121800Z

its also interesting to think about what is a good way to provide hooks for metrics like this

wilkerlucio 2021-06-24T17:02:25.122Z

because measuring single vs batch, its not the same thing, and maybe is better to have distint ways to track it

henrik 2021-06-24T19:42:41.126500Z

That’s a good point, and it’s not the end of the world if it's two separate hooks. To me, it doesn't matter for the purposes of Honeycomb, since it's interesting enough to see where the app is spending a lot of time. From that point of view, it doesn't matter whether it’s batched or not. But I get that there may be other circumstances where it does matter.

henrik 2021-06-24T19:48:13.131600Z

With Honeycomb, I could inject the variable of whether it's batched or not, if this distinction could be known inside the plugin definition. This would enable me to split the analysis on those that are batched and not in the Honeycomb UI. Exposing an indicator of whether the plug-in is currently running inside a batch resolver or not might be more convenient than using two distinct integration points. That would leave it up to the creator of the plug-in to decide whether this information matters to them or not.

wilkerlucio 2021-06-24T22:08:18.132600Z

currently you can check if you look at the resolver, the "node" has ::pco/op-name, which you can use to lookup at ::pci/index-resolvers, them pull the config map with pco/operation-config

👍 1
wilkerlucio 2021-06-24T22:08:29.132800Z

the major missing point is a hook to know about the batch run time

wilkerlucio 2021-06-24T22:08:56.133Z

that's currenty not available, but I can add that, just like to think a bit more about the whole plugin thing, this is something I can get to this week

wilkerlucio 2021-07-01T11:53:30.151800Z

@henrik yesterday I made some changes to what wrap-resolve wraps, before it was wrapping some higher process, but now it really wraps the resolve call (as I believe you expected, which makes sense), note now you get env input instead of env node, please let me know how that fits in your game

🎉 1
wilkerlucio 2021-07-01T11:53:56.152Z

important to note though, now in the case of batch, you will only get 1 call to wrap-resolve with the batch (`input` will be a collection)

henrik 2021-07-01T14:59:22.152900Z

This works very well, thank you. I can now add the size of the input to the logging with Honeycomb. (i.e., "it took 59ms, but on the other hand there were 2291 inputs")

wilkerlucio 2021-06-23T14:23:48.111100Z

hello Henrik, looking at the graph it seems to be using batch correctly, that blue bar is kind of a “shared time” in the batch of the items

wilkerlucio 2021-06-23T14:24:31.112400Z

have you tried logging to see if there are many calls to the resolver?

wilkerlucio 2021-06-23T15:43:56.112600Z

maybe the reading is a bit confusing, but see that those blue bars are in "parallel", altough there is no parallel runner yet, the intention was to make an indication they are a single thing (the batch run), do you have an idea how we could make this clear?

henrik 2021-06-23T16:46:50.112800Z

Aha! That's interesting. I've also written a plugin to wrap each resolver call with a log to Honeycomb, where it looks like it's registering numerous calls to the same resolver:

henrik 2021-06-23T16:48:15.113200Z

Now I'm thinking that I might not be measuring what I think I'm measuring. When wrapping around ::pcr/wrap-resolve, am I wrapping around the call to the resolver, or the construction of the resolver, or something else?

henrik 2021-06-23T16:50:54.113400Z

(Btw, Honeycomb might be an example of a UX that is quite good at communicating where spans are children vs. siblings)

henrik 2021-06-23T16:54:47.113600Z

(defn wrap-resolver-with-honeycomb [resolve]
  (fn [env node]
    (wrap-honeycomb env (str (::pco/op-name node))
      (resolve env node))))

henrik 2021-06-23T20:17:45.114Z

So, It's pretty clear to me that I've misunderstood wrap-resolve, and that this is the source of my confusion. Is there a way to wrap the invocation of a resolver, at the moment where it receives the inputs?

wilkerlucio 2021-06-23T22:44:03.114200Z

this expectation is correct, but as you are seeing, in the case of batch it get some caveats

wilkerlucio 2021-06-23T22:44:24.114400Z

indeed it always runs when the resolver gets the input, but, in the case of batch, it doesn't run immediatly

wilkerlucio 2021-06-23T22:45:19.114600Z

you can check if that happen, by looking at the output of what you are wrapping, in case of batch it will be a map with the key ::pcr/batch-hold on it, if you see that, this means the resolver isn't running now, and will run later as a batch

wilkerlucio 2021-06-23T22:45:28.114800Z

for observability purposes, you may want to ignore those cases

wilkerlucio 2021-06-23T22:48:45.115Z

honeycomb looks nice 🙂