Fork me on GitHub
#pathom
<
2023-10-30
>
Eric Dvorsak20:10:41

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?

Eric Dvorsak22:10:46

@U3XCG2GBZ 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 Dvorsak22:10:48

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.macdonaldblack22:10:00

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.macdonaldblack22:10:43

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.macdonaldblack22:10:23

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

caleb.macdonaldblack22:10:01

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

caleb.macdonaldblack22:10:41

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

caleb.macdonaldblack22:10:09

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

wilkerlucio02:10:19

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...)

wilkerlucio02:10:03

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

wilkerlucio02:10:12

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 Dvorsak06:10:44

@U066U8JQJ 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?

wilkerlucio23:11:59

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