Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
draw: add fast paths for RGBA64Image
Go 1.17 added image.RGBA64Image and draw.RGBA64Image interfaces which use color.RGBA64 instead of color.Color in order to avoid heap allocations on pixel operations. Fast paths were added to image/draw for drawing with these images, but not to x/image/draw. This CL adds them. Fixes golang/go#62423 goos: windows goarch: amd64 pkg: golang.org/x/image/draw cpu: AMD Ryzen 9 7900X 12-Core Processor │ old.bench │ new.bench │ │ sec/op │ sec/op vs base │ SimpleScaleCopy-24 7.425µ ± 0% 7.581µ ± 0% +2.10% (p=0.000 n=20) SimpleTransformCopy-24 7.473µ ± 1% 7.678µ ± 1% +2.74% (p=0.000 n=20) SimpleTransformScale-24 440.7µ ± 0% 442.6µ ± 0% +0.44% (p=0.012 n=20) ScaleNNLargeDown-24 155.3µ ± 4% 156.9µ ± 2% ~ (p=0.495 n=20) ScaleABLargeDown-24 843.4µ ± 0% 850.7µ ± 1% +0.87% (p=0.000 n=20) ScaleBLLargeDown-24 102.7m ± 0% 102.7m ± 1% ~ (p=0.779 n=20) ScaleCRLargeDown-24 165.6m ± 0% 168.7m ± 1% +1.84% (p=0.000 n=20) ScaleNNDown-24 42.53µ ± 1% 43.00µ ± 1% +1.10% (p=0.000 n=20) ScaleABDown-24 149.3µ ± 0% 151.5µ ± 1% +1.52% (p=0.000 n=20) ScaleBLDown-24 1.347m ± 1% 1.367m ± 1% +1.43% (p=0.000 n=20) ScaleCRDown-24 2.635m ± 1% 2.663m ± 1% +1.09% (p=0.007 n=20) ScaleNNUp-24 2.108m ± 0% 2.128m ± 2% +0.93% (p=0.023 n=20) ScaleABUp-24 7.493m ± 0% 7.594m ± 1% +1.35% (p=0.000 n=20) ScaleBLUp-24 6.105m ± 3% 6.410m ± 3% +5.01% (p=0.001 n=20) ScaleCRUp-24 10.297m ± 9% 9.640m ± 3% ~ (p=0.121 n=20) ScaleNNSrcRGBA-24 111.3µ ± 1% 108.6µ ± 2% -2.37% (p=0.000 n=20) ScaleNNSrcUnif-24 1.410µ ± 1% 1.397µ ± 1% ~ (p=0.103 n=20) ScaleNNOverRGBA-24 174.0µ ± 1% 170.5µ ± 2% -1.98% (p=0.004 n=20) ScaleNNOverUnif-24 90.17µ ± 1% 90.12µ ± 1% ~ (p=0.490 n=20) TformNNSrcRGBA-24 103.4µ ± 1% 105.8µ ± 1% +2.25% (p=0.000 n=20) TformNNSrcUnif-24 38.61µ ± 1% 40.80µ ± 1% +5.69% (p=0.000 n=20) TformNNOverRGBA-24 150.3µ ± 0% 155.5µ ± 2% +3.49% (p=0.000 n=20) TformNNOverUnif-24 35.16µ ± 2% 34.75µ ± 2% -1.18% (p=0.015 n=20) ScaleABSrcGray-24 154.5µ ± 2% 151.8µ ± 1% -1.69% (p=0.006 n=20) ScaleABSrcNRGBA-24 482.0µ ± 1% 475.9µ ± 1% -1.26% (p=0.002 n=20) ScaleABSrcRGBA-24 418.2µ ± 0% 416.0µ ± 1% ~ (p=0.108 n=20) ScaleABSrcYCbCr-24 849.4µ ± 0% 845.6µ ± 1% -0.45% (p=0.015 n=20) ScaleABSrcRGBA64-24 1616.6µ ± 2% 467.8µ ± 2% -71.06% (p=0.000 n=20) ScaleABOverGray-24 152.0µ ± 1% 148.2µ ± 1% -2.51% (p=0.000 n=20) ScaleABOverNRGBA-24 511.8µ ± 1% 510.2µ ± 1% ~ (p=0.640 n=20) ScaleABOverRGBA-24 480.1µ ± 1% 475.5µ ± 0% -0.94% (p=0.000 n=20) ScaleABOverYCbCr-24 861.1µ ± 1% 843.2µ ± 0% -2.08% (p=0.000 n=20) ScaleABOverRGBA64-24 1723.2µ ± 2% 538.0µ ± 0% -68.78% (p=0.000 n=20) TformABSrcGray-24 148.6µ ± 1% 142.6µ ± 0% -4.01% (p=0.000 n=20) TformABSrcNRGBA-24 363.3µ ± 2% 356.2µ ± 0% -1.95% (p=0.000 n=20) TformABSrcRGBA-24 301.0µ ± 0% 296.5µ ± 0% -1.49% (p=0.000 n=20) TformABSrcYCbCr-24 415.1µ ± 0% 409.1µ ± 0% -1.45% (p=0.000 n=20) TformABSrcRGBA64-24 1068.9µ ± 2% 337.7µ ± 1% -68.41% (p=0.000 n=20) TformABOverGray-24 146.0µ ± 1% 143.2µ ± 0% -1.88% (p=0.000 n=20) TformABOverNRGBA-24 394.6µ ± 1% 389.0µ ± 0% -1.43% (p=0.000 n=20) TformABOverRGBA-24 341.0µ ± 1% 338.1µ ± 0% -0.83% (p=0.001 n=20) TformABOverYCbCr-24 414.4µ ± 1% 410.6µ ± 1% -0.91% (p=0.049 n=20) TformABOverRGBA64-24 1108.7µ ± 2% 389.4µ ± 1% -64.88% (p=0.000 n=20) ScaleCRSrcGray-24 4.065m ± 2% 3.979m ± 0% -2.12% (p=0.000 n=20) ScaleCRSrcNRGBA-24 13.66m ± 1% 13.41m ± 1% -1.79% (p=0.007 n=20) ScaleCRSrcRGBA-24 9.258m ± 3% 9.091m ± 1% -1.80% (p=0.002 n=20) ScaleCRSrcYCbCr-24 23.53m ± 0% 22.85m ± 1% -2.89% (p=0.000 n=20) ScaleCRSrcRGBA64-24 42.76m ± 2% 13.13m ± 1% -69.31% (p=0.000 n=20) ScaleCROverGray-24 4.110m ± 1% 3.973m ± 1% -3.33% (p=0.000 n=20) ScaleCROverNRGBA-24 14.74m ± 1% 13.50m ± 0% -8.41% (p=0.000 n=20) ScaleCROverRGBA-24 9.504m ± 1% 9.301m ± 1% -2.14% (p=0.000 n=20) ScaleCROverYCbCr-24 23.42m ± 1% 22.86m ± 0% -2.38% (p=0.000 n=20) ScaleCROverRGBA64-24 43.47m ± 1% 13.07m ± 1% -69.93% (p=0.000 n=20) TformCRSrcGray-24 1.253m ± 1% 1.225m ± 0% -2.24% (p=0.000 n=20) TformCRSrcNRGBA-24 2.141m ± 2% 2.050m ± 1% -4.24% (p=0.000 n=20) TformCRSrcRGBA-24 1.810m ± 1% 1.771m ± 0% -2.15% (p=0.002 n=20) TformCRSrcYCbCr-24 2.404m ± 1% 2.403m ± 1% ~ (p=0.698 n=20) TformCRSrcRGBA64-24 5.150m ± 1% 2.197m ± 1% -57.34% (p=0.000 n=20) TformCROverGray-24 1.251m ± 0% 1.223m ± 0% -2.23% (p=0.000 n=20) TformCROverNRGBA-24 2.081m ± 1% 2.037m ± 0% -2.13% (p=0.000 n=20) TformCROverRGBA-24 1.809m ± 1% 1.793m ± 2% ~ (p=0.149 n=20) TformCROverYCbCr-24 2.444m ± 0% 2.400m ± 1% -1.82% (p=0.000 n=20) TformCROverRGBA64-24 5.303m ± 2% 2.221m ± 1% -58.12% (p=0.000 n=20) geomean 930.7µ 804.7µ -13.54% │ old.bench │ new.bench │ │ B/op │ B/op vs base │ ScaleNNLargeDown-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABLargeDown-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleBLLargeDown-24 1.407Mi ± 0% 1.407Mi ± 0% ~ (p=0.283 n=20) ScaleCRLargeDown-24 2.010Mi ± 0% 2.345Mi ± 14% +16.67% (p=0.000 n=20) ScaleNNDown-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABDown-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleBLDown-24 1.704Ki ± 1% 1.721Ki ± 3% ~ (p=0.109 n=20) ScaleCRDown-24 3.309Ki ± 2% 3.342Ki ± 2% ~ (p=0.568 n=20) ScaleNNUp-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABUp-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleBLUp-24 50.96Ki ± 2% 52.73Ki ± 4% +3.47% (p=0.002 n=20) ScaleCRUp-24 86.54Ki ± 14% 79.09Ki ± 2% ~ (p=0.061 n=20) ScaleNNSrcRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleNNSrcUnif-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleNNOverRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleNNOverUnif-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformNNSrcRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformNNSrcUnif-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformNNOverRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformNNOverUnif-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABSrcGray-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABSrcNRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABSrcRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABSrcYCbCr-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABSrcRGBA64-24 937.5Ki ± 0% 0.0Ki ± 0% -100.00% (p=0.000 n=20) ScaleABOverGray-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABOverNRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABOverRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABOverYCbCr-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABOverRGBA64-24 937.5Ki ± 0% 0.0Ki ± 0% -100.00% (p=0.000 n=20) TformABSrcGray-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformABSrcNRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformABSrcRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformABSrcYCbCr-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformABSrcRGBA64-24 600.8Ki ± 0% 0.0Ki ± 0% -100.00% (p=0.000 n=20) TformABOverGray-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformABOverNRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformABOverRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformABOverYCbCr-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformABOverRGBA64-24 600.8Ki ± 0% 0.0Ki ± 0% -100.00% (p=0.000 n=20) ScaleCRSrcGray-24 16.51Ki ± 1% 15.97Ki ± 1% -3.32% (p=0.000 n=20) ScaleCRSrcNRGBA-24 59.33Ki ± 5% 57.21Ki ± 4% ~ (p=0.142 n=20) ScaleCRSrcRGBA-24 37.55Ki ± 2% 36.41Ki ± 2% -3.03% (p=0.001 n=20) ScaleCRSrcYCbCr-24 98.08Ki ± 2% 98.08Ki ± 2% ~ (p=0.952 n=20) ScaleCRSrcRGBA64-24 24624.95Ki ± 0% 55.21Ki ± 4% -99.78% (p=0.000 n=20) ScaleCROverGray-24 16.46Ki ± 1% 15.97Ki ± 1% -2.99% (p=0.000 n=20) ScaleCROverNRGBA-24 61.62Ki ± 3% 59.70Ki ± 5% -3.10% (p=0.015 n=20) ScaleCROverRGBA-24 38.76Ki ± 2% 37.55Ki ± 1% -3.12% (p=0.000 n=20) ScaleCROverYCbCr-24 98.08Ki ± 2% 98.08Ki ± 2% ~ (p=0.232 n=20) ScaleCROverRGBA64-24 24624.95Ki ± 0% 55.21Ki ± 2% -99.78% (p=0.000 n=20) TformCRSrcGray-24 96.00 ± 0% 96.00 ± 0% ~ (p=1.000 n=20) ¹ TformCRSrcNRGBA-24 96.00 ± 0% 96.00 ± 0% ~ (p=1.000 n=20) ¹ TformCRSrcRGBA-24 96.00 ± 0% 96.00 ± 0% ~ (p=1.000 n=20) ¹ TformCRSrcYCbCr-24 96.00 ± 0% 96.00 ± 0% ~ (p=1.000 n=20) ¹ TformCRSrcRGBA64-24 2396479.00 ± 0% 96.00 ± 0% -100.00% (p=0.000 n=20) TformCROverGray-24 96.00 ± 0% 96.00 ± 0% ~ (p=1.000 n=20) ¹ TformCROverNRGBA-24 96.00 ± 0% 96.00 ± 0% ~ (p=1.000 n=20) ¹ TformCROverRGBA-24 96.00 ± 0% 96.00 ± 0% ~ (p=1.000 n=20) ¹ TformCROverYCbCr-24 96.00 ± 0% 96.00 ± 0% ~ (p=1.000 n=20) ¹ TformCROverRGBA64-24 2396479.00 ± 0% 96.00 ± 0% -100.00% (p=0.000 n=20) geomean ² ? ² ³ ¹ all samples are equal ² summaries must be >0 to compute geomean ³ ratios must be >0 to compute geomean │ old.bench │ new.bench │ │ allocs/op │ allocs/op vs base │ ScaleNNLargeDown-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABLargeDown-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleBLLargeDown-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleCRLargeDown-24 0.000 ± 0% 1.000 ± ? ? (p=0.000 n=20) ScaleNNDown-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABDown-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleBLDown-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleCRDown-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleNNUp-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABUp-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleBLUp-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleCRUp-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleNNSrcRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleNNSrcUnif-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleNNOverRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleNNOverUnif-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformNNSrcRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformNNSrcUnif-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformNNOverRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformNNOverUnif-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABSrcGray-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABSrcNRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABSrcRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABSrcYCbCr-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABSrcRGBA64-24 120.0k ± 0% 0.0k ± 0% -100.00% (p=0.000 n=20) ScaleABOverGray-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABOverNRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABOverRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABOverYCbCr-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleABOverRGBA64-24 120.0k ± 0% 0.0k ± 0% -100.00% (p=0.000 n=20) TformABSrcGray-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformABSrcNRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformABSrcRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformABSrcYCbCr-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformABSrcRGBA64-24 76.90k ± 0% 0.00k ± 0% -100.00% (p=0.000 n=20) TformABOverGray-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformABOverNRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformABOverRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformABOverYCbCr-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ TformABOverRGBA64-24 76.90k ± 0% 0.00k ± 0% -100.00% (p=0.000 n=20) ScaleCRSrcGray-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleCRSrcNRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleCRSrcRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleCRSrcYCbCr-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleCRSrcRGBA64-24 3.129M ± 0% 0.000M ± 0% -100.00% (p=0.000 n=20) ScaleCROverGray-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleCROverNRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleCROverRGBA-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleCROverYCbCr-24 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ ScaleCROverRGBA64-24 3.129M ± 0% 0.000M ± 0% -100.00% (p=0.000 n=20) TformCRSrcGray-24 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=20) ¹ TformCRSrcNRGBA-24 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=20) ¹ TformCRSrcRGBA-24 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=20) ¹ TformCRSrcYCbCr-24 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=20) ¹ TformCRSrcRGBA64-24 299549.000 ± 0% 2.000 ± 0% -100.00% (p=0.000 n=20) TformCROverGray-24 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=20) ¹ TformCROverNRGBA-24 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=20) ¹ TformCROverRGBA-24 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=20) ¹ TformCROverYCbCr-24 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=20) ¹ TformCROverRGBA64-24 299549.000 ± 0% 2.000 ± 0% -100.00% (p=0.000 n=20) geomean ² ? ² ¹ all samples are equal ² summaries must be >0 to compute geomean Change-Id: I37778e925cce13c4fec65c9e6d57e205440e2a06 Reviewed-on: https://go-review.googlesource.com/c/image/+/525255 Reviewed-by: Dmitri Shuralyov <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]> Reviewed-by: Nigel Tao <[email protected]> Reviewed-by: Nigel Tao (INACTIVE; USE @golang.org INSTEAD) <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
- Loading branch information