Commit 9ca9bc4
authored
refactor(profiling): change how
## Description
This change replicates P403n1x87/echion#202.
This PR changes the way `GenInfo::is_running` works. Previously, it
would indicate whether the _current_ coroutine was on CPU; now, it
indicates whether the current coroutine _or the coroutine it
(recursively) awaits_ is on CPU.
Making that change also allows us to do less work when we check whether
the current coroutine is on CPU or not. Because a Coroutine / Generator
/ `GenInfo` can only be running if it is not awaiting another Generator,
we do not need to compute `is_running` if we have `await != nullptr`
(and we take `await->is_running` for the value in that case).
Making that change makes it easier to check whether a Task is currently
on-CPU; and allows to do less work when we decide how to unwind
`asyncio` Tasks (cf the changes in `TaskInfo` which doesn't need the
`is_on_cpu` method that iterates on the `await` chain anymore).
Note that I checked whether `GenInfo::is_running` was used in any other
way than the one I describe and simplify; it is not, so I do think this
change is safe to make as-is.
**Note** This PR makes sense on its own, but it is in the context of
making P403n1x87/echion#198 simpler.
**Note** This doesn't need a changelog entry as it makes no difference
to the user, it's purely a refactor.GenInfo::is_running works (#15508)1 parent 9f1242e commit 9ca9bc4
2 files changed
+21
-42
lines changedLines changed: 19 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | | - | |
| 74 | + | |
| 75 | + | |
76 | 76 | | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
| 80 | + | |
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
| |||
149 | 151 | | |
150 | 152 | | |
151 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
152 | 161 | | |
153 | | - | |
| 162 | + | |
154 | 163 | | |
155 | | - | |
| 164 | + | |
156 | 165 | | |
157 | | - | |
| 166 | + | |
158 | 167 | | |
| 168 | + | |
159 | 169 | | |
160 | 170 | | |
161 | 171 | | |
| |||
178 | 188 | | |
179 | 189 | | |
180 | 190 | | |
181 | | - | |
| 191 | + | |
182 | 192 | | |
183 | 193 | | |
184 | 194 | | |
| |||
187 | 197 | | |
188 | 198 | | |
189 | 199 | | |
| 200 | + | |
190 | 201 | | |
191 | 202 | | |
192 | 203 | | |
193 | 204 | | |
194 | 205 | | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | 206 | | |
217 | 207 | | |
218 | 208 | | |
| |||
242 | 232 | | |
243 | 233 | | |
244 | 234 | | |
245 | | - | |
246 | | - | |
247 | 235 | | |
248 | 236 | | |
249 | 237 | | |
| |||
262 | 250 | | |
263 | 251 | | |
264 | 252 | | |
265 | | - | |
| 253 | + | |
| 254 | + | |
266 | 255 | | |
267 | 256 | | |
268 | 257 | | |
| |||
Lines changed: 2 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | 255 | | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
| 256 | + | |
267 | 257 | | |
268 | 258 | | |
269 | 259 | | |
270 | 260 | | |
271 | 261 | | |
272 | 262 | | |
273 | | - | |
| 263 | + | |
274 | 264 | | |
275 | 265 | | |
276 | 266 | | |
| |||
0 commit comments