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

receive: Optimized receive; fixed long term overallocation #3334

Closed
wants to merge 5 commits into from

Commits on Oct 17, 2020

  1. receive: Added benchmark for writes.

    Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
    bwplotka committed Oct 17, 2020
    Configuration menu
    Copy the full SHA
    e09c413 View commit details
    Browse the repository at this point in the history
  2. Optimized write: AddFast and debug prints.

    GOROOT=/home/bwplotka/.gvm/gos/go1.15 #gosetup
    GOPATH=/home/bwplotka/Repos/thanosgopath #gosetup
    /home/bwplotka/.gvm/gos/go1.15/bin/go test -c -o /tmp/___BenchmarkHandlerReceiveHTTP_in_github_com_thanos_io_thanos_pkg_receive github.com/thanos-io/thanos/pkg/receive #gosetup
    /tmp/___BenchmarkHandlerReceiveHTTP_in_github_com_thanos_io_thanos_pkg_receive -test.v -test.bench ^\QBenchmarkHandlerReceiveHTTP\E$ -test.run ^$
    goos: linux
    goarch: amd64
    pkg: github.com/thanos-io/thanos/pkg/receive
    BenchmarkHandlerReceiveHTTP
    BenchmarkHandlerReceiveHTTP/typical_labels_under_1KB,_single_sample
    BenchmarkHandlerReceiveHTTP/typical_labels_under_1KB,_single_sample/OK
    BenchmarkHandlerReceiveHTTP/typical_labels_under_1KB,_single_sample/OK-12      	   66613	     17432 ns/op	    6382 B/op	      47 allocs/op
    BenchmarkHandlerReceiveHTTP/typical_labels_under_1KB,_single_sample/conflict_errors
    BenchmarkHandlerReceiveHTTP/typical_labels_under_1KB,_single_sample/conflict_errors-12         	   65179	     20922 ns/op	    9392 B/op	      90 allocs/op
    BenchmarkHandlerReceiveHTTP/typical_labels_under_1KB,_2MB_of_samples
    BenchmarkHandlerReceiveHTTP/typical_labels_under_1KB,_2MB_of_samples/OK
    BenchmarkHandlerReceiveHTTP/typical_labels_under_1KB,_2MB_of_samples/OK-12                     	      51	  22250679 ns/op	14286524 B/op	    5118 allocs/op
    BenchmarkHandlerReceiveHTTP/typical_labels_under_1KB,_2MB_of_samples/conflict_errors
    BenchmarkHandlerReceiveHTTP/typical_labels_under_1KB,_2MB_of_samples/conflict_errors-12        	      31	  47359942 ns/op	45323821 B/op	  500126 allocs/op
    BenchmarkHandlerReceiveHTTP/bigger_labels_over_1KB,_single_sample
    BenchmarkHandlerReceiveHTTP/bigger_labels_over_1KB,_single_sample/OK
    BenchmarkHandlerReceiveHTTP/bigger_labels_over_1KB,_single_sample/OK-12                        	   33147	     30462 ns/op	   10578 B/op	      49 allocs/op
    BenchmarkHandlerReceiveHTTP/bigger_labels_over_1KB,_single_sample/conflict_errors
    BenchmarkHandlerReceiveHTTP/bigger_labels_over_1KB,_single_sample/conflict_errors-12           	   53385	     24087 ns/op	   13606 B/op	      92 allocs/op
    BenchmarkHandlerReceiveHTTP/bigger_labels_over_1KB,_2MB_of_samples
    BenchmarkHandlerReceiveHTTP/bigger_labels_over_1KB,_2MB_of_samples/OK
    BenchmarkHandlerReceiveHTTP/bigger_labels_over_1KB,_2MB_of_samples/OK-12                       	      49	  24593572 ns/op	15436524 B/op	    5141 allocs/op
    BenchmarkHandlerReceiveHTTP/bigger_labels_over_1KB,_2MB_of_samples/conflict_errors
    BenchmarkHandlerReceiveHTTP/bigger_labels_over_1KB,_2MB_of_samples/conflict_errors-12          	      25	  52976766 ns/op	45329167 B/op	  500129 allocs/op
    BenchmarkHandlerReceiveHTTP/extremely_large_label_value_10MB,_single_sample
    BenchmarkHandlerReceiveHTTP/extremely_large_label_value_10MB,_single_sample/OK
    BenchmarkHandlerReceiveHTTP/extremely_large_label_value_10MB,_single_sample/OK-12              	      60	  27261861 ns/op	32538875 B/op	      54 allocs/op
    BenchmarkHandlerReceiveHTTP/extremely_large_label_value_10MB,_single_sample/conflict_errors
    BenchmarkHandlerReceiveHTTP/extremely_large_label_value_10MB,_single_sample/conflict_errors-12 	      78	  15315152 ns/op	32540624 B/op	      97 allocs/op
    BenchmarkHandlerReceiveHTTP/extremely_large_label_value_10MB,_2MB_samples
    BenchmarkHandlerReceiveHTTP/extremely_large_label_value_10MB,_2MB_samples/OK
    BenchmarkHandlerReceiveHTTP/extremely_large_label_value_10MB,_2MB_samples/OK-12                	      33	  35595450 ns/op	47171972 B/op	    5100 allocs/op
    BenchmarkHandlerReceiveHTTP/extremely_large_label_value_10MB,_2MB_samples/conflict_errors
    BenchmarkHandlerReceiveHTTP/extremely_large_label_value_10MB,_2MB_samples/conflict_errors-12   	      21	  58917325 ns/op	78629564 B/op	  500125 allocs/op
    PASS
    
    Process finished with exit code 0
    
    
    Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
    bwplotka committed Oct 17, 2020
    Configuration menu
    Copy the full SHA
    65aa6c1 View commit details
    Browse the repository at this point in the history
  3. Removed ZLabels from promb.

    Tried DeepCopy but not worth it:
    
    ```
    benchstat -delta-test=none _dev/diffc.out _dev/diffd.out
    name                                                                                   old time/op    new time/op    delta
    HandlerReceiveHTTP/typical_labels_under_1KB,_single_sample/OK-12                         18.5µs ± 0%    17.8µs ± 0%   -3.89%
    HandlerReceiveHTTP/typical_labels_under_1KB,_single_sample/conflict_errors-12            22.5µs ± 0%    20.9µs ± 0%   -7.03%
    HandlerReceiveHTTP/typical_labels_under_1KB,_2MB_of_samples/OK-12                        25.0ms ± 0%    24.3ms ± 0%   -2.62%
    HandlerReceiveHTTP/typical_labels_under_1KB,_2MB_of_samples/conflict_errors-12           54.2ms ± 0%    52.3ms ± 0%   -3.35%
    HandlerReceiveHTTP/bigger_labels_over_1KB,_single_sample/OK-12                           33.9µs ± 0%    26.6µs ± 0%  -21.46%
    HandlerReceiveHTTP/bigger_labels_over_1KB,_single_sample/conflict_errors-12              24.3µs ± 0%    24.6µs ± 0%   +1.43%
    HandlerReceiveHTTP/bigger_labels_over_1KB,_2MB_of_samples/OK-12                          24.4ms ± 0%    24.8ms ± 0%   +1.36%
    HandlerReceiveHTTP/bigger_labels_over_1KB,_2MB_of_samples/conflict_errors-12             52.4ms ± 0%    48.8ms ± 0%   -7.03%
    HandlerReceiveHTTP/extremely_large_label_value_10MB,_single_sample/OK-12                 15.2ms ± 0%    15.0ms ± 0%   -1.37%
    HandlerReceiveHTTP/extremely_large_label_value_10MB,_single_sample/conflict_errors-12    15.9ms ± 0%    15.2ms ± 0%   -4.08%
    HandlerReceiveHTTP/extremely_large_label_value_10MB,_2MB_samples/OK-12                   38.7ms ± 0%    39.6ms ± 0%   +2.28%
    HandlerReceiveHTTP/extremely_large_label_value_10MB,_2MB_samples/conflict_errors-12      67.7ms ± 0%    64.8ms ± 0%   -4.34%
    
    name                                                                                   old alloc/op   new alloc/op   delta
    HandlerReceiveHTTP/typical_labels_under_1KB,_single_sample/OK-12                         7.35kB ± 0%    7.66kB ± 0%   +4.25%
    HandlerReceiveHTTP/typical_labels_under_1KB,_single_sample/conflict_errors-12            10.4kB ± 0%    10.7kB ± 0%   +2.94%
    HandlerReceiveHTTP/typical_labels_under_1KB,_2MB_of_samples/OK-12                        14.9MB ± 0%    15.3MB ± 0%   +2.56%
    HandlerReceiveHTTP/typical_labels_under_1KB,_2MB_of_samples/conflict_errors-12           45.3MB ± 0%    45.3MB ± 0%   -0.00%
    HandlerReceiveHTTP/bigger_labels_over_1KB,_single_sample/OK-12                           11.9kB ± 0%    12.2kB ± 0%   +2.79%
    HandlerReceiveHTTP/bigger_labels_over_1KB,_single_sample/conflict_errors-12              14.9kB ± 0%    15.2kB ± 0%   +2.18%
    HandlerReceiveHTTP/bigger_labels_over_1KB,_2MB_of_samples/OK-12                          15.9MB ± 0%    17.7MB ± 0%  +11.38%
    HandlerReceiveHTTP/bigger_labels_over_1KB,_2MB_of_samples/conflict_errors-12             45.3MB ± 0%    45.3MB ± 0%   -0.00%
    HandlerReceiveHTTP/extremely_large_label_value_10MB,_single_sample/OK-12                 43.0MB ± 0%    43.0MB ± 0%   -0.00%
    HandlerReceiveHTTP/extremely_large_label_value_10MB,_single_sample/conflict_errors-12    43.0MB ± 0%    43.0MB ± 0%   -0.01%
    HandlerReceiveHTTP/extremely_large_label_value_10MB,_2MB_samples/OK-12                   61.2MB ± 0%    60.8MB ± 0%   -0.72%
    HandlerReceiveHTTP/extremely_large_label_value_10MB,_2MB_samples/conflict_errors-12      89.1MB ± 0%    89.1MB ± 0%   -0.00%
    
    name                                                                                   old allocs/op  new allocs/op  delta
    HandlerReceiveHTTP/typical_labels_under_1KB,_single_sample/OK-12                           67.0 ± 0%      68.0 ± 0%   +1.49%
    HandlerReceiveHTTP/typical_labels_under_1KB,_single_sample/conflict_errors-12               110 ± 0%       111 ± 0%   +0.91%
    HandlerReceiveHTTP/typical_labels_under_1KB,_2MB_of_samples/OK-12                         5.14k ± 0%     5.14k ± 0%   +0.02%
    HandlerReceiveHTTP/typical_labels_under_1KB,_2MB_of_samples/conflict_errors-12             500k ± 0%      500k ± 0%   -0.00%
    HandlerReceiveHTTP/bigger_labels_over_1KB,_single_sample/OK-12                             69.0 ± 0%      70.0 ± 0%   +1.45%
    HandlerReceiveHTTP/bigger_labels_over_1KB,_single_sample/conflict_errors-12                 112 ± 0%       113 ± 0%   +0.89%
    HandlerReceiveHTTP/bigger_labels_over_1KB,_2MB_of_samples/OK-12                           5.17k ± 0%     5.18k ± 0%   +0.17%
    HandlerReceiveHTTP/bigger_labels_over_1KB,_2MB_of_samples/conflict_errors-12               500k ± 0%      500k ± 0%   +0.00%
    HandlerReceiveHTTP/extremely_large_label_value_10MB,_single_sample/OK-12                   57.0 ± 0%      57.0 ± 0%    0.00%
    HandlerReceiveHTTP/extremely_large_label_value_10MB,_single_sample/conflict_errors-12       100 ± 0%       100 ± 0%    0.00%
    HandlerReceiveHTTP/extremely_large_label_value_10MB,_2MB_samples/OK-12                    5.11k ± 0%     5.11k ± 0%   -0.08%
    HandlerReceiveHTTP/extremely_large_label_value_10MB,_2MB_samples/conflict_errors-12        500k ± 0%      500k ± 0%    0.00%
    ```
    Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
    bwplotka committed Oct 17, 2020
    Configuration menu
    Copy the full SHA
    1db1615 View commit details
    Browse the repository at this point in the history
  4. Optimized hash.

    Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
    bwplotka committed Oct 17, 2020
    Configuration menu
    Copy the full SHA
    153636f View commit details
    Browse the repository at this point in the history
  5. Reduced allocs on write append errors.

    Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
    bwplotka committed Oct 17, 2020
    Configuration menu
    Copy the full SHA
    9f0ec87 View commit details
    Browse the repository at this point in the history