syncthing/lib/protocol
Jakob Borg 9682bbfbda lib/protocol: Optimize luhn and chunk functions
These functions were very naive and slow. We haven't done much about
them because they pretty much don't matter at all for Syncthing
performance. They are however called very often in the discovery server
and these optimizations have a huge effect on the CPU load on the
public discovery servers.

The code isn't exactly obvious, but we have good test coverage on all
these functions.

benchmark                 old ns/op     new ns/op     delta
BenchmarkLuhnify-8        12458         1045          -91.61%
BenchmarkUnluhnify-8      12598         1074          -91.47%
BenchmarkChunkify-8       10792         104           -99.04%

benchmark                 old allocs     new allocs     delta
BenchmarkLuhnify-8        18             1              -94.44%
BenchmarkUnluhnify-8      18             1              -94.44%
BenchmarkChunkify-8       44             2              -95.45%

benchmark                 old bytes     new bytes     delta
BenchmarkLuhnify-8        1278          64            -94.99%
BenchmarkUnluhnify-8      1278          64            -94.99%
BenchmarkChunkify-8       42552         128           -99.70%

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4346
2017-09-03 10:26:12 +00:00
..
LICENSE Add 'lib/protocol/' from commit 'f91191218b192ace841c878f161832d19c09145a' 2015-09-22 19:34:29 +02:00
benchmark_test.go lib/connections: Use our own fork of kcp (fixes #4063) 2017-09-02 06:04:35 +00:00
bep.pb.go all: Remove symlink support on Windows, SymlinksEnabled config 2017-02-07 08:34:24 +00:00
bep.proto all: Remove symlink support on Windows, SymlinksEnabled config 2017-02-07 08:34:24 +00:00
bep_extensions.go all: Remove symlink support on Windows, SymlinksEnabled config 2017-02-07 08:34:24 +00:00
bufferpool.go build: Enable gometalinter "gosimple" check, improve build.go 2016-12-21 14:53:45 +01:00
common_test.go lib/connections, lib/model: Refactor connection close handling (fixes #3466) 2016-08-10 09:37:32 +00:00
compression.go lib/protocol, lib/discover, lib/db: Use protocol buffer serialization (fixes #3080) 2016-07-04 10:40:29 +00:00
compression_test.go Add 'lib/protocol/' from commit 'f91191218b192ace841c878f161832d19c09145a' 2015-09-22 19:34:29 +02:00
conflict_test.go lib/protocol, lib/model: Implement high precision time stamps (fixes #3305) 2016-08-06 13:05:59 +00:00
counting.go Add 'lib/protocol/' from commit 'f91191218b192ace841c878f161832d19c09145a' 2015-09-22 19:34:29 +02:00
debug.go lib/protocol, lib/discover, lib/db: Use protocol buffer serialization (fixes #3080) 2016-07-04 10:40:29 +00:00
deviceid.go lib/protocol: Optimize luhn and chunk functions 2017-09-03 10:26:12 +00:00
deviceid_test.go lib/protocol: Optimize luhn and chunk functions 2017-09-03 10:26:12 +00:00
deviceid_test.pb.go vendor: Update github.com/gogo/protobuf 2017-01-03 00:16:21 +00:00
deviceid_test.proto lib/protocol: Use DeviceID in protocol messages, with custom marshalling 2016-10-29 21:56:24 +00:00
doc.go Add 'lib/protocol/' from commit 'f91191218b192ace841c878f161832d19c09145a' 2015-09-22 19:34:29 +02:00
errors.go lib/protocol, lib/discover, lib/db: Use protocol buffer serialization (fixes #3080) 2016-07-04 10:40:29 +00:00
hello.go build: Enable gometalinter "gosimple" check, improve build.go 2016-12-21 14:53:45 +01:00
hello_test.go lib/protocol: Hello message length is an int16 2016-07-17 21:41:20 +00:00
hello_v0.13.go lib/protocol: Understand older/newer Hello messages (fixes #3287) 2016-06-09 10:50:14 +00:00
hello_v0.13_xdr.go lib/protocol: Understand older/newer Hello messages (fixes #3287) 2016-06-09 10:50:14 +00:00
nativemodel_darwin.go lib/protocol, lib/discover, lib/db: Use protocol buffer serialization (fixes #3080) 2016-07-04 10:40:29 +00:00
nativemodel_unix.go lib/model, lib/protocol: Implement temporary indexes (fixes #950) 2016-04-15 10:59:41 +00:00
nativemodel_windows.go lib/protocol: Warnln should have been Warnf 2016-12-21 10:43:12 +01:00
nativemodel_windows_test.go lib/protocol: Apply input filtering on file names 2016-12-01 12:35:32 +00:00
protocol.go lib/protocol: Accept invalid files without blocks (fixes #4093) 2017-04-12 11:28:12 +02:00
protocol_test.go lib/protocol: Add some consistency checks on incoming index updates (fixes #4053) 2017-03-27 07:21:08 +00:00
vector.go lib/protocol, lib/discover, lib/db: Use protocol buffer serialization (fixes #3080) 2016-07-04 10:40:29 +00:00
vector_test.go build, cmd, lib: Minimum supported compiler version is Go 1.5 2016-08-15 08:37:32 +02:00
wireformat.go lib/protocol, lib/discover, lib/db: Use protocol buffer serialization (fixes #3080) 2016-07-04 10:40:29 +00:00