Agniva De Sarker
3563e56a77
MM-54998: Optimize JSON marshalling in websocket broadcast ( #25286 )
...
Marshalling a json.RawMessage is not zero overhead. Instead,
it compacts the raw message which starts to have an overhead
at scale.
https://github.com/golang/go/issues/33422
Since we have full control over the message constructed, we
can simply write the byte slice into the network stream.
This gives considerable performance boost.
```
goos: linux
goarch: amd64
pkg: github.com/mattermost/mattermost/server/public/model
cpu: Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
│ old.txt │ new_2.txt │
│ sec/op │ sec/op vs base │
EncodeJSON-8 1640.5n ± 2% 289.6n ± 1% -82.35% (p=0.000 n=10)
│ old.txt │ new_2.txt │
│ B/op │ B/op vs base │
EncodeJSON-8 528.0 ± 0% 503.0 ± 0% -4.73% (p=0.000 n=10)
│ old.txt │ new_2.txt │
│ allocs/op │ allocs/op vs base │
EncodeJSON-8 5.000 ± 0% 4.000 ± 0% -20.00% (p=0.000 n=10)
```
P.S. No concerns over changing the model API because we are
still using 0.x
https://mattermost.atlassian.net/browse/MM-54998
```release-note
Improve websocket event marshalling performance
```
2023-11-08 12:15:24 +05:30
..
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-10-11 10:13:36 +02:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-10-11 10:13:36 +02:00
2023-10-11 10:13:36 +02:00
2023-10-24 15:08:14 +02:00
2023-10-11 10:13:36 +02:00
2023-05-10 13:07:02 -03:00
2023-08-25 17:55:47 -07:00
2023-05-10 13:07:02 -03:00
2023-06-11 10:54:35 +05:30
2023-06-13 14:08:36 +05:30
2023-06-13 14:08:36 +05:30
2023-10-11 10:13:36 +02:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-07-18 17:25:11 +02:00
2023-10-12 09:47:35 +05:30
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-10-12 09:47:35 +05:30
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-10-24 15:08:14 +02:00
2023-10-11 10:13:36 +02:00
2023-10-17 12:03:28 -04:00
2023-09-06 23:27:35 +03:00
2023-05-10 13:07:02 -03:00
2023-06-30 20:12:56 +05:30
2023-08-10 09:40:49 +05:30
2023-09-07 20:58:20 +05:30
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-06-11 10:54:35 +05:30
2023-05-10 13:07:02 -03:00
2023-10-11 10:13:36 +02:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-06-11 10:54:35 +05:30
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-10-11 10:13:36 +02:00
2023-10-23 10:20:32 +02:00
2023-10-25 16:40:07 +02:00
2023-11-06 15:24:59 -07:00
2023-10-12 09:47:35 +05:30
2023-09-06 08:25:27 -04:00
2023-05-10 13:07:02 -03:00
2023-10-12 10:52:10 -04:00
2023-10-17 11:57:35 -04:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-08-03 12:45:10 -03:00
2023-05-10 13:07:02 -03:00
2023-10-23 11:12:46 -03:00
2023-06-30 20:12:56 +05:30
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-07-19 13:01:39 -07:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-11-01 12:57:13 +01:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-10-11 10:13:36 +02:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-06-13 14:08:36 +05:30
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-10-12 10:52:10 -04:00
2023-05-10 13:07:02 -03:00
2023-10-11 10:13:36 +02:00
2023-05-10 13:07:02 -03:00
2023-10-11 10:13:36 +02:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-08-22 10:39:27 +02:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-10-12 10:52:10 -04:00
2023-05-10 13:07:02 -03:00
2023-06-13 14:08:36 +05:30
2023-05-10 13:07:02 -03:00
2023-10-11 10:13:36 +02:00
2023-06-05 18:42:03 -07:00
2023-05-10 13:07:02 -03:00
2023-10-11 10:13:36 +02:00
2023-05-10 13:07:02 -03:00
2023-07-31 09:12:53 -04:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-06-15 08:23:56 -04:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-10-11 10:13:36 +02:00
2023-06-28 15:31:51 -04:00
2023-06-30 20:12:56 +05:30
2023-10-11 10:13:36 +02:00
2023-10-23 20:22:36 +02:00
2023-05-10 13:07:02 -03:00
2023-09-19 15:29:57 +02:00
2023-05-10 13:07:02 -03:00
2023-10-11 10:13:36 +02:00
2023-08-24 12:33:53 -04:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-06-13 14:08:36 +05:30
2023-05-20 02:04:28 +03:00
2023-07-31 09:12:53 -04:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-10-11 10:13:36 +02:00
2023-07-24 10:31:06 -03:00
2023-05-10 13:07:02 -03:00
2023-06-07 10:15:33 -03:00
2023-06-07 10:15:33 -03:00
2023-09-08 11:00:48 -03:00
2023-06-07 10:15:33 -03:00
2023-05-10 13:07:02 -03:00
2023-10-03 09:51:07 -05:00
2023-10-11 10:13:36 +02:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-10-12 09:47:35 +05:30
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-10-26 22:22:22 +03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-10-12 09:47:35 +05:30
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-10-23 20:22:36 +02:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-08-14 17:54:10 +02:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-10-06 22:43:21 +02:00
2023-10-23 20:22:36 +02:00
2023-05-10 13:07:02 -03:00
2023-10-11 10:13:36 +02:00
2023-10-12 09:47:35 +05:30
2023-05-10 13:07:02 -03:00
2023-11-02 15:52:23 +01:00
2023-06-13 14:08:36 +05:30
2023-06-11 10:54:35 +05:30
2023-11-08 12:15:24 +05:30
2023-11-08 12:15:24 +05:30
2023-06-11 10:54:35 +05:30