* MM-24972: make GetHubForUserId lock-less and zero-alloc The hubs aren't meant to be modified after the server starts up. But the key problem was the SetHubs method which would zero out the underlying hubs slice. This wasn't ideally necessary because an hub would only be stopped once during server shutdown. However, this was required by a test which would shutdown the hub twice. And since the hub shutdown isn't idempotent, zeroing the slice would just skip over shutting down the hub again. To improve the overall situation, we apply several optimizations. - We use the new hash/maphash package which exposes Go runtime's internal hash algorithms to be used as a package. This is much faster than hash/fnv. - We move around the initialization of the hub to happen before the metrics server starts. This allows us to initialize the hub before any of the hub elements are being accessed. - To make the test run successfully, we do not call th.TearDown. This is fine for a test, because anyways the test process would eventually stop and relinquish the resources to the OS. This allows us to completely remove any mutexes and thereby we can remove all the methods and any edge-case checks related to index being out of bounds. As a result, the fast path becomes very straightforward and zero-alloc. name old time/op new time/op delta GetHubForUserId-8 116ns ± 1% 38ns ± 7% -67.22% (p=0.000 n=10+10) name old alloc/op new alloc/op delta GetHubForUserId-8 36.0B ± 0% 0.0B -100.00% (p=0.000 n=10+10) name old allocs/op new allocs/op delta GetHubForUserId-8 2.00 ± 0% 0.00 -100.00% (p=0.000 n=10+10) Manually tested with some load testing and running Hub tests in -race mode. * remove mutex * incorporate review comments
Mattermost is an open source, private cloud, Slack-alternative from https://mattermost.com.
It's written in Golang and React and runs as a single Linux binary with MySQL or PostgreSQL. Every month on the 16th a new compiled version is released under an MIT license.
Try out Mattermost
- Join the Mattermost Contributor's server to join community discussions about contributions, development and more
- Join the Mattermost Demo server to try out Mattermost and explore sample use cases
Deploy on Heroku
Note: Heroku preview does not include email or persistent storage
Deploy on a Cloud Platform via Bitnami
Auto-deploy Mattermost to Amazon Web Services, Azure, Google Cloud Platform, or Oracle Cloud Platform via Bitnami.
Install on Your Own Machine
- One-line Docker Preview
- Developer Machine Setup
- Production Install Guides using Linux Binary
- Production Docker Install
Native Mobile and Desktop Apps
In addition to the web interface, you can also download Mattermost clients for Android, iOS, Windows PC, Mac OSX, and Linux.
Get Security Bulletins
Receive notifications of critical security updates. The sophistication of online attackers is perpetually increasing. If you are deploying Mattermost it is highly recommended you subscribe to the Mattermost Security Bulletin mailing list for updates on critical security releases.
Get Involved
- Contribute Code
- Find "Help Wanted" projects
- Join Developer Discussion on a Mattermost Server for contributors
- File Bugs
- Share Feature Ideas
- Get Troubleshooting Help
- Help translate Mattermost
Learn More
- API Options - webhooks, slash commands, drivers and web service
- See who's using Mattermost
- Browse over 700 Mattermost integrations
Get the Latest News
- Twitter - Follow Mattermost
- Blog - Get the latest updates from the Mattermost blog.
- Email - Subscribe to our newsletter (1 or 2 per month)
- Mattermost - Join the ~contributors channel on the Mattermost Community Server.
- IRC - Join the #matterbridge channel on Freenode (thanks to matterircd).
Any other questions, mail us at info@mattermost.com. We’d love to meet you!





