Commit 0497910
committed
Provide concrete-only traversal for Class#subclasses
For classes with many singletons, the Class#subclasses walk will
cost significantly more than is warranted for the few concrete
classes it will return. This can be eliminated by tracking whether
each entry is concrete and adding a separate traversal link to the
next concrete class in the chain.
Performance of such a case is significantly better:
Before:
```
1 thread Numeric.subclasses
1.315k (± 4.6%) i/s - 6.612k in 5.040800s
1 thread Object.subclasses
56.282 (± 3.6%) i/s - 285.000 in 5.074688s
1 thread Custom.subclasses with 1000 singletons
5.588 (± 0.0%) i/s - 28.000 in 5.021174s
```
After:
```
1 thread Numeric.subclasses
2.402k (± 3.4%) i/s - 11.990k in 4.998757s
1 thread Object.subclasses
189.977 (± 6.8%) i/s - 954.000 in 5.068134s
1 thread Custom.subclasses with many singletons
3.439k (± 1.0%) i/s - 17.334k in 5.040639s
```1 parent 422bb1c commit 0497910
1 file changed
+8
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1106 | 1106 | | |
1107 | 1107 | | |
1108 | 1108 | | |
1109 | | - | |
| 1109 | + | |
1110 | 1110 | | |
1111 | 1111 | | |
1112 | 1112 | | |
| |||
1153 | 1153 | | |
1154 | 1154 | | |
1155 | 1155 | | |
1156 | | - | |
| 1156 | + | |
1157 | 1157 | | |
1158 | 1158 | | |
1159 | 1159 | | |
1160 | 1160 | | |
1161 | 1161 | | |
1162 | 1162 | | |
1163 | 1163 | | |
| 1164 | + | |
| 1165 | + | |
1164 | 1166 | | |
1165 | 1167 | | |
1166 | | - | |
1167 | | - | |
| 1168 | + | |
1168 | 1169 | | |
1169 | | - | |
| 1170 | + | |
1170 | 1171 | | |
1171 | 1172 | | |
| 1173 | + | |
| 1174 | + | |
1172 | 1175 | | |
1173 | 1176 | | |
1174 | 1177 | | |
| |||
0 commit comments