Commit 2e157e5
committed
Established initial threshold for
The `AttributeDictionary` mapping introduces some overhead. If there aren't many attributes that will be mapped, this will actually slow down the mapping service, instead of speeding it up. If there are a lot of attributes that are mapped, however, it will dramatically improve the performance. With the help of the new load tests (3ecfa06, 7b529dc), I determined that this threshold is pretty quick; if 2-3 attributes are mapped, we reach a breakeven point; if more than 5-6 attributes are mapped, we start seeing a significant reduction.
Unfortunately, predetermining if the attributes map to properties is itself expensive, so we're instead just establishing a heuristic. In a typical OnTopic implementation, we typically expect each topic to have 2-3 attributes that won't be mapped with `AttributeDictionary` (such as `Title`, `LastModified`, `LastModifiedBy`). So the assumption here is that if there are five or more attributes, then 2-3 will be mapped, thus reaching that breakeven point.
In addition, if those attributes don't have properties to map to, there isn't any benefit to passing them in via the `AttributeDictionary`. This is even harder to evaluate because many of those will be compatible properties that aren't sourced from attributes (such as `Id`, `Key`, `ContentType`, `WebPath`, &c.)—but that will depend on the model itself, and may not hold for e.g. nested topics or references, or `[MapAs()]` types. In fact, we expect nearly all models to have 5-7 "base" properties as a result of that, in order to maintain compatibility with `ITopicViewModel`. Nevertheless, if there are less than five compatible properties, this likely isn't going to be worth the overhead.
In the future, we may revise this further based on real-world telemetry. Further, we may want to e.g. cache the number of convertible properties on the `TypeAccessor`, and even attempt to estimate the number of non-mapped types based on e.g., whether the target model implements `ITopicViewModel`. That's a bit expensive of a check, but again can be cached as part of the `TypeAccessor.AttributeDictionary mapping1 parent 7b529dc commit 2e157e5
1 file changed
Lines changed: 33 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
| 177 | + | |
176 | 178 | | |
177 | 179 | | |
178 | 180 | | |
| |||
185 | 187 | | |
186 | 188 | | |
187 | 189 | | |
188 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
189 | 195 | | |
190 | | - | |
191 | | - | |
192 | 196 | | |
193 | | - | |
194 | | - | |
195 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
196 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
197 | 224 | | |
198 | 225 | | |
199 | 226 | | |
| |||
0 commit comments