react

"mulling over state management stuff"
lilactown 2021-02-25T22:45:35.002700Z

I've been working on a doc at work re: our strategy for tracking performance of our reagent/react SPA. here's the basic rundown so far: * we will need to manually instrument our code with events that record the current time and store them. currently looking at using the browser's User Timing API for this * we'll have to manually relate these events later into spans and measure the duration between events (again using User Timing API), then send these measurements to some backend - currently looking at google analytics User Timings, and/or sending them to our backend metrics recorder so they show up in grafana we're also interested in tying this in with our backend observability tooling by sending these events to honeycomb so that we can see spans from client -> api -> service -> db -> service -> api -> client

lilactown 2021-02-25T22:45:58.003100Z

@roman01la @martinklepsch

lilactown 2021-02-25T22:47:34.004500Z

so far my research has shown that this is sort of the lowest common denominator for using all the APM services out there.

2021-02-25T22:48:45.006200Z

We are instrumenting our code with user timings API as well, works good and wasn't hard to do

2021-02-25T22:49:45.007700Z

In fact we are using performance mark/measure, so that those spans are also visible during debugging in chrome's devtools

1
lilactown 2021-02-25T22:50:31.008400Z

nice, glad to hear that's working well - that's what I'm assuming we would use now but wasn't sure how well it worked in practice

lilactown 2021-02-25T22:51:18.009200Z

how do you know when to call performance.measure() ? do you relate the marks together in code somehow?

2021-02-25T22:55:41.014700Z

We have multiple kinds of measures 1. Navigation: time from user interaction that triggers navigation to when Reagent flushed a specific component into the DOM 2. Text editing: average time per editing session where we measure time from keydown event to when text rendered on a screen 3. Dragging FPS: amount of frames recorded via raf / time user spent dragging something on a screen

2021-02-25T23:00:40.016400Z

And also initial loading time, that just uses a value from user timings object populated by a browser

2021-02-25T23:05:08.018100Z

I don't know what Grafana offers, but we are currently using datadog for perf metrics and it works well so far. The tool provides interesting capabilities such as anomaly detection and alerting

lilactown 2021-02-25T23:09:40.018700Z

nice

lilactown 2021-02-25T23:10:33.019600Z

after you've marked and measured using the user timing api, do you send those directly to data dog immediately?

2021-02-25T23:11:45.020800Z

Sending is throttled, meaning events are sent in batches

2021-02-25T23:13:30.022400Z

Not sure if this could be useful for you, but it's interesting to look at metrics graphs having info about user downlink speed, there's browser API for that

1🧠
2021-02-25T23:14:34.023300Z

That helps to distinguish loading times on fast and slow connections

2021-02-25T23:18:32.025500Z

Also depending on the type of product it could be useful to put users in diff buckets based on amount of data that directly impacts performance

2021-02-25T23:19:36.027300Z

For example in our case one of the metrics puts users in diff buckets depending on the size of a presentation they are opening

2021-02-25T23:24:47.030100Z

I guess there's little info about perf metrics for rich web apps because they are diff for every product, unlike websites like medium or online shops where everything boils down to optimizing for loading times

lilactown 2021-02-25T23:25:08.030300Z

right

lilactown 2021-02-25T23:26:46.032400Z

so it sounds like you've hooked into the reagent lifecycle? or into react's lifecycle?

2021-02-25T23:27:00.032700Z

I found this resource to be very useful https://calendar.perfplanet.com/2020/ from there you can find interesting people in web perf world and follow their work

2021-02-25T23:27:36.033200Z

> so it sounds like you've hooked into the reagent lifecycle? or into react's lifecycle? Regent lifecycle, yes

2021-02-25T23:29:29.033700Z

Are you doing any perf testing on CI?

lilactown 2021-02-25T23:30:02.034200Z

we are currently doing no perf testing or measuring 🤪

lilactown 2021-02-25T23:30:19.034700Z

other than one or two ad hoc things

lilactown 2021-02-25T23:31:10.036200Z

I'm guessing that pitch is far more of a perf sensitive app than ours so I'm happy to learn what you're doing

2021-02-25T23:31:22.036400Z

I see, we are about to work on testing and there's also nothing on that topic, hehe

lilactown 2021-02-25T23:32:27.037700Z

one of the complications I foresee when I was thinking through perf testing is that I want to replicate the type of conditions that a user would actually be interacting with our app

lilactown 2021-02-25T23:33:24.038700Z

so outside of simple benchmarking, I don't really know how useful it would be to measure some over-crowded CI server navigating our app through headless chrome

2021-02-25T23:36:15.041600Z

my view atm is that it could be useful and most importantly reliable for testing UI interactions that purely depend on computations happening on client side, avoiding network basically

2021-02-25T23:37:56.043900Z

dragging stuff around, typing into input fields etc

lilactown 2021-02-25T23:41:01.045Z

I'm basing this on my experience w/ using cypress in CI, which is that weird things happen when you put tests like that on a box running linux and headless chrome with a bunch of other processes running on it

lilactown 2021-02-25T23:41:56.046Z

e.g. some parts of our app were written using re-frame subs controlling text inputs, which meant a bit of lag on most clients but would occasionally flake out and drop key presses when cypress tests ran in CI

2021-02-25T23:43:27.048Z

That's my worry as well, btw Cypress doesn't recommend to use it for perf testing since they are intercepting and controlling timer APIs and a bunch of other things I believe

lilactown 2021-02-25T23:44:55.049Z

right - we use cypress for E2E and integration testing. was using it as the source of my fear re: how apps perform in CI

lilactown 2021-02-25T23:45:07.049200Z

cypress and I are on bad terms rn 😛

2021-02-25T23:47:18.051600Z

I wonder on which UI platforms it's more common to run perf tests? Mobile maybe?

lilactown 2021-02-25T23:47:59.052Z

that's a good question. you would think this would be solved