pathom

:pathom: https://github.com/wilkerlucio/pathom/ & https://pathom3.wsscode.com & https://roamresearch.com/#/app/wsscode
wilkerlucio 2020-12-18T00:00:01.011100Z

ok, let me check on older version to understand

tony.kay 2020-12-18T00:00:38.011300Z

I’ll try 2.3 and see if there was something weird

tony.kay 2020-12-18T00:03:44.011500Z

ok, weird

tony.kay 2020-12-18T00:03:49.011700Z

pathom 2.3 seems faster

tony.kay 2020-12-18T00:03:52.011900Z

@wilkerlucio

tony.kay 2020-12-18T00:03:59.012100Z

let me eval this

tony.kay 2020-12-18T00:04:19.012300Z

Yeah, I got one call this time

wilkerlucio 2020-12-18T00:04:25.012500Z

cool

tony.kay 2020-12-18T00:04:32.012700Z

I wonder if it was slower earlire for some other reason

tony.kay 2020-12-18T00:04:40.012900Z

I’ll measure some more. Thanks for the help 🙂

wilkerlucio 2020-12-18T00:04:53.013100Z

if that gets to a hard problem I can release a hotfix for 2.3.x with a fix for that fn you pointed out

tony.kay 2020-12-18T00:04:56.013300Z

I didn’t have the metadata on there earlier

tony.kay 2020-12-18T00:05:16.013500Z

so, I do think 2.3 is possibly slower without it. Let me check that

wilkerlucio 2020-12-18T00:05:50.013700Z

yeah, if you learn what it is, I would be glad to address, I don't remember any big change that could cause noticeable performance degradation

tony.kay 2020-12-18T00:06:12.013900Z

yeah…it’s waaaaaay worse

wilkerlucio 2020-12-18T00:06:19.014100Z

but maybe was this change, from moving to inline re-processing to the reader engine

tony.kay 2020-12-18T00:06:25.014300Z

I was getting 8s

tony.kay 2020-12-18T00:06:35.014500Z

it’s been running for 50s so far

tony.kay 2020-12-18T00:06:48.014700Z

and I was getting 2.5s with 2.2.30 with the metadata

tony.kay 2020-12-18T00:07:04.015Z

still running!

tony.kay 2020-12-18T00:07:20.015200Z

q: :taxable/taxes                     536   504.60μs    30.54ms    54.41ms    57.27ms    60.14ms    65.60ms    30.09ms  ±50%    16.13s     71%
q: :product/tax                       535   188.04μs    11.61ms    21.51ms    22.96ms    25.35ms    29.50ms    12.01ms  ±51%     6.43s     28%
q: :entity/company                    536    34.74μs    52.49μs    72.69μs    96.27μs   128.20μs   359.06μs    56.05μs  ±23%    30.04ms     0%
q: :tax/category                      535    18.01μs    35.83μs    45.29μs    55.18μs    85.55μs   214.91μs    36.65μs  ±23%    19.61ms     0%
q: :product/precise-price             535    14.47μs    24.50μs    38.12μs    42.49μs    86.47μs   414.02μs    28.26μs  ±31%    15.12ms     0%
q: :tax/rate                          535    13.50μs    20.57μs    38.35μs    44.99μs    71.57μs   106.56μs    25.30μs  ±35%    13.53ms     0%
q: :product/inventory-tracked?        536    12.16μs    20.13μs    36.27μs    41.60μs    77.72μs   103.24μs    23.69μs  ±35%    12.70ms     0%
q: :product/description               535    12.71μs    19.32μs    35.91μs    38.43μs    74.16μs   102.37μs    23.24μs  ±35%    12.43ms     0%
q: :product/id                        536    11.15μs    18.36μs    35.35μs    41.61μs    76.47μs   127.77μs    22.69μs  ±38%    12.16ms     0%
q: :product/sku                       535    11.39μs    19.33μs    35.35μs    38.69μs    77.51μs   104.34μs    22.38μs  ±36%    11.98ms     0%

tony.kay 2020-12-18T00:07:28.015400Z

I have minute-by-minute timing in a plugin

tony.kay 2020-12-18T00:07:41.015600Z

measuring every call to the reader

tony.kay 2020-12-18T00:08:00.015800Z

It can normally do 10,000 of those in a few ms…but with 2.3 it is 10x that

tony.kay 2020-12-18T00:08:02.016Z

or more

tony.kay 2020-12-18T00:08:21.016200Z

I’m seeing 11ms for 500 calls

wilkerlucio 2020-12-18T00:09:22.016400Z

I think the reason may be on the switch from inline processing to reader engine, but I wouldn't expect to be that much

tony.kay 2020-12-18T00:09:31.016600Z

still running

tony.kay 2020-12-18T00:09:49.016800Z

I think it may be 100 to 1000x slower

tony.kay 2020-12-18T00:10:16.017Z

yeah, I def cannot risk that one in prod 😕

tony.kay 2020-12-18T00:10:23.017200Z

this would kill us

wilkerlucio 2020-12-18T00:10:28.017400Z

if you need I can do a hotfix for that 2.2 to add support for final there

tony.kay 2020-12-18T00:10:40.017600Z

yes please 🙂

tony.kay 2020-12-18T00:10:59.017800Z

repro case is easy

tony.kay 2020-12-18T00:11:14.018Z

(defresolver all-products-resolver
  [{:keys [conn] :as env} _]
  {::pc/output [{:product/all-products [:product/id
                                        :product/sku
                                        :product/description
                                        :product/precise-price
                                        :taxable/taxes
                                        :product/tax
                                        :product/inventory-tracked?]}]}
  (let [db         (d/db conn)
        company-id (env->effective-company-id env)]
    {:product/all-products (get-all-products db company-id)}))

tony.kay 2020-12-18T00:11:23.018200Z

and make get-all-products return 1000 (complete) things

wilkerlucio 2020-12-18T00:13:38.018500Z

please try 2.2.31-SNAPSHOT

tony.kay 2020-12-18T00:13:50.018700Z

k

tony.kay 2020-12-18T00:13:51.018900Z

thanks

tony.kay 2020-12-18T00:14:06.019100Z

(it’s still running btw)

wilkerlucio 2020-12-18T00:14:29.019300Z

this is running on CLJ, right?

tony.kay 2020-12-18T00:14:35.019500Z

yeah

wilkerlucio 2020-12-18T00:14:39.019700Z

because I wanna do some measurements later, k

tony.kay 2020-12-18T00:14:42.019900Z

8700k CPU

wilkerlucio 2020-12-18T00:15:09.020100Z

8700k?

tony.kay 2020-12-18T00:15:17.020300Z

Intel CPU model

tony.kay 2020-12-18T00:15:31.020500Z

not the latest, but no slouch

wilkerlucio 2020-12-18T00:15:44.020700Z

ah, ok, just wanted to make sure I'm doing the tests in the same env (clj vs cljs)

tony.kay 2020-12-18T00:15:51.020900Z

sure

wilkerlucio 2020-12-18T00:17:59.021100Z

please let me know if that works, if so I'll release 2.2.31

tony.kay 2020-12-18T00:18:54.021300Z

I had to restart, and this thing is rather large…takes a min

wilkerlucio 2020-12-18T00:19:26.021500Z

no worries and no rush 🙂

tony.kay 2020-12-18T00:19:29.021700Z

cognitect.transit/write              transit.clj:  167
                 com.cognitect.transit.impl.WriterFactory$1.write       WriterFactory.java:   62
                      com.cognitect.transit.impl.JsonEmitter.emit         JsonEmitter.java:   41
            com.cognitect.transit.impl.AbstractEmitter.marshalTop     AbstractEmitter.java:  211
               com.cognitect.transit.impl.AbstractEmitter.marshal     AbstractEmitter.java:  184
               com.cognitect.transit.impl.AbstractEmitter.emitMap     AbstractEmitter.java:   85
                   com.cognitect.transit.impl.JsonEmitter.emitMap         JsonEmitter.java:  171
               com.cognitect.transit.impl.AbstractEmitter.marshal     AbstractEmitter.java:  194
       java.lang.Exception: Not supported: class clojure.lang.Atom
java.lang.RuntimeException: java.lang.Exception: Not supported: class clojure.lang.Atom

tony.kay 2020-12-18T00:19:31.021900Z

ooops

tony.kay 2020-12-18T00:19:44.022100Z

atom flowed through

wilkerlucio 2020-12-18T00:20:06.022300Z

ah, I know what is

wilkerlucio 2020-12-18T00:20:21.022500Z

sorry, minor mistake, releasing again

tony.kay 2020-12-18T00:20:29.022700Z

I should have cloned and run local/root so I could pull and jsut refresh instead of restarting 😕

wilkerlucio 2020-12-18T00:20:41.022900Z

re-released

tony.kay 2020-12-18T00:21:40.023300Z

k

wilkerlucio 2020-12-18T00:21:42.023500Z

its on this branch if you wanna pull local

tony.kay 2020-12-18T00:22:35.023700Z

did u push?

wilkerlucio 2020-12-18T00:23:00.024Z

yes

tony.kay 2020-12-18T00:23:35.024200Z

k…just a min

wilkerlucio 2020-12-18T00:23:39.024400Z

arg, it trigerred reformat, messy diff, going to fix, but the code should be correct

tony.kay 2020-12-18T00:26:46.024800Z

that got it

tony.kay 2020-12-18T00:26:51.025Z

fast

tony.kay 2020-12-18T00:27:19.025200Z

network request now 800ms

tony.kay 2020-12-18T00:27:30.025400Z

including data transfer

wilkerlucio 2020-12-18T00:29:18.025600Z

cool

wilkerlucio 2020-12-18T00:29:36.025800Z

I'm doing a few changes because I'm afraid the current impl may try to call meta in values it shouldn't

tony.kay 2020-12-18T00:29:53.026Z

ok, I’m running local/root so much faster to test now

wilkerlucio 2020-12-18T00:31:07.026200Z

oh, I think its fine, I though (meta nil) would break, but it works

wilkerlucio 2020-12-18T00:32:21.026500Z

unless you find some issue, I'm ok to release the 2.2.31

tony.kay 2020-12-18T00:32:53.026700Z

your branch name is weird

wilkerlucio 2020-12-18T00:33:05.026900Z

yeah... its wrong

tony.kay 2020-12-18T00:33:17.027100Z

so as long as the code is right, it should be ok

tony.kay 2020-12-18T00:33:23.027300Z

I mean version *

wilkerlucio 2020-12-18T00:33:49.027500Z

its fine, I'll just remove it after

wilkerlucio 2020-12-18T00:33:55.027700Z

and has the tag to get back to this version if needed

tony.kay 2020-12-18T00:33:59.027900Z

hm

tony.kay 2020-12-18T00:34:00.028100Z

hold on

tony.kay 2020-12-18T00:34:04.028300Z

I clicked around a bit

tony.kay 2020-12-18T00:34:11.028500Z

and other stuff seems to be slower now

tony.kay 2020-12-18T00:34:37.028700Z

any idea why that might be?

tony.kay 2020-12-18T00:35:22.028900Z

basically it looks like similar queries that don’t have the metadata are slower now

tony.kay 2020-12-18T00:35:27.029100Z

by a noticeable amount

tony.kay 2020-12-18T00:35:40.029300Z

are you making a bunch of new atoms to fix this?

tony.kay 2020-12-18T00:35:58.029500Z

or rather, without the metadata would it have new overhead?

wilkerlucio 2020-12-18T00:36:15.029700Z

nope, it should be simple

wilkerlucio 2020-12-18T00:36:23.029900Z

I just made another version, with an even simpler change

wilkerlucio 2020-12-18T00:36:49.030100Z

try the current on that branch

wilkerlucio 2020-12-18T00:36:53.030300Z

this are all the changes; https://github.com/wilkerlucio/pathom/compare/hotfix-final-2.3?expand=1

wilkerlucio 2020-12-18T00:37:23.030500Z

the previous was a bit weird: https://github.com/wilkerlucio/pathom/commit/2b1a4c368d9fdb170b31f28531608ad92d1eecce

tony.kay 2020-12-18T00:38:12.030700Z

ok, yeah, looks good. I bounced back to .31 and that page was just as slow, so false alarm

wilkerlucio 2020-12-18T00:48:38.030900Z

hey, I just did a comparison between 2.2 and 2.3 processing a 10k size list

wilkerlucio 2020-12-18T00:48:52.031100Z

(ns com.wsscode.demos.perf
  (:require [com.wsscode.pathom.connect :as pc]
            [criterium.core :as c]
            [com.wsscode.pathom.core :as p]))

(pc/defresolver long-list [env _]
  {::pc/output [:items]}
  {:items (mapv #(hash-map :id 1) (range 10000))})

(pc/defresolver x [env {:keys [id]}]
  {::pc/input #{:id}
   ::pc/output [:x]}
  {:x (* 10 id)})

(def registry [long-list x])

(def parser
  (p/parser
    {::p/env     {::p/reader               [p/map-reader
                                            pc/reader2
                                            pc/open-ident-reader
                                            p/env-placeholder-reader]
                  ::p/placeholder-prefixes #{">"}}
     ::p/mutate  pc/mutate
     ::p/plugins [(pc/connect-plugin {::pc/register registry})
                  p/error-handler-plugin
                  p/trace-plugin]}))

(comment
  (c/with-progress-reporting
    (c/quick-bench
      (parser {} [{:items [:x]}]))))

wilkerlucio 2020-12-18T00:49:08.031300Z

Pathom 2.2: Execution time mean : 93.091257 µs

wilkerlucio 2020-12-18T00:49:24.031500Z

Pathom 2.3: Execution time mean : 97.180679 µs

wilkerlucio 2020-12-18T00:49:52.031700Z

so aparently its not just something about the reader process, I wonder if there is something around custom plugins or anything that got affected to make such difference in your case

tony.kay 2020-12-18T01:13:36.031900Z

I think you need each item to have props

tony.kay 2020-12-18T01:13:54.032100Z

mine has 3 levels of depth, but you’re right, it could be a plugin

tony.kay 2020-12-18T01:14:12.032300Z

I did not actually measure real overhead

tony.kay 2020-12-18T01:14:27.032500Z

(of every bit)

tony.kay 2020-12-18T01:22:09.032700Z

should final work ok with siblings?

wilkerlucio 2020-12-18T01:22:50.032900Z

ah, I think I had an error on the measure, got redo

wilkerlucio 2020-12-18T01:22:55.033100Z

what you mean siblings?

tony.kay 2020-12-18T01:22:57.033300Z

query [{:a […]} {:other […]}]..can both siblings say final?

tony.kay 2020-12-18T01:23:08.033500Z

on their lists of return values

tony.kay 2020-12-18T01:23:23.033800Z

i.e. resolver for :a and :other

wilkerlucio 2020-12-18T01:24:05.034Z

yeah, you can make any list or a map final

tony.kay 2020-12-18T01:24:47.034200Z

ok, yeah, I think that is working…I’ve peppered it around and broke something, so was verifying I understood

tony.kay 2020-12-18T01:38:20.034500Z

@wilkerlucio could you push that to clojars? (at least the snapshot)?

tony.kay 2020-12-18T01:38:30.034700Z

I want to try on my staging server, and it won’t have local root

wilkerlucio 2020-12-18T01:38:47.034900Z

no problem, you mean at this commit: https://github.com/wilkerlucio/pathom/compare/hotfix-final-2.3?expand=1

wilkerlucio 2020-12-18T01:38:49.035100Z

correct?

tony.kay 2020-12-18T01:38:56.035300Z

the last one you did

wilkerlucio 2020-12-18T01:39:04.035500Z

yeah

tony.kay 2020-12-18T01:39:12.035700Z

I’m at 58b3d629e6ef464199a06d7fcde627c403fa9d59

wilkerlucio 2020-12-18T01:39:54.035900Z

pushed snapshot for you to try on staging

tony.kay 2020-12-18T01:39:58.036100Z

Did you see phronmophobic on #fulcro getting Fulcro working with Swing (I think…maybe AWT) 🙂

tony.kay 2020-12-18T01:40:06.036300Z

thanks

tony.kay 2020-12-18T01:40:14.036500Z

entertaining

wilkerlucio 2020-12-18T01:41:08.036700Z

wow, didn't, that's cool!

wilkerlucio 2020-12-18T01:41:31.036900Z

(snapshot ends in -3, if you need to confirm during some pipeline)

tony.kay 2020-12-18T01:42:53.037200Z

yeah, not retrieving yet…clojars must be slow

tony.kay 2020-12-18T01:46:50.037400Z

duh…should just use a frikkin sha

kenny 2020-12-18T17:26:33.040700Z

I have a ::pc/batch? resolver that throws an exception. After the exception is thrown, it appears that the resolver gets called again for each item in the list, throwing each time. This results in thousands of exceptions getting thrown for a single resolver call. Is there a way to tell the resolver to end the calls if the batch resolver throws?

wilkerlucio 2020-12-18T21:04:56.040800Z

hello, yes, its like that, what you can do is wrap the error in a try catch, and just provide empty state for the records (as if it returned all blank), this wya Pathom wont try to process then, this may help: https://cljdoc.org/d/com.wsscode/pathom/2.3.0/api/com.wsscode.pathom.connect#batch-restore-sort