• Kubernetes Submit Queue's avatar
    Merge pull request #34784 from smarterclayton/unsafe_converter · 7ccbb032
    Kubernetes Submit Queue authored
    Automatic merge from submit-queue
    
    Use unsafe operations to get fast memory copy
    
    We can avoid doing allocations by using legal unsafe.Pointer allocations to
    assign pointers to equivalent memory locations (for memory identical types).
    
    @wojtek-t
    
    ```
    benchcmp /tmp/old /tmp/new
    benchmark                                      old ns/op     new ns/op     delta
    BenchmarkPodConversion-8                       3590          2438          -32.09%
    BenchmarkNodeConversion-8                      4774          1773          -62.86%
    BenchmarkReplicationControllerConversion-8     3711          2919          -21.34%
    BenchmarkEncodeCodecFromInternalProtobuf-8     5692          4816          -15.39%
    BenchmarkDecodeCodecToInternalProtobuf-8       7762          6540          -15.74%
    BenchmarkEncodeCodecFromInternal-8             32668         31158         -4.62%
    BenchmarkDecodeCodec-8                         67260         63348         -5.82%
    BenchmarkDecodeIntoInternalCodec-8             62903         64510         +2.55%
    
    benchmark                                      old allocs     new allocs     delta
    BenchmarkPodConversion-8                       26             13             -50.00%
    BenchmarkNodeConversion-8                      21             9              -57.14%
    BenchmarkReplicationControllerConversion-8     23             17             -26.09%
    BenchmarkEncodeCodecFromInternalProtobuf-8     16             8              -50.00%
    BenchmarkDecodeCodecToInternalProtobuf-8       72             64             -11.11%
    BenchmarkEncodeCodecFromInternal-8             68             60             -11.76%
    BenchmarkDecodeCodec-8                         268            260            -2.99%
    BenchmarkDecodeIntoInternalCodec-8             268            260            -2.99%
    
    benchmark                                      old bytes     new bytes     delta
    BenchmarkPodConversion-8                       3324          2377          -28.49%
    BenchmarkNodeConversion-8                      4800          1696          -64.67%
    BenchmarkReplicationControllerConversion-8     3456          3072          -11.11%
    BenchmarkEncodeCodecFromInternalProtobuf-8     3992          3392          -15.03%
    BenchmarkDecodeCodecToInternalProtobuf-8       5560          4960          -10.79%
    BenchmarkEncodeCodecFromInternal-8             7180          6576          -8.41%
    BenchmarkDecodeCodec-8                         13920         13320         -4.31%
    BenchmarkDecodeIntoInternalCodec-8             13920         13320         -4.31%
    ```
    7ccbb032
Name
Last commit
Last update
..
abac Loading commit data...
apps Loading commit data...
authentication Loading commit data...
authorization Loading commit data...
autoscaling Loading commit data...
batch Loading commit data...
certificates Loading commit data...
componentconfig Loading commit data...
extensions Loading commit data...
imagepolicy Loading commit data...
policy Loading commit data...
rbac Loading commit data...
storage Loading commit data...
OWNERS Loading commit data...