Fork me on GitHub
#beginners
<
2020-07-17
>
vlad_poh17:07:04

how do i profile a clojure ring app

vlad_poh17:07:29

i've been using (time body) to find hotspots manually

noisesmith17:07:36

you can use hprof and/or visualvm (free) yourkit (paid)

noisesmith17:07:52

it's the jvm, the jvm has good tooling for this stuff

vlad_poh17:07:55

For example in this function call the timbre log lines adds 3 seconds per function call and the sql query adds half a second. overall takes about 5 seconds to run the first deposit and adds a second per deposit

(defn re-check-edeposits
  [db opts depositid]
  (fn [request]
    (let [_            (timbre/info ::check-edeposits (:headers request))
          sn           (get (-> request :headers) "x-vgs-sn")
          db           (assoc db :dbname sn)
          deposits     (jdbc/query db ["SELECT edeposittransactionid, trans_ref_no, bankdepositstaffid,
                                        edeposittransactionid as order_id,depositamount,
                                        'UNK' as payment_mode
                                        FROM edeposit
                                        WHERE edepositid =? " depositid])
          _            (timbre/info ::check-edeposits|deposits (count deposits))
          _            (doseq [d deposits]
                         (timbre/info ::check-edeposits|deposit d)
                         (validate-edeposit db opts d))]
      (ruhr/ok {:data :running :status 200}))))

noisesmith17:07:14

there's also newrelic

vlad_poh18:07:14

@noisesmith any good tutorials on how to use these hprof/newrelic with clojure? not finding anything helpful in my searches

noisesmith18:07:05

clojure is a java library, all those tools care about is the jvm, which is there to use

👍 3
noisesmith18:07:27

you can simplify things by building a fat jar (uberjar) so they don't get confused by any tooling layers that might accidentally be running

👍 3
vlad_poh18:07:34

ah got it. Thanks!

stopa19:07:30

Hey team, is there a recommended analog to gofmt / prettier that folks use for clojure? (would be great to have one command I can jig up to auto-fmt all the code)

slimslenderslacks05:07:11

hey @U0C5DE6RK, if you want to run cljfmt fix on each Push to GitHub, we created a tool that you can try: https://go.atomist.com/catalog/skills/atomist/cljfmt-skill and there's a version for zprint too: https://go.atomist.com/catalog/skills/atomist/zprint-skill You might find these useful if you're trying to get consistent formatting bootstrapped on a team (while everyone gets cljfmt/zprint/cljstyle into the envs).

❤️ 3
slimslenderslacks05:07:18

here's the repo that implements the function if you're interested: https://github.com/atomist-skills/cljfmt-skill (this is the code that runs when the GitHub app detects a Push)

❤️ 3
noisesmith19:07:53

I've used cljfmt, I bet there's something cooler nowadays

❤️ 3
noisesmith19:07:22

cljfmt has check mode and fix mode, but it's slower to start up than the kind of new stuff @borkdude makes

❤️ 3
noisesmith19:07:35

I knew tagging you in here would be a good idea :D

Mitch21:07:28

Is there a function that removes namespacing from keywords? Currently resorting to (keyword (name ::kw))

alexmiller21:07:00

so that looks good

Mitch21:07:34

thanks, Alex!

Mitch21:07:20

I thought my internet was out until I saw your message lol. Yes, down for me too

👌 3
Mitch21:07:44

Likely to do with a Cloudflare outage

👍 3
seancorfield21:07:14

Yeah, we had a bunch of New Relic alerts appear briefly saying San Francisco couldn't reach our East Coast data center. Everything cleared in a few minutes.