pathom

Eric Dvorsak 2023-10-30T20:24:41.412649Z

What is happening here? I have a resolver that returns a list of users, but when it returns 1000s of users it takes a long time because it looks like each user is processed sequentially. Is there a way to do it in parallel / faster?

caleb.macdonaldblack 2023-10-30T22:11:34.527289Z

If you’re using Pathom3, try turning that into a https://pathom3.wsscode.com/docs/resolvers/#batch-resolvers

Eric Dvorsak 2023-10-30T22:27:46.351749Z

@caleb.macdonaldblack it's a resolvers that returns a collections of users, output is {:admin/users [:user/id]} and there is no subquery needed to resolve further. this little green blocks seem to be purely pathom processing the outputs

Eric Dvorsak 2023-10-30T22:31:48.719669Z

marking the result as pco/final does remove these but ofc it's not suitable if eg I want extra attributes that are not resolved immediately by this resolver which is the case for a bunch of other queries that I have that do return a big amount of items in a seq

caleb.macdonaldblack 2023-10-30T22:52:00.123999Z

If it’s consuming time on simply processing the data (and not fetching from a db or something) then I’m not too sure. If you’re trying to take a large number of entities and process them by filtering or aggregating, doing that work db side will almost always be better option as apposed to using Pathom. Pathom just doesn’t have the performance for that sort of task.

caleb.macdonaldblack 2023-10-30T22:53:43.784059Z

However, if it’s just a data fetching problem you’re trying to speed up, your {:admin/users [:user/id]} should work just fine, and you’ll want to turn your user/id -> user/name, ... resolver into a batch resolver.

caleb.macdonaldblack 2023-10-30T22:54:23.213019Z

Also try out the p.a.eql/parallel? option and see if that helps.

caleb.macdonaldblack 2023-10-30T22:55:01.944889Z

Make sure you’re using the p.a.eql too, and not p.eql

caleb.macdonaldblack 2023-10-30T22:55:41.079439Z

resolvers you want running in parallel should return futures or promises or whatever

caleb.macdonaldblack 2023-10-30T22:59:09.123109Z

I didn’t know about ::pco/final. That’s pretty handy

wilkerlucio 2023-10-31T02:22:19.944789Z

hello Eric, yeah, this is an overhead that pathom adds because even if the entity has all the data, Pathom must check it (scan over results, compare the data with required query, etc...)

wilkerlucio 2023-10-31T02:23:03.876679Z

if you know you wont have any futher process, you can use ::pco/final to mark the data as complete, doing so will tell pathom to not try anything, this way you can avoid the scan

wilkerlucio 2023-10-31T02:24:12.140749Z

I was thinking the parallle processor could try to split a vector in blocks and process them in parallel, but its tricky, because I also dont want to be spawing too many threads, a solution like that involves also adding some sort of thread management/configuration

Eric Dvorsak 2023-10-31T06:02:44.422339Z

@wilkerlucio would it be possible to have something like “final” but instead of doing nothing it does the job on the first item of the sequence and extrapolates to all the others? Because when the resolvers is getting a lot of rows from a table you are 100% sure all items have the same shape of outputs?

wilkerlucio 2023-11-13T23:53:59.477059Z

not impossible, but its a considerable change, something maybe to test and see if there are enough gains to compensate the add complexity