Commit Graph

97 Commits

Author SHA1 Message Date
Agniva De Sarker
76d492f9ab MM-37186: Update dependencies (#18604)
* MM-37186: Update dependencies

The split client libraries were excluded from being upgraded.

See: https://github.com/splitio/go-split-commons/issues/56

https://mattermost.atlassian.net/browse/MM-37186

```release-note
NONE
```

* Ignore staticcheck deprecation warnings

```release-note
NONE
```
2021-10-07 12:57:51 +05:30
Miguel de la Cruz
a9101d62a6 Update to bleve v2 and to use the scorch index (#18266)
Automatic Merge
2021-09-17 10:59:02 +02:00
Doug Lauder
bb659d03fd Fix plugin logging missing context fields
Fix an issue where context fields logged by server on behalf of plugins didn't contain correct name/value pairs:
- bump Logr version to add key/value methods to sugar logger
- expose factory args when configuring logging with custom target types (needed for FocalBoard to create log target adapter that converts typed fields into slices of interface{} as per plugin logging API)
2021-09-13 10:12:18 -04:00
Joram Wilander
e9935e44bd Bump go.mod and docker go version to 1.16 (#18280)
* Bump go.mod go version to 1.16

* Bump docker build go version to 1.16.7
2021-08-27 08:08:03 -04:00
Doug Lauder
a4507327a7 MM-36764 mlog refactor (#18118)
Refactor mlog
- simplify mlog by removing redundant code
- remove Zap dependency
- update unit test helpers
- update logging config
- update auditing
2021-08-17 16:08:04 -04:00
Jesús Espino
b9cceb70ae Making doc extraction more reliable (#17842)
* Making doc extraction more reliable

* fix error message

* Adding test doc file

* Removing test that not works on CI because the lack of a binary

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-07-29 11:57:51 +02:00
Claudio Costa
1ae1c38c9f [MM-36995] Start using db native JSON datatypes (#17930)
* Start using db native JSON datatypes

* Fix syntax to work on MySQL 5.7.12
2021-07-28 08:50:36 +02:00
Agniva De Sarker
c4b4e1bc38 MM-36271: Bump major version to 6.0 (#17973)
https://mattermost.atlassian.net/browse/MM-36271

```release-note
We bump the major version to 6.0
```
2021-07-22 12:21:47 +05:30
Agniva De Sarker
14acff5466 Use original opengraph dependency (#17855)
The PR is now merged with the original repo, so we can remove
the temporary replace.

https://focalboard-community.octo.mattermost.com/workspace/zyoahc9uapdn3xdptac6jb69ic?id=285b80a3-257d-41f6-8cf4-ed80ca9d92e5&v=495cdb4d-c13a-4992-8eb9-80cfee2819a4&c=59af323d-35a7-4312-87a1-e374239a03d9

```release-note
NONE
```
2021-07-06 15:44:35 -04:00
Agniva De Sarker
97e3c550a4 Use forked version of gziphandler (#17852) 2021-06-30 14:39:28 +05:30
Agniva De Sarker
ec8aaec5ce MM-36486: Bump dependencies (#17830)
* MM-36486: Bump dependencies

https://mattermost.atlassian.net/browse/MM-36486

```release-note
NONE
```

* Added collector dependency

* Trigger CI

* Trigger CI

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-06-29 20:49:19 +05:30
Ahmad Karlam
081f4a5123 [MM-11143] Strip markdown formatting characters from push notifications (#17775)
* WIP: trim markdown for push notification

* fix: golangci

* fix: table regex

* fix: regex code block

* doc: add license

* WIP: custom renderer with goldmark

* WIP: update goldmark version to 1.38

* fix: use goldmark as parser

* fix: remove table extension

* fix: change buf to `strings.Builder`

* fix: return original string, log warning if error

* refactor: change `WriteString` to `WriteByte`

* refactor: change if condition

* refactor: use assertion

* refactor: move to inline

* fix: remove handle multiline

Already handled by mobile

* refactor: wrap same function

* refactor: move strip markdown to `sendPushNotificationSync`

* refactor: renaming variable aren't used

* fix: move log to func `sendPushNotificationSync`

* docs: add comment to `StripMarkdown`

* fix: move assign message to else

* appErr to err rename

Co-authored-by: Agniva De Sarker <agnivade@yahoo.co.in>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-06-29 08:54:13 +05:30
Agniva De Sarker
3299a72adb MM-34932: Bump dependencies (#17708)
https://mattermost.atlassian.net/browse/MM-34932

```release-note
NONE
```
2021-06-03 12:59:05 +05:30
Claudio Costa
3984381011 [MM-13799] Avoid queries timing out during upgrade (#17444)
* Avoid timing out during upgrade

* Update gorp dep

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-04-19 20:34:21 +02:00
Agniva De Sarker
b950125d4e MM-33945: Update dependencies (#17201)
* MM-33945: Update dependencies

Ran `make update-dependencies`

https://mattermost.atlassian.net/browse/MM-33945

```release-notes
NONE
```

* fix test
2021-03-25 14:45:13 +05:30
Agniva De Sarker
aba6471512 revertws (#17216)
* Revert "MM-34000: Use non-epoll mode for TLS connections (#17172)"

This reverts commit 2743089b54.

* Revert "MM-33233: Fix double close of webconn pump (#17026)"

This reverts commit 0f98620b65.

* Revert "MM-33836: Detect and upgrade incorrect HTTP version for websocket handshakes (#17142)"

This reverts commit 4c5ea07aff.

* revert i18n

* Revert "MM-21012: Revamp websocket implementation (#16620)"

This reverts commit a246104d04.

* fix go.mod

* Trigger CI
2021-03-24 15:29:23 +05:30
Agniva De Sarker
33e319366c MM-34080: Removing sqlite entirely (#17188)
* MM-34080: Removing sqlite entirely

The initial commit missed removing this blank import.
So the library still remained in our vendor directory.
Removing it for good now.

Bye bye sqlite.

https://mattermost.atlassian.net/browse/MM-34080

* fix go.mod
2021-03-19 20:23:23 +05:30
Agniva De Sarker
91099818df MM-32961: Bump dependencies (#17016)
Ran `make update-dependencies`

https://mattermost.atlassian.net/browse/MM-32961
2021-03-09 11:26:42 +05:30
Joram Wilander
aba00a3cfd Update split SDK to 6.0.2 to fix sync bug (#17060)
* Update split SDK to 6.0.2 to fix sync bug

* Vendor and tidy
2021-03-04 11:16:08 -05:00
John Tzikas
809affd6d1 Create basic make commands for configuring golang-migrate (#16938)
* Create basic make commands for configuring golang-migrate

* Showcase full flow with new migrations

* Apply PR suggestions

* Migrate over team members

* Update mocks

* Fix specs

* Move columns that added after table creation onto separate stmts

* Put back gorp table definitions

* Fix issues with golang-migrate that not tracks underlying db driver

* Help prompt after new migration and consistent checksum for bindata

* Put gorp mapping back

* Apply PR suggestiong

* Close migrations after they run

* Add migration file to bindata check

* Updates needed

* Reset store_test

* Add copyright

* Apply PR suggestions

* Fix new circleci check

* Put back upgrade step for backwards comp

* Add store test to test migration directions

* Apply PR suggestions

* Add go-bindata to tools

* Apply PR suggestios

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-02-23 16:22:31 +02:00
Jesús Espino
59d33b9002 Migrate channel to waitgroup for access the store in parallel (#16926)
* Migrate channel to waitgroup for access the store in parallel

* Addressing PR review comments

* Using a cleanest way of group errors

* Reverting go.mod change
2021-02-15 19:32:45 +01:00
Agniva De Sarker
a246104d04 MM-21012: Revamp websocket implementation (#16620)
* MM-21012: Revamp websocket implementation

We replace the old gorilla/websocket implementation with the
gobwas/ws library. The gorilla library was in maintenance mode
and had a high level API due to which we cannot use that for
situations where a large number of concurrent connections needs
to be supported.

The ws library is a very low-level library that allows us
to work with raw net.Conns. We make several improvements:

- We completely remove the reader goroutines, and instead
replace them with a manual epoll implementation which sends off
messages to be read when it receives any data on the connection.
This lets us scale to a much larger number of connections.
- The reader buffer is eliminated, because we directly read
from the connection now.

https://mattermost.atlassian.net/browse/MM-21012

```release-notes
Improved the websocket implementation by using epoll manually
to read from a websocket. As a result, the number of goroutines
is expected to go down by half.
```

* fix tests

* fix shadowing errors

* final changes

* windows support!

* Remove pointer to waitgroup

* Fix edge case

* Trigger CI

* Trigger CI

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-02-13 23:42:11 +05:30
Rodrigo Villablanca
9e561aa491 Set required go version to 1.15 (#16922) 2021-02-12 23:23:11 +05:30
Agniva De Sarker
1cb019c0d8 MM-32048: Upgrade dependencies (#16765)
```release-note
Updated Go dependencies to their latest minor version
```

https://mattermost.atlassian.net/browse/MM-32048
2021-01-21 22:17:05 +05:30
Agniva De Sarker
346c8b01b2 Fix go.mod to give priority to go mod tidy (#16685)
There is a race between go mod tidy and go mod vendor
due to https://github.com/golang/go/issues/37376.

However, if we give priority to go mod vendor, then
gopls complains of inconsistent vendoring. We make go mod tidy happy
as it's a more commonly used command than go mod vendor,
and is a common problem faced by other devs too
2021-01-13 19:14:52 +05:30
Agniva De Sarker
091659c8ad MM-31436: Upgrade dependencies (#16605)
* MM-31436: Upgrade dependencies

Ran make update-dependencies

https://mattermost.atlassian.net/browse/MM-31436

```release-note
NONE
```

* add missing dep

* fix lru marshaling
2021-01-07 14:39:17 +05:30
Agniva De Sarker
727a158e9a MM-31511: Fix incorrect replace repo (#16603)
The package paths were changed. Therefore, go mod tidy
on master failed with:

```
go: finding module for package github.com/hmhealey/go-opengraph/opengraph
go: found github.com/hmhealey/go-opengraph/opengraph in github.com/hmhealey/go-opengraph v0.0.0-20201209151214-f2d823730dba
go: github.com/hmhealey/go-opengraph@v0.0.0-20201209151214-f2d823730dba used for two different module paths (github.com/dyatlov/go-opengraph and github.com/hmhealey/go-opengraph)
```

https://mattermost.atlassian.net/browse/MM-31511

```release-note
NONE
```
2020-12-24 15:26:22 +05:30
Harrison Healey
1367418e3c MM-31171 Fork OpenGraph library to handle bad HTML from YouTube (#16528) 2020-12-10 15:42:23 -05:00
Agniva De Sarker
17194f2edf MM-30708: Fix racy TestLdapConnect/STARTTLS_connection (#16448)
```release-note
NONE
```

https://mattermost.atlassian.net/browse/MM-30708

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-12-07 22:44:32 +05:30
Christopher Speller
1aadd36644 MM-28859 Add feature flag managment system using split.io and remove viper. (#15954)
* Add feature flag managment system using split.io and remove viper.

* Fixing tests.

* Attempt to fix postgres tests.

* Fix watch filepath for advanced logging.

* Review fixes.

* Some error wrapping.

* Remove unessisary store interface.

* Desanitize SplitKey

* Simplify.

* Review feedback.

* Rename split mlog adatper to split logger.

* fsInner

* Style.

* Restore oldcfg test.

* Downgrading non-actionable feature flag errors to warnings.

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-10-29 15:54:39 -07:00
Jesús Espino
8d5be2d657 Document extractor service (#15665)
* Document extractor service

* Fixing vendor modules

* Addressing PR Review comments

* Some small simplifications

* Fixing a linter complain

* simplifying a bit the code using package variables

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-10-27 15:58:38 +01:00
Agniva De Sarker
087758caee MM-28737: Upgrade dependencies (#15877)
https://mattermost.atlassian.net/browse/MM-28737

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-10-25 22:09:55 +05:30
catalintomai
1c0d590c81 Add AWS Metering service support (#15290) 2020-09-28 11:43:08 -07:00
Eli Yukelzon
4e9ddd4686 MM-27918 In-Product notices support (#15316) 2020-09-21 10:28:46 +03:00
Agniva De Sarker
96a3407b7a Optimize gzip compression of responses (#15416)
It looks like maintainers aren't very active on the repo
and https://github.com/nytimes/gziphandler/pull/107 has come to a standstill.

I don't want to wait forever for this to go in. Let's use a replace directive
to point to the fork. When the PR gets merged, we can just bump the dependency
and remove the replace directive.

Re: the PR, copying the text from the PR description

This gives 40-50% improvements in CPU with very minor increase
in memory, just as a drop-in replacement. I think that is a very reasonable tradeoff.

The library is mature and safe to be used in production.

```
name                 old time/op    new time/op    delta
GzipHandler_S2k-8      74.9µs ± 2%    34.4µs ± 2%  -54.07%  (p=0.000 n=10+9)
GzipHandler_S20k-8      379µs ± 1%     226µs ± 3%  -40.42%  (p=0.000 n=9+10)
GzipHandler_S100k-8    1.95ms ± 2%    1.15ms ± 1%  -41.27%  (p=0.000 n=9+9)
GzipHandler_P2k-8      24.3µs ±25%    10.7µs ±25%  -55.80%  (p=0.000 n=10+10)
GzipHandler_P20k-8      132µs ± 2%      75µs ± 1%  -42.95%  (p=0.000 n=9+10)
GzipHandler_P100k-8     658µs ± 2%     371µs ± 3%  -43.68%  (p=0.000 n=9+10)

name                 old alloc/op   new alloc/op   delta
GzipHandler_S2k-8      7.71kB ± 5%    9.13kB ± 7%  +18.33%  (p=0.000 n=10+10)
GzipHandler_S20k-8     65.1kB ± 3%    70.3kB ± 3%   +8.05%  (p=0.000 n=10+10)
GzipHandler_S100k-8     348kB ± 4%     382kB ± 2%   +9.85%  (p=0.000 n=10+10)
GzipHandler_P2k-8      7.60kB ± 1%    7.93kB ± 2%   +4.33%  (p=0.000 n=10+10)
GzipHandler_P20k-8     64.4kB ± 1%    66.3kB ± 2%   +2.92%  (p=0.000 n=10+10)
GzipHandler_P100k-8     304kB ± 1%     309kB ± 1%   +1.67%  (p=0.000 n=10+9)

name                 old allocs/op  new allocs/op  delta
GzipHandler_S2k-8        21.0 ± 0%      21.0 ± 0%     ~     (all equal)
GzipHandler_S20k-8       24.0 ± 0%      24.0 ± 0%     ~     (all equal)
GzipHandler_S100k-8      27.0 ± 0%      27.0 ± 0%     ~     (all equal)
GzipHandler_P2k-8        21.0 ± 0%      21.0 ± 0%     ~     (all equal)
GzipHandler_P20k-8       24.0 ± 0%      24.0 ± 0%     ~     (all equal)
GzipHandler_P100k-8      26.0 ± 0%      26.0 ± 0%     ~     (all equal)
```

https://mattermost.atlassian.net/browse/MM-28491
2020-09-10 09:02:20 +05:30
Doug Lauder
1b67322fb9 MM-27744 disable Zap for unit tests. (#15398)
MM-27744 disable Zap for unit tests.

Zap has no concept of shutdown or close. Zap is only shutdown when the app exits. Not a problem for console logging, but when creating a new Zap logger that outputs to files on every unit test, that leaves no easy way to clean up until process exit. Depending on what else is running this can exhaust all file handles and cause unit tests to fail.

Zap is now disabled unit tests and uses Logr instead, regardless of config settings. `make test-server` peak file handle usage dropped from ~5K to less than 100.
2020-09-09 15:25:55 -04:00
Agniva De Sarker
f2a8e10216 MM-27613: Update dependencies (#15294)
https://mattermost.atlassian.net/browse/MM-27613
2020-09-03 10:00:12 +05:30
Doug Lauder
05f1f35a00 MM-22786 enterprise metrics for logging (#15313)
Adds metrics for logging engine which are collected by Prometheus.
- current queue level(s)
- rate of logging records emitted
- rate of logging errors
2020-09-01 10:29:29 -04:00
Elisabeth Kulzer
c368dc7838 Implement empty translation check. (#15364) 2020-08-31 10:43:09 +02:00
Gabe Jackson
90ef61f74c Add functionality to update password with password hash (#15343)
* Add functionality to update password with password hash

This can be used to update a user's password with a direct password
hash instead of providing the password in plaintext.

* Use test helper for local mode
2020-08-26 17:28:00 +02:00
nickmisasi
769f39eee5 [MM-27535] User invite limits for MM Cloud (#15197)
* Add a config for MM User Limit

* Adding graceful errors for if an administrator invites people passed their user limit

* Including changed vendor files

* Adding unit test

* Fix a bug

* Push up working tests (Thanks Joram)

* Add more cases, clean up logs in code

* One more case

* Refactoring based on PR comments

* Updating i18n

* Some changes based on PR review

* Remove a comment

* Bring back some translations that were somehow removed

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-08-19 16:01:07 -04:00
Mario de Frutos Dieguez
f619de2c83 [MM-25673] Upgrades and migrations to start using master gorp (#14823)
Database changes needed to reflect gorp master changes
2020-08-18 10:43:56 +02:00
Agniva De Sarker
91a76b2df9 MM-27456: Use reflect-free serialization for hot structs (#15171)
Automatic Merge
2020-08-13 03:35:57 -04:00
Claudio Costa
c89c56ab2e [MM-27328] Upgrade minio-go to v7 (#15177)
* Upgrade minio-go to v7

* Update to v7.0.3

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-08-12 19:53:47 +02:00
Jesús Espino
ce82ff7e2b Add psd preview support (#15078)
* Add psd preview support

* Adding required vendor files

* Adding oov/psd license to NOTICE.txt file

* Adding the license notice for gopherjs to the NOTICE.txt

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-07-31 14:46:22 +02:00
Doug Lauder
90ff87a77f MM-25731 Advanced Logging (#14888)
Adds Advanced Logging to server. Advanced Logging is an optional logging capability that allows customers to send log records to any number of destinations.

Supported destinations:
- file
- syslog (with out without TLS)
- raw TCP socket (with out without TLS)

Allows developers to specify discrete log levels as well as the standard trace, debug, info, ... panic. Existing code and logging API usage is unchanged.

Log records are emitted asynchronously to reduce latency to the caller. Supports hot-reloading of logger config, including adding removing targets.

Advanced Logging is configured within config.json via "LogSettings.AdvancedLoggingConfig" which can contain a filespec to another config file, a database DSN, or JSON.
2020-07-15 14:40:36 -04:00
Agniva De Sarker
d3156395a1 MM-25943: Upgrade dependencies for server (#14932)
* MM-25943: Upgrade dependencies for server

* tmp
2020-06-29 17:49:46 +05:30
George Goldberg
e5addef19b MM-23574: Remove Segment. (#14712)
* MM-23574: Eliminate Segment.

* Update dependencies.

* Fix review suggestions.
2020-06-22 08:35:03 +01:00
Agniva De Sarker
ef85001523 MM-25710: Use an efficient cache serialization algorithm (#14826)
* MM-25710: Use an efficient cache serialization algorithm

We investigate 3 packages for selecting a suitable replacement
for gob encoding. The algorithm chosen was msgpack which gives
a decent boost over the standard gob encoding.

Any external schema dependent algorithms like protobuf, flatbuffers, avro,
capn'proto were not considered as that would entail converting the model structs
into separate schema objects and then code generating the Go structs.
It could be done theoretically at a later stage specifically for structs
which are in the hot path. This is a general solution for now.

The packages considered were:
- github.com/tinylib/msgp
- github.com/ugorji/go/codec
- github.com/vmihailenco/msgpack/v5

msgp uses code generation to generate encoding/decoding code without the reflection overhead.
Theoretically, therefore this is supposed to give the fastest performance. However, a major
flaw in that package is that it works only at a file/directory level, not at a package level.
Therefore, for structs which are spread across multiple files, it becomes near to impossible
to chase down all transitive dependencies to generate the code. Even if that's done, it fails
on some complex type like xml.Name and time.Time. (See: https://github.com/tinylib/msgp/issues/274#issuecomment-643654611)

Therefore, we are left with 2 choices. Both of them use the same underlying algorithm.
But msgpack/v5 wraps the encoders/decoders in a sync.Pool. To make a perfect apples-apples
comparison, I wrote a sync.Pool for ugorji/go/codec too and compared performance.

msgpack/v5 came out to be the fastest by a small margin.

benchstat master.txt ugorji.txt
name               old time/op    new time/op    delta
LRU/simple=new-8     5.62µs ± 3%    3.68µs ± 2%  -34.64%  (p=0.000 n=10+10)
LRU/complex=new-8    38.4µs ± 2%     9.1µs ± 2%  -76.38%  (p=0.000 n=9+9)
LRU/User=new-8       75.8µs ± 2%    23.5µs ± 2%  -69.01%  (p=0.000 n=10+10)
LRU/Post=new-8        125µs ± 2%      21µs ± 3%  -82.92%  (p=0.000 n=9+10)
LRU/Status=new-8     27.6µs ± 1%     5.4µs ± 4%  -80.34%  (p=0.000 n=10+10)

name               old alloc/op   new alloc/op   delta
LRU/simple=new-8     3.20kB ± 0%    1.60kB ± 0%  -49.97%  (p=0.000 n=10+10)
LRU/complex=new-8    15.7kB ± 0%     4.4kB ± 0%  -71.89%  (p=0.000 n=9+10)
LRU/User=new-8       33.5kB ± 0%     9.2kB ± 0%  -72.48%  (p=0.000 n=10+8)
LRU/Post=new-8       38.7kB ± 0%     4.8kB ± 0%  -87.48%  (p=0.000 n=10+10)
LRU/Status=new-8     10.6kB ± 0%     1.7kB ± 0%  -83.50%  (p=0.000 n=10+10)

name               old allocs/op  new allocs/op  delta
LRU/simple=new-8       46.0 ± 0%      20.0 ± 0%  -56.52%  (p=0.000 n=10+10)
LRU/complex=new-8       324 ± 0%        48 ± 0%  -85.19%  (p=0.000 n=10+10)
LRU/User=new-8          622 ± 0%       108 ± 0%  -82.64%  (p=0.000 n=10+10)
LRU/Post=new-8          902 ± 0%        74 ± 0%  -91.80%  (p=0.000 n=10+10)
LRU/Status=new-8        242 ± 0%        22 ± 0%  -90.91%  (p=0.000 n=10+10)

11:31:48-~/mattermost/mattermost-server/services/cache2$benchstat master.txt vmi.txt
name               old time/op    new time/op    delta
LRU/simple=new-8     5.62µs ± 3%    3.68µs ± 3%  -34.59%  (p=0.000 n=10+10)
LRU/complex=new-8    38.4µs ± 2%     8.7µs ± 3%  -77.45%  (p=0.000 n=9+10)
LRU/User=new-8       75.8µs ± 2%    20.9µs ± 1%  -72.45%  (p=0.000 n=10+10)
LRU/Post=new-8        125µs ± 2%      21µs ± 2%  -83.08%  (p=0.000 n=9+10)
LRU/Status=new-8     27.6µs ± 1%     5.1µs ± 3%  -81.66%  (p=0.000 n=10+10)

name               old alloc/op   new alloc/op   delta
LRU/simple=new-8     3.20kB ± 0%    1.60kB ± 0%  -49.89%  (p=0.000 n=10+10)
LRU/complex=new-8    15.7kB ± 0%     4.6kB ± 0%  -70.87%  (p=0.000 n=9+8)
LRU/User=new-8       33.5kB ± 0%    10.3kB ± 0%  -69.40%  (p=0.000 n=10+9)
LRU/Post=new-8       38.7kB ± 0%     6.0kB ± 0%  -84.62%  (p=0.000 n=10+10)
LRU/Status=new-8     10.6kB ± 0%     1.9kB ± 0%  -82.41%  (p=0.000 n=10+10)

name               old allocs/op  new allocs/op  delta
LRU/simple=new-8       46.0 ± 0%      20.0 ± 0%  -56.52%  (p=0.000 n=10+10)
LRU/complex=new-8       324 ± 0%        46 ± 0%  -85.80%  (p=0.000 n=10+10)
LRU/User=new-8          622 ± 0%       106 ± 0%  -82.96%  (p=0.000 n=10+10)
LRU/Post=new-8          902 ± 0%        89 ± 0%  -90.13%  (p=0.000 n=10+10)
LRU/Status=new-8        242 ± 0%        23 ± 0%  -90.50%  (p=0.000 n=10+10)

In general, we can see that the time to marshal/unmarshal pays off as the size of the struct
increases.

We can see that msgpack/v5 is faster for CPU but very slightly heavier on memory.
Since we are interested in fastest speed, we choose msgpack/v5.

As a future optimization, we can use a mix of msgpack and msgp for hot structs.
To do that, we would need to shuffle around some code so that for the hot struct,
all its dependencies are in the same file.

Let's use this in production for some time, watch grafana graphs for the hottest caches
and come back to optimizing this more once we have more data.

Side note: we have to do with micro-benchmarks for the time being, because all the caches
aren't migrated to cache2 interface yet. Once that's in, we can actually run some load tests
and do comparisons.

* Bring back missing import

* Fix tests
2020-06-18 17:21:39 +05:30
Martin Kraft
2bb6071f73 MM-26065: Reverts Brotli encoding. (#14834)
* MM-26065: Reverts Brotli encoding.

* MM-26065: Removes package reference.
2020-06-16 18:15:31 -04:00