1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 19:17:38 +08:00

98 Commits

Author SHA1 Message Date
wdvxdr
8a518ee96c
dep: drop github.com/klauspost/compress 2022-02-13 17:08:11 +08:00
wdvxdr
28637c41be
internal/proto: move binary.DynamicProtoMessage to proto.DynamicMessage 2022-02-10 21:56:40 +08:00
wdvxdr
a3b4e1b994
client: move parse packet logic to transport 2021-12-24 17:18:42 +08:00
wdvxdr
254eef3a5a
internal/oicq: reduce lambda 2021-12-24 14:22:10 +08:00
源文雨
cf864799cb
fix: WriteIntLvPacket length error (#226) 2021-12-23 23:04:13 +08:00
源文雨
3e84f279c1
fix: use general write at method (#225)
* fix: use general write at method

* fix: drop WriteShortBufLenExcludeSelfAfterPos
2021-12-23 22:09:04 +08:00
源文雨
b1279cf08f
perf(writer): drop some lambda expressions (#224)
* perf(writer): drop some lambda expressions

* perf(writer): drop more lambda expressions

* fix: resolve conflicts

* perf(writer): drop more lambda expressions

* fix: modify function name

* perf(writer): drop more lambda expressions

* fix: some error
2021-12-23 21:04:15 +08:00
wdvxdr
8b99d3147e
style: fix issues reported by golangci-lint 2021-12-16 20:21:49 +08:00
wdvxdr
2e6b21bfef
remove 256k & 128k pool 2021-12-15 19:20:30 +08:00
wdvxdr
b398cec6a5
refactor: move highway.go to client/internal/highway 2021-12-15 19:13:52 +08:00
wdvxdr
5ff69f3c3a
binary/jce: use go/parser generator 2021-12-12 14:38:03 +08:00
源文雨
45692b75f8
fix(jce): ToByes lost some fields of SvcReqRegisterNew (#217) 2021-12-12 00:04:15 +08:00
fumiama
bcde705a75 fix: codegen error & drop all reflect in jce 2021-12-10 14:49:53 +08:00
fumiama
ed7199def8 fix: gen rely on jce 2021-12-09 23:30:12 +08:00
fumiama
f1d2259956 fix(jce): replacment not equivalent 2021-12-09 22:47:16 +08:00
fumiama
b041fc20e8 perf(jce): drop most reflect in writer
name                           old time/op    new time/op     delta
JceWriter_WriteMap-8             2.34µs ± 2%     0.69µs ± 4%   -70.63%  (p=0.008 n=5+5)
JceWriter_WriteJceStructRaw-8    1.28µs ± 1%     0.42µs ± 1%   -66.86%  (p=0.008 n=5+5)

name                           old speed      new speed       delta
JceWriter_WriteMap-8           39.7MB/s ± 2%  135.4MB/s ± 4%  +240.56%  (p=0.008 n=5+5)
JceWriter_WriteJceStructRaw-8  82.3MB/s ± 1%  219.9MB/s ± 1%  +167.32%  (p=0.008 n=5+5)

name                           old alloc/op   new alloc/op    delta
JceWriter_WriteMap-8             1.30kB ± 0%     0.21kB ± 0%   -84.05%  (p=0.008 n=5+5)
JceWriter_WriteJceStructRaw-8      640B ± 0%       208B ± 0%   -67.50%  (p=0.008 n=5+5)

name                           old allocs/op  new allocs/op   delta
JceWriter_WriteMap-8               30.0 ± 0%        2.0 ± 0%   -93.33%  (p=0.008 n=5+5)
JceWriter_WriteJceStructRaw-8      15.0 ± 0%        2.0 ± 0%   -86.67%  (p=0.008 n=5+5)
2021-12-09 22:25:53 +08:00
fumiama
d3ab5965d5 fix(#209): OpenWriterF encode error 2021-12-04 20:31:11 +08:00
fumiama
13a9d087e7 perf(jce): drop reflect in reader
name                   old time/op    new time/op    delta
JceReader_ReadSlice-8    1.53ms ±90%    0.82ms ±86%  -46.30%  (p=0.017 n=16+16)

name                   old speed      new speed      delta
JceReader_ReadSlice-8   117MB/s ± 3%   228MB/s ± 4%  +94.43%  (p=0.000 n=16+16)

name                   old alloc/op   new alloc/op   delta
JceReader_ReadSlice-8     516kB ±88%     536kB ±85%     ~     (p=0.780 n=16+16)

name                   old allocs/op  new allocs/op  delta
JceReader_ReadSlice-8     25.6k ±88%     26.6k ±85%     ~     (p=0.780 n=16+16)
2021-11-26 15:02:44 +08:00
fumiama
a70e0f20de perf: add 0 alloc func OpenWriterF 2021-11-23 16:21:06 +08:00
fumiama
26579583cc drop(pool): unnecessay nil judge 2021-11-23 15:35:52 +08:00
fumiama
ec053573f1 perf(tea): use runtime.fastrand
name          old time/op    new time/op    delta
TEAen/16-8       242ns ± 1%     225ns ± 2%  -6.98%  (p=0.008 n=5+5)
TEAen/256-8     1.71µs ± 0%    1.68µs ± 0%  -1.58%  (p=0.008 n=5+5)
TEAen/4K-8      25.0µs ± 1%    25.0µs ± 0%    ~     (p=1.000 n=5+5)
TEAen/32K-8      202µs ± 1%     202µs ± 0%    ~     (p=0.548 n=5+5)
TEAde/16-8       208ns ± 0%     207ns ± 0%    ~     (p=0.198 n=5+5)
TEAde/256-8     1.65µs ± 0%    1.64µs ± 0%  -0.39%  (p=0.048 n=5+5)
TEAde/4K-8      24.6µs ± 0%    24.6µs ± 1%    ~     (p=1.000 n=5+5)
TEAde/32K-8      199µs ± 0%     199µs ± 0%    ~     (p=0.905 n=4+5)

name          old speed      new speed      delta
TEAen/16-8    66.2MB/s ± 1%  71.2MB/s ± 2%  +7.51%  (p=0.008 n=5+5)
TEAen/256-8    150MB/s ± 0%   152MB/s ± 0%  +1.61%  (p=0.008 n=5+5)
TEAen/4K-8     164MB/s ± 1%   164MB/s ± 0%    ~     (p=1.000 n=5+5)
TEAen/32K-8    162MB/s ± 1%   162MB/s ± 0%    ~     (p=0.548 n=5+5)
TEAde/16-8     154MB/s ± 0%   154MB/s ± 0%    ~     (p=0.222 n=5+5)
TEAde/256-8    165MB/s ± 0%   165MB/s ± 0%    ~     (p=0.056 n=5+5)
TEAde/4K-8     167MB/s ± 0%   167MB/s ± 1%    ~     (p=1.000 n=5+5)
TEAde/32K-8    165MB/s ± 0%   165MB/s ± 0%    ~     (p=0.825 n=4+5)
2021-11-23 13:18:58 +08:00
Blackjack200
70af1fee57
rename NewWriter to SelectWriter 2021-11-21 12:58:34 +08:00
wdvxdr
97dcddb6d4
jce: speed up read
don't use bytes.Buffer to inline more functions

name                            old time/op    new time/op    delta
JceReader_ReadSlice-8              614µs ±68%     523µs ±70%     ~     (p=0.690 n=5+5)
RequestDataVersion2_ReadFrom-8    3.98µs ± 1%    3.54µs ± 2%  -10.96%  (p=0.008 n=5+5)

name                            old speed      new speed      delta
JceReader_ReadSlice-8            104MB/s ± 7%   121MB/s ± 2%  +16.68%  (p=0.008 n=5+5)
RequestDataVersion2_ReadFrom-8  23.4MB/s ± 1%  26.3MB/s ± 2%  +12.33%  (p=0.008 n=5+5)

name                            old alloc/op   new alloc/op   delta
JceReader_ReadSlice-8              196kB ±67%     184kB ±67%     ~     (p=0.690 n=5+5)
RequestDataVersion2_ReadFrom-8    2.59kB ± 0%    2.62kB ± 0%   +1.04%  (p=0.008 n=5+5)

name                            old allocs/op  new allocs/op  delta
JceReader_ReadSlice-8              9.02k ±67%     9.02k ±67%     ~     (p=1.000 n=5+5)
RequestDataVersion2_ReadFrom-8      46.0 ± 0%      44.0 ± 0%   -4.35%  (p=0.008 n=5+5)
2021-11-20 20:54:19 +08:00
wdvxdr
43b23f4e6f
jce: speed up write
name                           old time/op    new time/op    delta
JceWriter_WriteMap-8             2.46µs ± 1%    2.37µs ± 1%   -3.88%  (p=0.000 n=9+9)
JceWriter_WriteJceStructRaw-8    1.78µs ± 1%    1.29µs ± 1%  -27.38%  (p=0.000 n=9+10)

name                           old speed      new speed      delta
JceWriter_WriteMap-8           37.7MB/s ± 1%  39.3MB/s ± 1%   +4.04%  (p=0.000 n=9+9)
JceWriter_WriteJceStructRaw-8  59.0MB/s ± 1%  81.3MB/s ± 1%  +37.70%  (p=0.000 n=9+10)

name                           old alloc/op   new alloc/op   delta
JceWriter_WriteMap-8             1.30kB ± 0%    1.30kB ± 0%     ~     (all equal)
JceWriter_WriteJceStructRaw-8      724B ± 0%      640B ± 0%  -11.60%  (p=0.000 n=10+10)

name                           old allocs/op  new allocs/op  delta
JceWriter_WriteMap-8               30.0 ± 0%      30.0 ± 0%     ~     (all equal)
JceWriter_WriteJceStructRaw-8      29.0 ± 0%      15.0 ± 0%  -48.28%  (p=0.000 n=10+10)
2021-11-20 11:38:24 +08:00
wdvxdr
574c4e57b1
perf(tea): unrolling encode
name         old time/op    new time/op    delta
TEAen/16-8      237ns ± 0%     227ns ± 1%  -4.03%  (p=0.008 n=5+5)
TEAen/256-8    1.69µs ± 0%    1.60µs ± 1%  -4.83%  (p=0.008 n=5+5)
TEAen/4K-8     25.0µs ± 1%    23.8µs ± 2%  -4.73%  (p=0.008 n=5+5)
TEAen/32K-8     199µs ± 1%     188µs ± 1%  -5.30%  (p=0.008 n=5+5)
TEAde/16-8      196ns ± 1%     194ns ± 1%  -0.89%  (p=0.016 n=5+5)
TEAde/256-8    1.56µs ± 0%    1.54µs ± 0%  -1.50%  (p=0.008 n=5+5)
TEAde/4K-8     23.5µs ± 0%    23.2µs ± 0%  -1.46%  (p=0.008 n=5+5)
TEAde/32K-8     187µs ± 1%     184µs ± 1%  -1.50%  (p=0.008 n=5+5)

name         old speed      new speed      delta
TEAen/16-8   67.6MB/s ± 1%  70.5MB/s ± 1%  +4.20%  (p=0.008 n=5+5)
TEAen/256-8   152MB/s ± 0%   160MB/s ± 1%  +5.07%  (p=0.008 n=5+5)
TEAen/4K-8    164MB/s ± 1%   172MB/s ± 2%  +4.98%  (p=0.008 n=5+5)
TEAen/32K-8   165MB/s ± 1%   174MB/s ± 1%  +5.60%  (p=0.008 n=5+5)
TEAde/16-8    163MB/s ± 1%   165MB/s ± 1%  +0.90%  (p=0.016 n=5+5)
TEAde/256-8   174MB/s ± 0%   177MB/s ± 0%  +1.51%  (p=0.008 n=5+5)
TEAde/4K-8    175MB/s ± 0%   177MB/s ± 0%  +1.48%  (p=0.008 n=5+5)
TEAde/32K-8   175MB/s ± 1%   178MB/s ± 1%  +1.52%  (p=0.008 n=5+5)
2021-11-17 13:33:25 +08:00
wdvxdr
a69487056d
drop unsafe in TEA encryption
name         old time/op    new time/op    delta
TEAen/16-8      245ns ± 0%     237ns ± 0%  -3.29%  (p=0.008 n=5+5)
TEAen/256-8    1.73µs ± 0%    1.69µs ± 0%  -2.77%  (p=0.008 n=5+5)
TEAen/4K-8     24.9µs ± 0%    25.0µs ± 1%    ~     (p=0.690 n=5+5)
TEAen/32K-8     198µs ± 0%     199µs ± 1%  +0.73%  (p=0.008 n=5+5)
TEAde/16-8      215ns ± 1%     196ns ± 1%  -8.93%  (p=0.008 n=5+5)
TEAde/256-8    1.70µs ± 0%    1.56µs ± 0%  -8.08%  (p=0.008 n=5+5)
TEAde/4K-8     24.9µs ± 1%    23.5µs ± 0%  -5.50%  (p=0.008 n=5+5)
TEAde/32K-8     198µs ± 0%     187µs ± 1%  -5.34%  (p=0.008 n=5+5)

name         old speed      new speed      delta
TEAen/16-8   65.4MB/s ± 0%  67.6MB/s ± 1%  +3.39%  (p=0.008 n=5+5)
TEAen/256-8   148MB/s ± 0%   152MB/s ± 0%  +2.84%  (p=0.008 n=5+5)
TEAen/4K-8    164MB/s ± 0%   164MB/s ± 1%    ~     (p=0.587 n=5+5)
TEAen/32K-8   166MB/s ± 0%   165MB/s ± 1%  -0.72%  (p=0.008 n=5+5)
TEAde/16-8    149MB/s ± 1%   163MB/s ± 1%  +9.81%  (p=0.008 n=5+5)
TEAde/256-8   160MB/s ± 0%   174MB/s ± 0%  +8.80%  (p=0.008 n=5+5)
TEAde/4K-8    165MB/s ± 1%   175MB/s ± 0%  +5.81%  (p=0.008 n=5+5)
TEAde/32K-8   166MB/s ± 0%   175MB/s ± 1%  +5.70%  (p=0.008 n=5+5)
2021-11-16 20:54:40 +08:00
wdvxdr
2a92b2755f
perf: speed up tea encrypt & decrypt
name         old time/op    new time/op    delta
TEAen/16-8      260ns ± 0%     245ns ± 0%   -5.83%  (p=0.008 n=5+5)
TEAen/256-8    1.86µs ± 0%    1.73µs ± 0%   -6.86%  (p=0.008 n=5+5)
TEAen/4K-8     27.8µs ± 0%    24.9µs ± 0%  -10.19%  (p=0.008 n=5+5)
TEAde/16-8      223ns ± 1%     215ns ± 1%   -3.24%  (p=0.008 n=5+5)
TEAde/256-8    1.88µs ± 0%    1.70µs ± 0%   -9.49%  (p=0.000 n=4+5)
TEAde/4K-8     28.1µs ± 1%    24.9µs ± 1%  -11.43%  (p=0.008 n=5+5)

name         old speed      new speed      delta
TEAen/16-8   61.6MB/s ± 0%  65.4MB/s ± 0%   +6.19%  (p=0.008 n=5+5)
TEAen/256-8   138MB/s ± 0%   148MB/s ± 0%   +7.35%  (p=0.008 n=5+5)
TEAen/4K-8    147MB/s ± 0%   164MB/s ± 0%  +11.34%  (p=0.008 n=5+5)
TEAde/16-8    144MB/s ± 1%   149MB/s ± 1%   +3.34%  (p=0.008 n=5+5)
TEAde/256-8   145MB/s ± 0%   160MB/s ± 0%  +10.47%  (p=0.016 n=4+5)
TEAde/4K-8    146MB/s ± 1%   165MB/s ± 1%  +12.90%  (p=0.008 n=5+5)
2021-11-12 11:40:40 +08:00
Mrs4s
af9ed48cb7
feat: query guild service image 2021-11-09 03:16:26 +08:00
wdvxdr
aba75d5733
fix: fix wrong byte array length in (*encoder).u32 2021-11-07 13:58:46 +08:00
wdvxdr
21ff14fd5c
optimize(binary): allow inline (*encoder).svarint
name                       old time/op  new time/op  delta
encoder_svarint/short-8   7.12ns ± 2%  6.24ns ± 2%  -12.36%  (p=0.000 n=10+9)
encoder_svarint/medium-8  8.86ns ± 3%  7.82ns ± 2%  -11.76%  (p=0.000 n=10+10)
encoder_svarint/large-8   12.2ns ± 1%  11.4ns ± 2%   -5.99%  (p=0.000 n=10+10)

BTW, (*encoder).u32 and (*encoder).u64 can be inlined with go1.18
2021-11-07 13:56:40 +08:00
wdvxdr
4a777539be
test: add benchmark for (*encoder).uvarint 2021-11-07 13:28:17 +08:00
Mrs4s
991f69f141
feat: ChannelService.FetchGuestGuild 2021-11-06 23:37:33 +08:00
Mrs4s
4dfdc22a70
style: cleanup dynamic proto encode 2021-11-06 15:27:56 +08:00
wdvxdr
7e2033fd75
test: unify tea benchmark 2021-11-06 14:41:47 +08:00
Mrs4s
606ad69679
feat: GetGuildMembers 2021-11-06 14:12:03 +08:00
wdvxdr
80e2d83dab
fix: only read protobuf on known sub-type
Fixes Mrs4s/go-cqhttp#1120
2021-10-21 18:01:33 +08:00
wdvxdr
3b85d69fd3
dep: use github.com/klauspost/compress 2021-10-16 22:11:21 +08:00
wdvxdr
2cdb7407f9
clean: remove unused method 2021-10-05 23:33:39 +08:00
wdvxdr
fd9a6657fa
drop dep jsoniter&reflect2.
for smaller binary size.
2021-08-25 16:16:08 +08:00
wdvxdr
7bed7a3657
jce: optimize JceWriter_WriteMap.
name                  old time/op    new time/op    delta
JceWriter_WriteMap-8    4.09µs ± 3%    2.44µs ± 1%  -40.39%  (p=0.000 n=10+8)

name                  old speed      new speed      delta
JceWriter_WriteMap-8  22.8MB/s ± 3%  38.2MB/s ± 1%  +67.73%  (p=0.000 n=10+8)

name                  old alloc/op   new alloc/op   delta
JceWriter_WriteMap-8    2.34kB ± 0%    1.30kB ± 0%  -44.37%  (p=0.000 n=10+10)

name                  old allocs/op  new allocs/op  delta
JceWriter_WriteMap-8      52.0 ± 0%      30.0 ± 0%  -42.31%  (p=0.000 n=10+10)
2021-08-17 17:06:00 +08:00
wdvxdr
53ac47950c
jce: optimize readByte.
name                            old time/op    new time/op    delta
JceReader_ReadSlice-8              271µs ± 2%     228µs ± 7%  -15.97%  (p=0.000 n=9+10)
RequestDataVersion2_ReadFrom-8    4.57µs ± 6%    4.08µs ± 2%  -10.74%  (p=0.000 n=10+10)

name                            old speed      new speed      delta
JceReader_ReadSlice-8           77.6MB/s ± 2%  92.5MB/s ± 7%  +19.14%  (p=0.000 n=9+10)
RequestDataVersion2_ReadFrom-8  20.4MB/s ± 6%  22.8MB/s ± 2%  +11.92%  (p=0.000 n=10+10)

name                            old alloc/op   new alloc/op   delta
JceReader_ReadSlice-8             73.4kB ± 0%    65.3kB ± 0%  -10.96%  (p=0.000 n=9+6)
RequestDataVersion2_ReadFrom-8    2.64kB ± 0%    2.59kB ± 0%   -1.93%  (p=0.000 n=10+10)

name                            old allocs/op  new allocs/op  delta
JceReader_ReadSlice-8              6.02k ± 0%     3.01k ± 0%  -49.96%  (p=0.000 n=10+10)
RequestDataVersion2_ReadFrom-8      67.0 ± 0%      46.0 ± 0%  -31.34%  (p=0.000 n=10+10)
2021-08-17 16:32:16 +08:00
wdvxdr
0ca0c6ea45
jce: readHead return non-ptr.
avoid escape.

name                            old time/op    new time/op    delta
JceReader_ReadSlice-8              469µs ± 1%     238µs ± 2%  -49.40%  (p=0.000 n=8+9)
RequestDataVersion2_ReadFrom-8    5.72µs ± 5%    4.12µs ± 4%  -28.04%  (p=0.000 n=9+10)

name                            old speed      new speed      delta
JceReader_ReadSlice-8           44.8MB/s ± 1%  88.6MB/s ± 2%  +97.66%  (p=0.000 n=8+9)
RequestDataVersion2_ReadFrom-8  16.3MB/s ± 6%  22.6MB/s ± 4%  +38.89%  (p=0.000 n=9+10)

name                            old alloc/op   new alloc/op   delta
JceReader_ReadSlice-8              266kB ± 0%      73kB ± 0%  -72.40%  (p=0.000 n=8+7)
RequestDataVersion2_ReadFrom-8    3.74kB ± 0%    2.64kB ± 0%  -29.49%  (p=0.000 n=10+10)

name                            old allocs/op  new allocs/op  delta
JceReader_ReadSlice-8              18.0k ± 0%      6.0k ± 0%  -66.66%  (p=0.000 n=10+10)
RequestDataVersion2_ReadFrom-8       136 ± 0%        67 ± 0%  -50.74%  (p=0.000 n=10+10)
2021-08-17 12:01:45 +08:00
wdvxdr
ad174508ff
clean(jce): use new ReadBytes rather than ReadAny.
use rsc.io/rf tool:

rf '
  ex {
    var reader *JceReader
    var tag int
    reader.ReadAny(tag).([]byte) -> reader.ReadBytes(tag)
  }
'
2021-08-13 15:35:26 +08:00
wdvxdr
1abbeb148a
feat(jce): new api *JceReader.ReadBytes. 2021-08-13 15:29:07 +08:00
wdvxdr
3ed9b8d698
clean(jce): remove ReadMapF. 2021-08-12 23:28:21 +08:00
wdvxdr
9814f5295d
refactor(jce): use ReadMap & remove ReadMapF.
name                            old time/op    new time/op    delta
RequestDataVersion2_ReadFrom-8    5.58µs ± 1%    5.78µs ± 2%   +3.64%  (p=0.000 n=9+9)

name                            old speed      new speed      delta
RequestDataVersion2_ReadFrom-8  16.7MB/s ± 1%  16.1MB/s ± 2%   -3.52%  (p=0.000 n=9+9)

name                            old alloc/op   new alloc/op   delta
RequestDataVersion2_ReadFrom-8    5.40kB ± 0%    3.74kB ± 0%  -30.67%  (p=0.000 n=10+10)

name                            old allocs/op  new allocs/op  delta
RequestDataVersion2_ReadFrom-8       147 ± 0%       136 ± 0%   -7.48%  (p=0.000 n=10+10)
2021-08-12 23:24:58 +08:00
wdvxdr
f4fca58809
feat(jce): optimize ReadSlice performance.
name                   old time/op    new time/op    delta
JceReader_ReadSlice-8    1.09ms ± 7%    0.52ms ± 1%   -52.48%  (p=0.000 n=10+10)

name                   old speed      new speed      delta
JceReader_ReadSlice-8  19.4MB/s ± 7%  40.8MB/s ± 1%  +110.25%  (p=0.000 n=10+10)

name                   old alloc/op   new alloc/op   delta
JceReader_ReadSlice-8     594kB ± 1%     266kB ± 0%   -55.22%  (p=0.000 n=9+9)

name                   old allocs/op  new allocs/op  delta
JceReader_ReadSlice-8     22.6k ± 0%     18.0k ± 0%   -19.98%  (p=0.000 n=10+10)
2021-08-12 20:45:45 +08:00
wdvxdr
1d900b302d
feat: group member shut up timestamp.
Fixes: #174
2021-08-07 16:43:13 +08:00
wdvxdr
b7dee2aeb2
use binary package in reader. 2021-07-13 10:17:36 +08:00
wdvxdr
4aa87a8ab8
dep: remove github.com/golang/protobuf 2021-06-11 14:23:46 +08:00