Benchmark Says No — The Mattermost Platformer #16
Published: 2022-07-22 08:03:38

_This post is part of a series previously posted in the public ["The Platformer"](https://community.mattermost.com/core/channels/the-platformer) channel on [Mattermost's Community](https://community.mattermost.com/) server. "The Platformer" is published on a weekly cadence sharing the latest updates from the [Mattermost](https://www.mattermost.com) platform teams (web, server, mobile and QA). It's an insider look into **how** these teams operate, and **what** they're working on._

There are many reasons why it’s cool to contribute to open source. One reason that is often overlooked is that **simply having a large code base available to the public is value in itself**. Why? _Other_ projects can use these code bases to showcase the value of _their_ tools. I once heard that JetBrains used the Mattermost server repo as a benchmark for their Go tooling. And now, Meta demonstrated the performance improvement their new [Hermes engine](https://reactnative.dev/docs/hermes) makes in React Native, by [using Mattermost as a benchmark application](https://reactnative.dev/blog/2022/07/08/hermes-as-the-default). Check that post for animated GIFs (pronounced “jiffs” by the way) to get a visual feel of the performance boost from this engine. Also it’s great to see v1 in action again. Those were the days huh. Oh my, v2 is so much nicer looking (and faster).

And once more, purely coincidentally we got ourselves a theme of the week: performance and benchmarking. Performance is a complicated topic and tends to become a bit of a game of whack-a-mole: you solve one performance issue, but then a bit later it reappears, or another one appears elsewhere. That’s not great. There must be a better way, no? More on this in a bit, first let’s get to the weekly pickings of the fruits.

## Cherry picks
On the **mobile platform** end, the team is a bit thinly populated this week (half is out), but we keep chugging along in terms of bringing v2 to feature parity with v1, focusing on [upgrading settings screens](https://github.com/mattermost/mattermost-mobile/pull/6491) (almost there) and our ever expanding end-to-end test coverage (even with some test performance improvements this week!). 

On the **web platform** end, we are experimenting with “theme weeks” as a budgeting hack to work on _important but not urgent stuff_. This first theme week (and this will likely be a recurring one) is focused on 🥁 _performance_! We’re pulling in a whole bunch of tickets accumulated over time of smaller things we can optimize for performance. Some of these improvements are [already](https://github.com/mattermost/mattermost-webapp/pull/10811) [landing](https://github.com/mattermost/mattermost-webapp/pull/10813).

On the **desktop platform** end, [translations have landed](https://github.com/mattermost/desktop/pull/2190)! If you know some language that is not English, join [our localization channel](https://community.mattermost.com/core/channels/localization) and help out getting the desktop app translated to your favorite and least favorite languages! There’s also work in progress to [improve window resizing](https://github.com/mattermost/desktop/pull/2204) _performance_. The resizing performance regressed to be comically slow on some OSes, as you can see in my _jiff_ attached to that PR.

On the **server platform** side, we’re firing on all four cylinders (now that Alejandro officially joined us 🎉) this week. He started running load tests with [Postgres 12, showing a significant performance boost](https://github.com/mattermost/mattermost-load-test-ng/pull/498). Isn’t it great when simply bumping an (open source) dependency makes your product _way_ faster, effectively for free (free as in beer)? We’re also debugging cloud production issues around the _performance_ of plugin downloads. On the refactoring side, we continue to make progress on spreading the [context](https://github.com/mattermost/mattermost-server/pull/20575) [love](https://github.com/mattermost/mattermost-server/pull/20674) across our code base, and refactoring the multi-product architecture into larger services [according to The Plan™️](https://docs.google.com/document/d/1kgMZY9QN5V9qqyy9etdthk5lQk4dAYOG6mDedHNcN3k/edit?usp=sharing). We’re also fixing a bug in GraphQL that broke guest logins on community, until then, GraphQL is disabled (so if you’re feeling less _graphy_ this week, now you know why).

On the **QA platform** side, more work is done on our build pipelines for mobile, in close collaboration with the mobile platform team. It seems that our set of “unstable” end-to-end tests needs a bit more love, and be lowered from the 260 tests (out of a total of 1600+), because we had a case where a regression wasn’t caught even though we had a test for it (this test was in the “unstable” suite and we missed it). Further: another week, another cloud release. There’s still opportunity to further oil this release machine (for _performance_ — I had to work that in somehow).

## The Performance Regression Challenge
Here’s a conversation I’ve been having multiple times over the last months: so we invest a lot in fixing performance issues in `<<INSERT CLIENT HERE>>`. How do we prove that they:

1. Make a material difference (are **high impact**)
2. Don’t regress again tomorrow (are **lasting**)

This is a problem we have tackled on the server side already. We have a [load test tool](https://github.com/mattermost/mattermost-load-test-ng) and a test suite where we can verify the performance of a substantial part of the (server side) of our product in a reproducible way. As long as y’all keep adding your features to this suite (_hint hint!_). We run this suite at least every release to make sure there’s no performance regressions.

But of course the server side is only a part of the story. We have to figure out how to do this for our clients as well.

The ideal situation is that as part of our CI job (e.g. run in the context of a PR), we are able to run a performance regression suite, which compares the results of this run with previous runs and gives a 👍 or 👎 based on this (ideally fully automated). In Little Britain parlance, [“computer says no”](https://www.youtube.com/watch?v=qNDS4kVwA68) to any commit that makes performance worse.

This is easier said than done, because we have to be able to control a lot of variables. I think this worth the research & development, though. Ideally, we find a reusable solutions that we can leverage across our clients and server as well. I’ll bring some people together to brainstorm on this topic to see if this could be a potential thing to work on in Q4. 

Ultimately we have to be able to put trustworthy numbers on our performance improvement work (to complement our nice looking _jiffs_). And if we’re able to do that, we may as well use those numbers to detect regressions.

If anybody has experience or ideas on how to do this in web app or mobile app contexts, please let us know.

And that’s all for this week. Have a great weekend!