From: | "Joel Jacobson" <joel(at)compiler(dot)org> |
---|---|
To: | "Dean Rasheed" <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
Cc: | Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Optimize numeric multiplication for one and two base-NBASE digit multiplicands. |
Date: | 2024-07-09 19:48:57 |
Message-ID: | 7f733f07-8631-4019-96bf-df83b14919bb@app.fastmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Jul 9, 2024, at 16:11, Joel Jacobson wrote:
> I added some more ndigits test cases:
Ops, please ignore previous benchmark;
I had forgot to commit in between the measurements,
so they all ran in the same db txn,
which caused a lot of noise on few ndigits.
New benchmark:
> /*
> * Intel Core i9-14900K
> */
NBASE digits | HEAD rate | patch rate | relative difference
--------------+----------------+----------------+---------------------
1 | 5.0251256e+07 | 5.2631579e+07 | 4.74%
2 | 4.8543689e+07 | 4.9751244e+07 | 2.49%
3 | 4.1493776e+07 | 4.3478261e+07 | 4.78%
4 | 4.1493776e+07 | 4.0816327e+07 | -1.63%
5 | 2.2371365e+07 | 2.3364486e+07 | 4.44%
6 | 2.1008403e+07 | 2.1186441e+07 | 0.85%
7 | 1.7152659e+07 | 1.6233766e+07 | -5.36%
8 | 1.7123288e+07 | 1.8450185e+07 | 7.75%
9 | 1.5290520e+07 | 1.7271157e+07 | 12.95%
10 | 1.3351135e+07 | 1.5384615e+07 | 15.23%
11 | 1.2453300e+07 | 1.4164306e+07 | 13.74%
12 | 1.1655012e+07 | 1.2936611e+07 | 11.00%
13 | 1.0373444e+07 | 1.1904762e+07 | 14.76%
14 | 9.0909091e+06 | 1.0162602e+07 | 11.79%
15 | 7.7519380e+06 | 8.1300813e+06 | 4.88%
16 | 9.0909091e+06 | 9.8039216e+06 | 7.84%
17 | 7.5757576e+06 | 9.0909091e+06 | 20.00%
18 | 7.2463768e+06 | 8.2644628e+06 | 14.05%
19 | 6.6225166e+06 | 7.5757576e+06 | 14.39%
20 | 6.4516129e+06 | 7.0422535e+06 | 9.15%
21 | 6.0606061e+06 | 6.5789474e+06 | 8.55%
22 | 5.7142857e+06 | 6.2500000e+06 | 9.38%
24 | 5.4054054e+06 | 6.0240964e+06 | 11.45%
25 | 5.2356021e+06 | 5.8139535e+06 | 11.05%
26 | 5.0251256e+06 | 5.8139535e+06 | 15.70%
27 | 4.7393365e+06 | 5.7142857e+06 | 20.57%
28 | 4.6082949e+06 | 5.2083333e+06 | 13.02%
29 | 4.3478261e+06 | 4.9504950e+06 | 13.86%
30 | 4.0816327e+06 | 4.6728972e+06 | 14.49%
31 | 3.4843206e+06 | 3.9682540e+06 | 13.89%
32 | 4.0000000e+06 | 4.1666667e+06 | 4.17%
50 | 2.1097046e+06 | 2.8571429e+06 | 35.43%
100 | 680272.11 | 909090.91 | 33.64%
250 | 141643.06 | 174216.03 | 23.00%
2500 | 1626.02 | 2188.18 | 34.57%
15000 | 41.67 | 52.63 | 26.32%
(36 rows)
> /*
> * AMD Ryzen 9 7950X3D
> */
NBASE digits | HEAD rate | patch rate | relative difference
--------------+----------------+----------------+---------------------
1 | 3.7037037e+07 | 3.8910506e+07 | 5.06%
2 | 3.5587189e+07 | 3.5971223e+07 | 1.08%
3 | 3.0581040e+07 | 2.9239766e+07 | -4.39%
4 | 2.7322404e+07 | 3.0303030e+07 | 10.91%
5 | 1.8050542e+07 | 1.9011407e+07 | 5.32%
6 | 1.5974441e+07 | 1.6233766e+07 | 1.62%
7 | 1.3106160e+07 | 1.3071895e+07 | -0.26%
8 | 1.2285012e+07 | 1.3106160e+07 | 6.68%
9 | 1.1534025e+07 | 1.2269939e+07 | 6.38%
10 | 1.1135857e+07 | 1.1507480e+07 | 3.34%
11 | 9.7943193e+06 | 1.0976948e+07 | 12.07%
12 | 9.5238095e+06 | 1.0256410e+07 | 7.69%
13 | 8.6206897e+06 | 8.7719298e+06 | 1.75%
14 | 7.3529412e+06 | 8.1967213e+06 | 11.48%
15 | 6.2893082e+06 | 6.7114094e+06 | 6.71%
16 | 7.2463768e+06 | 7.0422535e+06 | -2.82%
17 | 6.2893082e+06 | 7.2463768e+06 | 15.22%
18 | 6.3694268e+06 | 7.4626866e+06 | 17.16%
19 | 5.6818182e+06 | 6.6225166e+06 | 16.56%
20 | 5.2083333e+06 | 6.1728395e+06 | 18.52%
21 | 5.0251256e+06 | 5.7471264e+06 | 14.37%
22 | 4.5248869e+06 | 5.1282051e+06 | 13.33%
24 | 4.9261084e+06 | 5.1020408e+06 | 3.57%
25 | 4.6511628e+06 | 4.9504950e+06 | 6.44%
26 | 4.2553191e+06 | 4.6082949e+06 | 8.29%
27 | 3.9682540e+06 | 4.2918455e+06 | 8.15%
28 | 3.8910506e+06 | 4.1322314e+06 | 6.20%
29 | 3.8167939e+06 | 3.7593985e+06 | -1.50%
30 | 3.5842294e+06 | 3.6101083e+06 | 0.72%
31 | 3.1948882e+06 | 3.1645570e+06 | -0.95%
32 | 3.4722222e+06 | 3.7174721e+06 | 7.06%
50 | 1.6474465e+06 | 2.1691974e+06 | 31.67%
100 | 555555.56 | 653594.77 | 17.65%
250 | 109409.19 | 140449.44 | 28.37%
2500 | 1236.09 | 1555.21 | 25.82%
15000 | 34.48 | 43.48 | 26.09%
(36 rows)
> /*
> * Apple M3 Max
> */
NBASE digits | HEAD rate | patch rate | relative difference
--------------+----------------+----------------+---------------------
1 | 4.7169811e+07 | 4.7619048e+07 | 0.95%
2 | 6.0240964e+07 | 5.8479532e+07 | -2.92%
3 | 5.2083333e+07 | 5.3191489e+07 | 2.13%
4 | 4.5871560e+07 | 4.6948357e+07 | 2.35%
5 | 2.2075055e+07 | 2.3529412e+07 | 6.59%
6 | 2.0080321e+07 | 2.1505376e+07 | 7.10%
7 | 1.7301038e+07 | 1.8975332e+07 | 9.68%
8 | 1.6025641e+07 | 1.6556291e+07 | 3.31%
9 | 1.3245033e+07 | 1.3717421e+07 | 3.57%
10 | 1.1709602e+07 | 1.2315271e+07 | 5.17%
11 | 1.0000000e+07 | 1.0989011e+07 | 9.89%
12 | 9.0909091e+06 | 9.7276265e+06 | 7.00%
13 | 8.3333333e+06 | 9.0090090e+06 | 8.11%
14 | 7.6923077e+06 | 8.0645161e+06 | 4.84%
15 | 7.0921986e+06 | 7.5187970e+06 | 6.02%
16 | 6.6666667e+06 | 7.0921986e+06 | 6.38%
17 | 6.2111801e+06 | 6.3694268e+06 | 2.55%
18 | 5.7803468e+06 | 5.9523810e+06 | 2.98%
19 | 5.2910053e+06 | 5.4347826e+06 | 2.72%
20 | 4.7846890e+06 | 5.0505051e+06 | 5.56%
21 | 4.5454545e+06 | 4.6728972e+06 | 2.80%
22 | 4.2372881e+06 | 4.3859649e+06 | 3.51%
24 | 3.7174721e+06 | 3.8759690e+06 | 4.26%
25 | 3.4722222e+06 | 3.6231884e+06 | 4.35%
26 | 3.2894737e+06 | 3.3898305e+06 | 3.05%
27 | 3.0674847e+06 | 3.1847134e+06 | 3.82%
28 | 2.9239766e+06 | 3.0120482e+06 | 3.01%
29 | 2.7548209e+06 | 2.8901734e+06 | 4.91%
30 | 2.6041667e+06 | 2.7322404e+06 | 4.92%
31 | 2.5000000e+06 | 2.5773196e+06 | 3.09%
32 | 4.6082949e+06 | 4.7846890e+06 | 3.83%
50 | 1.7241379e+06 | 2.0703934e+06 | 20.08%
100 | 719424.46 | 869565.22 | 20.87%
250 | 124688.28 | 157977.88 | 26.70%
2500 | 1455.60 | 1811.59 | 24.46%
15000 | 40.00 | 50.00 | 25.00%
(36 rows)
Regards,
Joel
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2024-07-09 19:53:17 | Re: XML test error on Arch Linux |
Previous Message | Joe Conway | 2024-07-09 19:24:51 | Re: Commitfest manager for July 2024 |