Fork me on GitHub
#hoplon
<
2016-05-13
>
leontalbot14:05:58

Ok Hoplon, quick question : In do-watch, what is the init argument?

leontalbot14:05:06

(defn do-watch
  ([atom f]
   (do-watch atom nil f))
  ([atom init f]
   (with-let [k (gensym)]
     (f init @atom)
     (add-watch atom k (fn [_ _ old new] (f old new))))))
 

leontalbot14:05:44

any examples?

leontalbot14:05:57

(we need a docstring here!)

leontalbot14:05:17

Let's build a docstring, okay?

leontalbot14:05:05

Other question

leontalbot14:05:26

I have a cell content-state that gets updated once, when the db loads the content-state data.

leontalbot14:05:13

I have this in my views. (cell= (map #(view-item :id %) (map :id content-state))

leontalbot14:05:27

And it gets slow

leontalbot14:05:55

when click on a button, it takes a while to update, etc.

dm314:05:26

Chrome profiler is great for these kinds of things

dm314:05:32

i.e. are you sure it's that line that takes all the time?

leontalbot14:05:25

didn't know about Chrome profiler

leontalbot14:05:21

It seems like (program) takes some time, what is this?

dm314:05:31

you should see better on the flame graph

dm314:05:42

this just says that it spends all of its time checking equivalence and creating seqs

dm314:05:54

you want to see your functions in the profile

leontalbot14:05:11

@dm3 r.handle the jquery thing takes a while

leontalbot15:05:03

ok, no I get it better

leontalbot15:05:16

scrolling down, I see a bit more

leontalbot15:05:15

(do-watch fetch-db-success
          #(when %2
             (reset! content-state
                     (vectorify-all form-content-vectors %2))))

leontalbot15:05:08

Can I close a do-watch after the db is fetched, so after it's first f call (reset!) ?

donmullen15:05:50

^ @alandipert @micha interested to learn more

leontalbot15:05:03

Oh, the loop-tpl thing seems slow too

dm315:05:18

ideally you'd extract some of you functions to top level from cells so that you could see them in the trace

dm315:05:34

none of the Hoplon fns are slow by themselves

dm315:05:49

rather you're doing a huge number of recomputations

leontalbot15:05:04

Yes, in (cell= (map #(view-item :id %) (map :id content-state)) my view-item-fn is pretty slow

leontalbot15:05:54

But the thing is, if I could at least deref content-state when db-fetch is done, I could save some time I think

leontalbot15:05:28

But How to deref-once-loaded?

dm315:05:11

do-watch?

leontalbot15:05:41

not sure how

leontalbot15:05:04

I already have this

leontalbot15:05:13

(do-watch fetch-db-success
          #(when %2
             (reset! content-state
                     (vectorify-all form-content-vectors %2))))

leontalbot15:05:58

Not sure where to deref what

dm315:05:27

not sure what you will gain by derefing content-state

micha15:05:45

@donmullen: we just deploy to ASGs now, without beanstalk

micha15:05:30

we have some simple scripts that we use to create ASGs with a user-data script that knows how to download application and run a Makefile

donmullen15:05:58

ASG - auto-scaling group (?)

micha15:05:13

but the overall organization is similar to beanstalk, eg. we have the concept of "applications" which can contain "environments"

micha15:05:20

yes ASG -> autoscaling group

micha15:05:45

that's the basic unit we allocate in AWS now

micha15:05:01

even if it will only contain a single instance, we still have that instance created by an ASG

micha15:05:33

environments for us are simply ASGs

micha15:05:45

ASGs are basically instnace factories

donmullen15:05:49

@micha - Interesting - thanks. Anything OSS yet - or planned? — similar to boot-beanstalk?

micha15:05:01

so once you create them you can easily create and manage instances

micha15:05:22

i can show you the scripts, they're really very simple

micha15:05:28

trivial even

micha15:05:44

all they do is call the aws api to create things and give those things sane names

micha15:05:02

like if you have an environment named foo-prod, all the things in AWs will be named foo-prod

donmullen15:05:12

cool - looking for pointers to give to a dev spinning up aws.

micha15:05:18

so you don't have like awseb-9832457fnsdjfwertoisghsd names

micha15:05:45

i can't stand getting alerts on pagerduty with those kinds of eb names

leontalbot16:05:17

@dm3: was 10x faster when content-state was hardcoded and static

leontalbot16:05:37

my state machine is bad 😞

dm316:05:19

it seems you're waiting for the network call to finish in order to make the first render, no?

leontalbot16:05:26

I could do it server side and pass in params to hoplon page?

dm316:05:42

depends on what you want to do

dm316:05:55

you need to decide on the pre-loaded state first

leontalbot16:05:28

What could I do on the client?

leontalbot16:05:44

(pretending I rely on rpc call)

leontalbot16:05:56

(no server prerendering)

dm316:05:08

show "Loading..." state

leontalbot16:05:17

I do it already

leontalbot16:05:09

It is slow, but my problem is more, when I interact with stuff like buttons

leontalbot16:05:15

the delay is huge

leontalbot16:05:27

because content-state get updated

dm316:05:55

so you press a button, then content-state gets updated, then you recompute the view-items which takes all the time?

dm316:05:27

well, if that's really the case - you have to reduce the work you're doing

dm316:05:21

if the network call eats time - you can only work around it by adding loading states

dm316:05:47

if it's actual computation - you need to cache/limit the things you're recomputing

leontalbot16:05:12

I solved the lagging problem 1.4s -> 0.15 s

leontalbot16:05:00

I create a second cell that has the same data but is not updated

leontalbot16:05:12

works like a charm!

leontalbot16:05:51

I now need to find a way to pre-fetch data...

leontalbot16:05:58

will study castra