Commit 5978a5d
Claude (on behalf of Steven Schlansker)
perf(format): generate row-codec schema projections lazily on first decode
Schema-evolution projection codecs were compiled eagerly at builder time:
the row/array/map builders enumerated the full historical cross-product and
loaded one generated codec class per combination, so a deep nested version
history paid its whole class cost up front whether or not those versions ever
appeared on the wire.
Defer that compilation to decode. Each builder now builds an immutable
hash -> ProjectionSource index that holds only the inputs (the VersionedSchema
and codegen context); the codec class is compiled the first time a payload with
that hash is decoded and cached in a per-encoder LongMap. No new synchronization:
encoders are single-threaded, and the class compile is already memoized globally
by the shared code generator, so a concurrent first-miss on the same hash
compiles the class once.
The build-time collision guards stay eager over the full cross-product (row/array
via SchemaHistory's strict-hash guard, map via its two combined-hash guards), so a
hash clash still fails fast at build rather than on an unlucky decode.
Because the build-time class count no longer tracks annotated history, the
projection-count warning no longer flags a real cost; remove
PROJECTION_COUNT_WARN_THRESHOLD and warnIfManyProjections. Also fix stale Javadoc
that claimed map keys are always read at the current schema and that map support
is in progress, and update the row-format guide's generation-cost note to the
lazy model.1 parent 3d2f8f1 commit 5978a5d
11 files changed
Lines changed: 345 additions & 233 deletions
File tree
- docs/guide/java
- java/fory-format/src/main/java/org/apache/fory/format/encoder
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
300 | 299 | | |
301 | 300 | | |
302 | 301 | | |
| |||
Lines changed: 45 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
| |||
104 | 103 | | |
105 | 104 | | |
106 | 105 | | |
107 | | - | |
108 | | - | |
109 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
| 115 | + | |
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
| 120 | + | |
132 | 121 | | |
133 | 122 | | |
134 | 123 | | |
135 | 124 | | |
136 | 125 | | |
137 | 126 | | |
138 | 127 | | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | 128 | | |
145 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
146 | 135 | | |
147 | 136 | | |
148 | 137 | | |
149 | 138 | | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
157 | 154 | | |
158 | 155 | | |
159 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
160 | 171 | | |
161 | | - | |
162 | | - | |
| 172 | + | |
| 173 | + | |
163 | 174 | | |
164 | 175 | | |
165 | 176 | | |
| |||
Lines changed: 1 addition & 49 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | 29 | | |
32 | 30 | | |
33 | 31 | | |
34 | 32 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | 33 | | |
46 | 34 | | |
47 | 35 | | |
| |||
115 | 103 | | |
116 | 104 | | |
117 | 105 | | |
118 | | - | |
119 | | - | |
120 | | - | |
| 106 | + | |
121 | 107 | | |
122 | 108 | | |
123 | 109 | | |
| |||
129 | 115 | | |
130 | 116 | | |
131 | 117 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | 118 | | |
146 | 119 | | |
147 | 120 | | |
| |||
161 | 134 | | |
162 | 135 | | |
163 | 136 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | 137 | | |
186 | 138 | | |
187 | 139 | | |
| |||
Lines changed: 50 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
43 | 56 | | |
44 | 57 | | |
| 58 | + | |
| 59 | + | |
45 | 60 | | |
46 | 61 | | |
47 | 62 | | |
| |||
56 | 71 | | |
57 | 72 | | |
58 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
59 | 79 | | |
60 | 80 | | |
61 | 81 | | |
62 | 82 | | |
63 | | - | |
| 83 | + | |
64 | 84 | | |
65 | 85 | | |
66 | 86 | | |
67 | 87 | | |
68 | 88 | | |
69 | 89 | | |
70 | 90 | | |
71 | | - | |
| 91 | + | |
| 92 | + | |
72 | 93 | | |
73 | 94 | | |
74 | 95 | | |
75 | 96 | | |
76 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
77 | 100 | | |
78 | 101 | | |
79 | 102 | | |
| |||
107 | 130 | | |
108 | 131 | | |
109 | 132 | | |
110 | | - | |
| 133 | + | |
111 | 134 | | |
112 | 135 | | |
113 | 136 | | |
| |||
132 | 155 | | |
133 | 156 | | |
134 | 157 | | |
135 | | - | |
| 158 | + | |
136 | 159 | | |
137 | 160 | | |
138 | 161 | | |
| |||
146 | 169 | | |
147 | 170 | | |
148 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
149 | 191 | | |
150 | 192 | | |
151 | 193 | | |
152 | | - | |
| 194 | + | |
153 | 195 | | |
154 | 196 | | |
155 | 197 | | |
| |||
172 | 214 | | |
173 | 215 | | |
174 | 216 | | |
175 | | - | |
| 217 | + | |
176 | 218 | | |
177 | 219 | | |
178 | 220 | | |
| |||
0 commit comments