2020-11-03 11:25:47 +08:00
|
|
|
run:
|
Upgrade go from 1.20 to 1.21 (#33047)
Signed-off-by: shaoting-huang [shaoting-huang@zilliz.com]
issue: https://github.com/milvus-io/milvus/issues/32982
# Background
Go 1.21 introduces several improvements and changes over Go 1.20, which
is quite stable now. According to
[Go 1.21 Release Notes](https://tip.golang.org/doc/go1.21), the big
difference of Go 1.21 is enabling Profile-Guided Optimization by
default, which can improve performance by around 2-14%. Here are the
summary steps of PGO:
1. Build Initial Binary (Without PGO)
2. Deploying the Production Environment
3. Run the program and collect Performance Analysis Data (CPU pprof)
4. Analyze the Collected Data and Select a Performance Profile for PGO
5. Place the Performance Analysis File in the Main Package Directory and
Name It default.pgo
6. go build Detects the default.pgo File and Enables PGO
7. Build and Release the Updated Binary (With PGO)
8. Iterate and Repeat the Above Steps
<img width="657" alt="Screenshot 2024-05-14 at 15 57 01"
src="https://github.com/milvus-io/milvus/assets/167743503/b08d4300-0be1-44dc-801f-ce681dabc581">
# What does this PR do
There are three experiments, search benchmark by Zilliz test platform,
search benchmark by open-source
[VectorDBBench](https://github.com/zilliztech/VectorDBBench?tab=readme-ov-file),
and search benchmark with PGO. We do both search benchmarks by Zilliz
test platform and by VectorDBBench to reduce reliance on a single
experimental result. Besides, we validate the performance enhancement
with PGO.
## Search Benchmark Report by Zilliz Test Platform
An upgrade to Go 1.21 was conducted on a Milvus Standalone server,
equipped with 16 CPUs and 64GB of memory. The search performance was
evaluated using a 1 million entry local dataset with an L2 metric type
in a 768-dimensional space. The system was tested for concurrent
searches with 50 concurrent tasks for 1 hour, each with a 20-second
interval. The reason for using one server rather than two servers to
compare is to guarantee the same data source and same segment state
after compaction.
Test Sequence:
1. Go 1.20 Initial Run: Insert data, build index, load index, and
search.
2. Go 1.20 Rebuild: Rebuild the index with the same dataset, load index,
and search.
3. Go 1.21 Load: Upload to Go 1.21 within the server. Then load the
index from the second run, and search.
4. Go 1.21 Rebuild: Rebuild the index with the same dataset, load index,
and search.
Search Metrics:
| Metric | Go 1.20 | Go 1.20 Rebuild Index | Go 1.21 | Go 1.21 Rebuild
Index |
|----------------------------|------------------|-----------------|------------------|-----------------|
| `search requests` | 10,942,683 | 16,131,726 | 16,200,887 | 16,331,052
|
| `search fails` | 0 | 0 | 0 | 0 |
| `search RT_avg` (ms) | 16.44 | 11.15 | 11.11 | 11.02 |
| `search RT_min` (ms) | 1.30 | 1.28 | 1.31 | 1.26 |
| `search RT_max` (ms) | 446.61 | 233.22 | 235.90 | 147.93 |
| `search TP50` (ms) | 11.74 | 10.46 | 10.43 | 10.35 |
| `search TP99` (ms) | 92.30 | 25.76 | 25.36 | 25.23 |
| `search RPS` | 3,039 | 4,481 | 4,500 | 4,536 |
### Key Findings
The benchmark tests reveal that the index build time with Go 1.20 at
340.39 ms and Go 1.21 at 337.60 ms demonstrated negligible performance
variance in index construction. However, Go 1.21 offers slightly better
performance in search operations compared to Go 1.20, with improvements
in handling concurrent tasks and reducing response times.
## Search Benchmark Report By VectorDb Bench
Follow
[VectorDBBench](https://github.com/zilliztech/VectorDBBench?tab=readme-ov-file)
to create a VectorDb Bench test for Go 1.20 and Go 1.21. We test the
search performance with Go 1.20 and Go 1.21 (without PGO) on the Milvus
Standalone system. The tests were conducted using the Cohere dataset
with 1 million entries in a 768-dimensional space, utilizing the COSINE
metric type.
Search Metrics:
Metric | Go 1.20 | Go 1.21 without PGO
-- | -- | --
Load Duration (seconds) | 1195.95 | 976.37
Queries Per Second (QPS) | 841.62 | 875.89
99th Percentile Serial Latency (seconds) | 0.0047 | 0.0076
Recall | 0.9487 | 0.9489
### Key Findings
Go 1.21 indicates faster index loading times and larger search QPS
handling.
## PGO Performance Test
Milvus has already added
[net/http/pprof](https://pkg.go.dev/net/http/pprof) in the metrics. So
we can curl the CPU profile directly by running
`curl -o default.pgo
"http://${MILVUS_SERVER_IP}:${MILVUS_SERVER_PORT}/debug/pprof/profile?seconds=${TIME_SECOND}"`
to collect the profile as the default.pgo during the first search. Then
I build Milvus with PGO and use the same index to run the search again.
The result is as below:
Search Metrics
| Metric | Go 1.21 Without PGO | Go 1.21 With PGO | Change (%) |
|---------------------------------------------|------------------|-----------------|------------|
| `search Requests` | 2,644,583 | 2,837,726 | +7.30% |
| `search Fails` | 0 | 0 | N/A |
| `search RT_avg` (ms) | 11.34 | 10.57 | -6.78% |
| `search RT_min` (ms) | 1.39 | 1.32 | -5.18% |
| `search RT_max` (ms) | 349.72 | 143.72 | -58.91% |
| `search TP50` (ms) | 10.57 | 9.93 | -6.05% |
| `search TP99` (ms) | 26.14 | 24.16 | -7.56% |
| `search RPS` | 4,407 | 4,729 | +7.30% |
### Key Findings
PGO led to a notable enhancement in search performance, particularly in
reducing the maximum response time by 58% and increasing the search QPS
by 7.3%.
### Further Analysis
Generate a diff flame graphs between two CPU profiles by running `go
tool pprof -http=:8000 -diff_base nopgo.pgo pgo.pgo -normalize`
<img width="1894" alt="goprofiling"
src="https://github.com/milvus-io/milvus/assets/167743503/ab9e91eb-95c7-4963-acd9-d1c3c73ee010">
Further insight of HnswIndexNode and Milvus Search Handler
<img width="1906" alt="hnsw"
src="https://github.com/milvus-io/milvus/assets/167743503/a04cf4a0-7c97-4451-b3cf-98afc20a0b05">
<img width="1873" alt="search_handler"
src="https://github.com/milvus-io/milvus/assets/167743503/5f4d3982-18dd-4115-8e76-460f7f534c7f">
After applying PGO to the Milvus server, the CPU utilization of the
faiss::fvec_L2 function has decreased. This optimization significantly
enhances the performance of the
[HnswIndexNode::Search::searchKnn](https://github.com/zilliztech/knowhere/blob/e0c9c41aa22d8f6e6761a0a54460e4573de15bfe/src/index/hnsw/hnsw.cc#L203)
method, which is frequently invoked by Knowhere during high-concurrency
searches. As the explanation from Go release notes, the function might
be more aggressively inlined by Go compiler during the second build with
the CPU profiling collected from the first run. As a result, the search
handler efficiency within Milvus DataNode has improved, allowing the
server to process a higher number of search queries per second (QPS).
# Conclusion
The combination of Go 1.21 and PGO has led to substantial enhancements
in search performance for Milvus server, particularly in terms of search
QPS and response times, making it more efficient for handling
high-concurrency search operations.
Signed-off-by: shaoting-huang <shaoting.huang@zilliz.com>
2024-05-22 13:21:39 +08:00
|
|
|
go: "1.21"
|
2020-11-03 11:25:47 +08:00
|
|
|
skip-dirs:
|
|
|
|
- build
|
|
|
|
- configs
|
|
|
|
- deployments
|
|
|
|
- docs
|
|
|
|
- scripts
|
|
|
|
- internal/core
|
2023-09-21 09:45:27 +08:00
|
|
|
- cmake_build
|
2024-06-25 10:08:03 +08:00
|
|
|
- mmap
|
|
|
|
- data
|
|
|
|
- ci
|
2024-04-09 11:39:17 +08:00
|
|
|
skip-files:
|
|
|
|
- partial_search_test.go
|
2024-06-25 11:55:07 +08:00
|
|
|
build-tags:
|
|
|
|
- dynamic
|
|
|
|
- test
|
2020-11-03 11:25:47 +08:00
|
|
|
|
|
|
|
linters:
|
2020-11-04 16:28:14 +08:00
|
|
|
disable-all: true
|
2020-11-03 11:25:47 +08:00
|
|
|
enable:
|
2023-09-21 09:45:27 +08:00
|
|
|
- gosimple
|
2020-11-03 11:25:47 +08:00
|
|
|
- govet
|
|
|
|
- ineffassign
|
2023-09-21 09:45:27 +08:00
|
|
|
- staticcheck
|
|
|
|
- decorder
|
|
|
|
- depguard
|
|
|
|
- gofmt
|
|
|
|
- goimports
|
2021-09-18 14:45:50 +08:00
|
|
|
- gosec
|
2021-12-07 19:43:03 +08:00
|
|
|
- revive
|
2023-02-15 17:22:34 +08:00
|
|
|
- unconvert
|
2023-09-21 09:45:27 +08:00
|
|
|
- misspell
|
|
|
|
- typecheck
|
|
|
|
- durationcheck
|
2023-03-10 15:53:53 +08:00
|
|
|
- forbidigo
|
2023-09-21 09:45:27 +08:00
|
|
|
- gci
|
|
|
|
- whitespace
|
|
|
|
- gofumpt
|
2023-09-22 10:05:26 +08:00
|
|
|
- gocritic
|
2022-06-10 14:58:07 +08:00
|
|
|
|
|
|
|
linters-settings:
|
2023-09-21 09:45:27 +08:00
|
|
|
gci:
|
|
|
|
sections:
|
|
|
|
- standard
|
|
|
|
- default
|
|
|
|
- prefix(github.com/milvus-io)
|
|
|
|
custom-order: true
|
2024-06-24 14:52:03 +08:00
|
|
|
govet:
|
|
|
|
enable: # add extra linters
|
|
|
|
- nilness
|
2023-09-21 09:45:27 +08:00
|
|
|
gofumpt:
|
|
|
|
lang-version: "1.18"
|
|
|
|
module-path: github.com/milvus-io
|
|
|
|
goimports:
|
|
|
|
local-prefixes: github.com/milvus-io
|
2023-06-07 19:34:36 +08:00
|
|
|
revive:
|
|
|
|
rules:
|
|
|
|
- name: unused-parameter
|
|
|
|
disabled: true
|
2023-10-07 10:09:31 +08:00
|
|
|
- name: var-naming
|
|
|
|
severity: warning
|
|
|
|
disabled: false
|
|
|
|
arguments:
|
|
|
|
- ["ID"] # Allow list
|
2023-10-07 20:53:38 +08:00
|
|
|
- name: context-as-argument
|
|
|
|
severity: warning
|
|
|
|
disabled: false
|
|
|
|
arguments:
|
|
|
|
- allowTypesBefore: "*testing.T"
|
|
|
|
- name: datarace
|
|
|
|
severity: warning
|
|
|
|
disabled: false
|
|
|
|
- name: duplicated-imports
|
|
|
|
severity: warning
|
|
|
|
disabled: false
|
|
|
|
- name: waitgroup-by-value
|
|
|
|
severity: warning
|
|
|
|
disabled: false
|
|
|
|
- name: indent-error-flow
|
|
|
|
severity: warning
|
|
|
|
disabled: false
|
|
|
|
arguments:
|
|
|
|
- "preserveScope"
|
|
|
|
- name: range-val-in-closure
|
|
|
|
severity: warning
|
|
|
|
disabled: false
|
|
|
|
- name: range-val-address
|
|
|
|
severity: warning
|
|
|
|
disabled: false
|
|
|
|
- name: string-of-int
|
|
|
|
severity: warning
|
|
|
|
disabled: false
|
2022-06-10 14:58:07 +08:00
|
|
|
misspell:
|
|
|
|
locale: US
|
|
|
|
gocritic:
|
|
|
|
enabled-checks:
|
|
|
|
- ruleguard
|
|
|
|
settings:
|
|
|
|
ruleguard:
|
|
|
|
failOnError: true
|
2023-10-11 21:01:35 +08:00
|
|
|
rules: "rules.go"
|
2023-02-26 11:31:49 +08:00
|
|
|
depguard:
|
2023-06-07 19:34:36 +08:00
|
|
|
rules:
|
|
|
|
main:
|
|
|
|
deny:
|
2023-10-11 21:01:35 +08:00
|
|
|
- pkg: "errors"
|
2023-10-17 20:32:09 +08:00
|
|
|
desc: not allowed, use github.com/cockroachdb/errors
|
2023-10-11 21:01:35 +08:00
|
|
|
- pkg: "github.com/pkg/errors"
|
2023-10-17 20:32:09 +08:00
|
|
|
desc: not allowed, use github.com/cockroachdb/errors
|
2023-10-11 21:01:35 +08:00
|
|
|
- pkg: "github.com/pingcap/errors"
|
2023-10-17 20:32:09 +08:00
|
|
|
desc: not allowed, use github.com/cockroachdb/errors
|
2023-10-11 21:01:35 +08:00
|
|
|
- pkg: "golang.org/x/xerrors"
|
2023-10-17 20:32:09 +08:00
|
|
|
desc: not allowed, use github.com/cockroachdb/errors
|
2023-10-11 21:01:35 +08:00
|
|
|
- pkg: "github.com/go-errors/errors"
|
2023-10-17 20:32:09 +08:00
|
|
|
desc: not allowed, use github.com/cockroachdb/errors
|
|
|
|
- pkg: "io/ioutil"
|
|
|
|
desc: ioutil is deprecated after 1.16, 1.17, use os and io package instead
|
2024-02-06 10:41:41 +08:00
|
|
|
- pkg: "github.com/tikv/client-go/rawkv"
|
|
|
|
desc: not allowed, use github.com/tikv/client-go/v2/txnkv
|
|
|
|
- pkg: "github.com/tikv/client-go/v2/rawkv"
|
|
|
|
desc: not allowed, use github.com/tikv/client-go/v2/txnkv
|
2023-03-10 15:53:53 +08:00
|
|
|
forbidigo:
|
|
|
|
forbid:
|
|
|
|
- '^time\.Tick$'
|
2023-09-26 17:15:27 +08:00
|
|
|
- 'return merr\.Err[a-zA-Z]+'
|
|
|
|
- 'merr\.Wrap\w+\(\)\.Error\(\)'
|
|
|
|
- '\.(ErrorCode|Reason) = '
|
|
|
|
- 'Reason:\s+\w+\.Error\(\)'
|
2023-10-07 11:29:32 +08:00
|
|
|
- 'errors.New\((.+)\.GetReason\(\)\)'
|
2023-10-11 21:01:35 +08:00
|
|
|
- 'commonpb\.Status\{[\s\n]*ErrorCode:[\s\n]*.+[\s\S\n]*?\}'
|
2023-10-31 12:18:15 +08:00
|
|
|
- 'os\.Open\(.+\)'
|
|
|
|
- 'os\.ReadFile\(.+\)'
|
|
|
|
- 'os\.WriteFile\(.+\)'
|
2023-11-06 06:02:16 +08:00
|
|
|
- "runtime.NumCPU"
|
|
|
|
- "runtime.GOMAXPROCS(0)"
|
2023-03-10 15:53:53 +08:00
|
|
|
#- 'fmt\.Print.*' WIP
|
2020-11-03 11:25:47 +08:00
|
|
|
|
2020-11-12 12:04:12 +08:00
|
|
|
issues:
|
|
|
|
exclude-use-default: false
|
2023-10-11 21:01:35 +08:00
|
|
|
exclude-rules:
|
|
|
|
- path: .+_test\.go
|
|
|
|
linters:
|
|
|
|
- forbidigo
|
2020-11-12 12:04:12 +08:00
|
|
|
exclude:
|
|
|
|
- should have a package comment
|
|
|
|
- should have comment
|
|
|
|
- should be of the form
|
|
|
|
- should not use dot imports
|
|
|
|
- which can be annoying to use
|
2021-09-18 14:45:50 +08:00
|
|
|
# Binds to all network interfaces
|
|
|
|
- G102
|
2024-03-28 06:33:11 +08:00
|
|
|
# Use of unsafe calls should be audited
|
|
|
|
- G103
|
2021-09-18 14:45:50 +08:00
|
|
|
# Errors unhandled
|
|
|
|
- G104
|
|
|
|
# file/folder Permission
|
|
|
|
- G301
|
|
|
|
- G302
|
|
|
|
# Potential file inclusion via variable
|
|
|
|
- G304
|
2023-02-26 11:31:49 +08:00
|
|
|
# Deferring unsafe method like *os.File Close
|
2021-09-18 14:45:50 +08:00
|
|
|
- G307
|
2023-08-08 10:15:07 +08:00
|
|
|
# TLS MinVersion too low
|
|
|
|
- G402
|
2021-09-18 14:45:50 +08:00
|
|
|
# Use of weak random number generator math/rand
|
|
|
|
- G404
|
2023-09-19 10:05:22 +08:00
|
|
|
# Unused parameters
|
|
|
|
- SA1019
|
|
|
|
# defer return errors
|
|
|
|
- SA5001
|
|
|
|
|
2021-09-24 10:39:54 +08:00
|
|
|
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
|
|
|
|
max-issues-per-linter: 0
|
|
|
|
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
|
|
|
|
max-same-issues: 0
|
2023-11-10 07:46:18 +08:00
|
|
|
|
|
|
|
service:
|
2024-03-28 06:33:11 +08:00
|
|
|
# use the fixed version to not introduce new linters unexpectedly
|
|
|
|
golangci-lint-version: 1.55.2
|