Commit graph

7 commits

Author SHA1 Message Date
2b6d84de9a [#12] Optimize field encoding a bit
No need to clone a map if it is empty.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2023-10-18 11:30:19 +03:00
f358e67c81 [#12] Fix int-like fields encoding
Do it in journal similar to how we do it in zap.
1. Duration should take the form of "12s".
2. Uint64 should be encoded without sign.
3. Bool is better be true/false instead of 0/1.
4. Float64 should be float, not IEEE 754 bits cast to int64.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2023-10-18 11:30:09 +03:00
d6ea4d0bbf [#12] Use buffer pool for message encoding
```
goos: linux
goarch: amd64
pkg: git.frostfs.info/TrueCloudLab/zapjournald
cpu: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
                                     │      1       │                  2                  │
                                     │    sec/op    │   sec/op     vs base                │
Logger/standard/no_fields-8             450.3n ± 2%   452.9n ± 3%        ~ (p=0.138 n=10)
Logger/standard/application_fields-8    610.4n ± 1%   608.4n ± 1%        ~ (p=0.325 n=10)
Logger/standard/journald_fields-8       595.8n ± 5%   604.5n ± 1%        ~ (p=0.075 n=10)
Logger/journald/no_fields-8            1809.0n ± 4%   900.4n ± 1%  -50.23% (p=0.000 n=10)
Logger/journald/application_fields-8    2.037µ ± 5%   1.087µ ± 1%  -46.62% (p=0.000 n=10)
Logger/journald/journald_fields-8       2.054µ ± 4%   1.119µ ± 1%  -45.52% (p=0.000 n=10)
geomean                                 1.036µ        753.1n       -27.33%

                                     │        1        │                  2                   │
                                     │      B/op       │    B/op     vs base                  │
Logger/standard/no_fields-8               0.000 ± 0%     0.000 ± 0%        ~ (p=1.000 n=10) ¹
Logger/standard/application_fields-8      128.0 ± 0%     128.0 ± 0%        ~ (p=1.000 n=10) ¹
Logger/standard/journald_fields-8         64.00 ± 0%     64.00 ± 0%        ~ (p=1.000 n=10) ¹
Logger/journald/no_fields-8            1206.000 ± 0%     5.000 ± 0%  -99.59% (p=0.000 n=10)
Logger/journald/application_fields-8     1494.0 ± 0%     133.0 ± 0%  -91.10% (p=0.000 n=10)
Logger/journald/journald_fields-8       1478.00 ± 0%     85.00 ± 0%  -94.25% (p=0.000 n=10)
geomean                                              ²               -83.36%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                                     │       1       │                  2                   │
                                     │   allocs/op   │ allocs/op   vs base                  │
Logger/standard/no_fields-8             0.000 ± 0%     0.000 ± 0%        ~ (p=1.000 n=10) ¹
Logger/standard/application_fields-8    1.000 ± 0%     1.000 ± 0%        ~ (p=1.000 n=10) ¹
Logger/standard/journald_fields-8       1.000 ± 0%     1.000 ± 0%        ~ (p=1.000 n=10) ¹
Logger/journald/no_fields-8            29.000 ± 0%     1.000 ± 0%  -96.55% (p=0.000 n=10)
Logger/journald/application_fields-8   30.000 ± 0%     2.000 ± 0%  -93.33% (p=0.000 n=10)
Logger/journald/journald_fields-8      31.000 ± 0%     3.000 ± 0%  -90.32% (p=0.000 n=10)
geomean                                            ²               -75.38%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean
```

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2023-10-18 11:30:00 +03:00
8c4cf38d6a [#12] Free internal encoder buffer
```
goos: linux
goarch: amd64
pkg: git.frostfs.info/TrueCloudLab/zapjournald
cpu: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
                                     │     old     │                  1                  │
                                     │   sec/op    │   sec/op     vs base                │
Logger/standard/no_fields-8            435.9n ± 4%   450.3n ± 2%   +3.30% (p=0.041 n=10)
Logger/standard/application_fields-8   629.0n ± 8%   610.4n ± 1%   -2.96% (p=0.002 n=10)
Logger/standard/journald_fields-8      626.8n ± 5%   595.8n ± 5%   -4.95% (p=0.029 n=10)
Logger/journald/no_fields-8            2.097µ ± 3%   1.809µ ± 4%  -13.73% (p=0.000 n=10)
Logger/journald/application_fields-8   2.348µ ± 5%   2.037µ ± 5%  -13.27% (p=0.000 n=10)
Logger/journald/journald_fields-8      2.396µ ± 4%   2.054µ ± 4%  -14.26% (p=0.000 n=10)
geomean                                1.125µ        1.036µ        -7.88%

                                     │      old       │                   1                    │
                                     │      B/op      │     B/op      vs base                  │
Logger/standard/no_fields-8              0.000 ± 0%       0.000 ± 0%        ~ (p=1.000 n=10) ¹
Logger/standard/application_fields-8     128.0 ± 0%       128.0 ± 0%        ~ (p=1.000 n=10) ¹
Logger/standard/journald_fields-8        64.00 ± 0%       64.00 ± 0%        ~ (p=1.000 n=10) ¹
Logger/journald/no_fields-8            2.210Ki ± 0%     1.178Ki ± 0%  -46.71% (p=0.000 n=10)
Logger/journald/application_fields-8   2.491Ki ± 0%     1.459Ki ± 0%  -41.43% (p=0.000 n=10)
Logger/journald/journald_fields-8      2.476Ki ± 0%     1.443Ki ± 0%  -41.70% (p=0.000 n=10)
geomean                                             ²                 -24.72%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                                     │     old      │                  1                  │
                                     │  allocs/op   │ allocs/op   vs base                 │
Logger/standard/no_fields-8            0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Logger/standard/application_fields-8   1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=10) ¹
Logger/standard/journald_fields-8      1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=10) ¹
Logger/journald/no_fields-8            31.00 ± 0%     29.00 ± 0%  -6.45% (p=0.000 n=10)
Logger/journald/application_fields-8   32.00 ± 0%     30.00 ± 0%  -6.25% (p=0.000 n=10)
Logger/journald/journald_fields-8      33.00 ± 0%     31.00 ± 0%  -6.06% (p=0.000 n=10)
geomean                                           ²               -3.18%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean
```

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2023-10-18 11:29:55 +03:00
49c42ba807 [#12] Move log level conversion to a function
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2023-10-18 11:29:53 +03:00
f3f6f54b15 [#7] Add small test for getFieldValue function
Signed-off-by: Aleksey Savaitan <a.savaitan@yadro.com>
2023-04-14 11:00:07 +03:00
Aleksey Savaitan
074fe474dd [#3] Initial implementation
Signed-off-by: Aleksey Savaitan <zxc_off@mail.ru>
2023-04-10 15:35:42 +03:00