forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit3c17926
committed
Speed up printing of integers in snprintf.c.
Since the only possible divisors are 8, 10, and 16, it doesn't costmuch code space to replace the division loop with three copies usingconstant divisors. On most machines, division by a constant can bedone a lot more cheaply than division by an arbitrary value.A microbenchmark testing just snprintf("foo %d") with a 9-digit valueshowed about a 2X speedup for me (tgl). Most of Postgres isn't toodependent on the speed of snprintf, so that the effect in real-worldcases is barely measurable. Still, a cycle saved is a cycle earned.Arjan van de VenDiscussion:https://postgr.es/m/40a4b32a-b841-4667-11b2-a0baedb12714@linux.intel.comDiscussion:https://postgr.es/m/6e51c644-1b6d-956e-ac24-2d1b0541d532@linux.intel.com1 parent7f580aa commit3c17926
1 file changed
+30
-6
lines changedLines changed: 30 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1015 | 1015 |
| |
1016 | 1016 |
| |
1017 | 1017 |
| |
1018 |
| - | |
1019 | 1018 |
| |
| 1019 | + | |
1020 | 1020 |
| |
1021 | 1021 |
| |
1022 | 1022 |
| |
| |||
1075 | 1075 |
| |
1076 | 1076 |
| |
1077 | 1077 |
| |
1078 |
| - | |
1079 |
| - | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
1080 | 1093 |
| |
1081 |
| - | |
1082 |
| - | |
1083 |
| - | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
1084 | 1108 |
| |
1085 | 1109 |
| |
1086 | 1110 |
| |
|
0 commit comments
Comments
(0)