Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Add AppendProtocols for a an allocation free to get the protocols #188

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Jan 4, 2023

  1. perf: Add AppendProtocols for a an allocation free to get the protocols

    While looking at Kubo benchmarks, if you are using connection filters you allocate ~200MiB/s in the Protocols code path.
    
    This new method allows to give some preallocated memory in a slice, and it will be reused instead of allocating more.
    
    ```
    goos: linux
    goarch: amd64
    pkg: github.com/multiformats/go-multiaddr
    cpu: AMD Ryzen 5 3600 6-Core Processor
    BenchmarkProtocols-12          	 3779694	       312.0 ns/op	     640 B/op	       1 allocs/op
    BenchmarkAppendProtocols-12    	26105854	        43.13 ns/op	       0 B/op	       0 allocs/op
    ```
    Jorropo committed Jan 4, 2023
    Configuration menu
    Copy the full SHA
    5bd7ff1 View commit details
    Browse the repository at this point in the history