Commit e04f936
Wire the per-type subscription cache into RclcppyyNode.create_subscription
The startup-JIT lane on cppyy_kit (subscription cache in rclcpp_kit) removes the
~2.8 s cppyy JIT of create_subscription<MsgT>; rclcppyy has to opt in to benefit.
RclcppyyNode.create_subscription previously did two uncacheable JITs per call: a
per-UUID cppyy.cppdef of a <Python.h> lambda trampoline, and the raw
create_subscription[MsgT] template. Both are replaced by:
* cpp_callback = std::function<void(std::shared_ptr<const MsgT>)>(callback) built
directly via cppyy -- it delivers the C++ message proxy straight to the Python
callback and manages the GIL, so the old raw-pointer rebinding trampoline is
gone; and
* rclcpp_kit.subscription_cache.make_subscription(node, cpp_type, header, topic,
qos, cpp_callback), which loads a prebuilt per-type .so (or schedules a
background build and returns None -> plain-template fallback this run).
The header is derived from the resolved C++ type string (_subscription_header,
rosidl CamelCase->snake) rather than rclcpp_kit.message_header: under acceleration
the message class is already a cppyy C++ type, for which message_header returns
None. subscription_cache is absent on the published suite 0.1.0, so the whole path
is guarded and falls back to the plain create_subscription[MsgT] call there
(pub/sub roundtrip tests still pass in the default env). Correctness first; the
cache is a pure speedup.
Measured on the real `ros2 topic hz` (demo-topic-hz-startup, time to first hz line):
stock 1.7 s; RCLCPPYY_ENABLE_HOOK=1 cold 8.3 s, warm 4.1 s. The subscription cache
cut the warm start ~7.0 s -> 4.1 s (the eliminated create_subscription<Image> JIT);
the residual gap over stock is rclcpp bring-up (cppyy symbol discovery + adapters),
not yet cached. Delivery verified: hooked ros2 topic hz reports exact rates.
pixi run test: 32 passed. pixi run lint: clean. README startup section updated.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 0bbeeea commit e04f936
3 files changed
Lines changed: 94 additions & 90 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
284 | | - | |
| 284 | + | |
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
299 | 301 | | |
300 | 302 | | |
301 | 303 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
19 | 39 | | |
20 | 40 | | |
21 | 41 | | |
| |||
75 | 95 | | |
76 | 96 | | |
77 | 97 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | 98 | | |
99 | | - | |
100 | 99 | | |
101 | 100 | | |
102 | 101 | | |
| |||
310 | 309 | | |
311 | 310 | | |
312 | 311 | | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
355 | 321 | | |
356 | 322 | | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
368 | 350 | | |
369 | 351 | | |
370 | | - | |
371 | | - | |
| 352 | + | |
| 353 | + | |
372 | 354 | | |
373 | | - | |
374 | | - | |
| 355 | + | |
375 | 356 | | |
376 | 357 | | |
377 | | - | |
| 358 | + | |
378 | 359 | | |
379 | 360 | | |
380 | | - | |
| 361 | + | |
381 | 362 | | |
382 | 363 | | |
383 | 364 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
298 | 303 | | |
299 | 304 | | |
300 | 305 | | |
301 | 306 | | |
302 | 307 | | |
303 | 308 | | |
| 309 | + | |
304 | 310 | | |
305 | 311 | | |
306 | 312 | | |
| |||
313 | 319 | | |
314 | 320 | | |
315 | 321 | | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
316 | 337 | | |
317 | 338 | | |
318 | 339 | | |
| |||
0 commit comments