Commit 707cd0f
authored
Replace per-iter conan info subprocess with cached /search API (#2098)
## Summary
Library-builder hot path was shelling out to `conan info -r ceserver .` once per build combination to derive the conan package_id. Replaced with a single `GET /v1/conans/{lib}/{ver}/{lib}/{ver}/search` cached on the builder instance, with client-side settings matching.
Pattern ported from `compiler-explorer/lib/buildenvsetup/ceconan.ts` (@partouf's existing rewrite on the Node.js side). Match rules - headeronly / cshared compiler wildcards, libcxx and arch wildcards under those, stdver always-match - extracted as module-level helpers (`match_conan_settings`, `conan_search_url`, `build_target_settings` in `library_builder.py`) and shared across all four builder classes (c++, rust, fortran, go) to avoid drift.
Refs #1342.
## Performance
Measured locally with conan 1.66 against the live conan proxy:
| | per-iteration cost |
|---|---|
| old (`conan info` subprocess) | ~335ms |
| new (cached `/search` + dict scan) | ~0.5ms after a one-off ~1s search |
| iterations | old | new | speedup |
|--:|--:|--:|--:|
| 20 | 6.7s | 1.0s | 7x |
| 40 | 13.4s | 1.0s | 13x |
| 200 | 67s | 1.1s | 60x |
End-to-end timing on a real lin-builder is the natural follow-up; couldn't run that locally because CE customises conan's `settings.yml` with non-standard values (e.g. `compiler.version=g141`, the `flagcollection` setting) that only exist on the builder bootstrap.
## Subtle bits
- **`set_as_uploaded` ordering.** The new search endpoint can only see packages already on the remote, so the original ordering (`get_conan_hash` -> conditional `upload_builds`) would have crashed every first-time upload with `RuntimeError: Error determining conan hash`. Reordered to `get_build_annotations` -> conditional `upload_builds` -> `get_conan_hash`. `upload_builds` invalidates `_possible_builds`, so the post-upload `get_conan_hash` sees the fresh search response. `test_set_as_uploaded_first_time_does_not_raise` is the regression test for this path; it fails on the un-reordered version.
- **TS port faithfulness.** Match rules check the candidate's specific key (e.g. `candidate.get("compiler.version") in ("headeronly", "cshared")`) rather than a single up-front predicate, mirroring the TS implementation. Worth comparing to `ceconan.ts:249-275` if reviewing the matcher.
- **URL encoding** uses `urllib.parse.quote(s, safe="")` to match `encodeURIComponent` semantics for lib/version path segments.
- **Cache-invalidation point.** All four `upload_builds` set `self._possible_builds = None` after a successful upload, so the next `get_conan_hash` in the same builder instance refetches.
## Out of scope
- TTL on `hasFailedBefore` (the trunk-poisoning aspect of #1342). Separate, server-side concern.
- Consolidating `resil_get` / HTTP-retry into a shared helper across the four builders. Pre-existing drift, not made worse by this PR.
## Test plan
- [x] `make test` (636 passed, 1 skipped)
- [x] `make static-checks` clean
- [x] Two passes of code review by an LLM agent
- [x] Live validation against `conan.compiler-explorer.com`: real boost_bin/clang_barry hash returned by the matcher resolves to a real annotation; libcxx mismatch returns None; eigen/3.4.0 headeronly matches across compiler/libcxx/arch but rejects on os mismatch
- [x] Regression test for fresh-upload path verified to fail when the ordering fix is reverted
- [ ] End-to-end timing on a real lin-builder (follow-up; needs CE's customised conan settings)1 parent 24ecd1b commit 707cd0f
8 files changed
Lines changed: 666 additions & 128 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
49 | | - | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
450 | 450 | | |
451 | 451 | | |
452 | 452 | | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
469 | 462 | | |
470 | | - | |
471 | | - | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
472 | 468 | | |
473 | 469 | | |
474 | 470 | | |
| |||
581 | 577 | | |
582 | 578 | | |
583 | 579 | | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
584 | 588 | | |
585 | 589 | | |
586 | 590 | | |
587 | 591 | | |
588 | | - | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
| 592 | + | |
593 | 593 | | |
594 | 594 | | |
595 | 595 | | |
| |||
705 | 705 | | |
706 | 706 | | |
707 | 707 | | |
| 708 | + | |
708 | 709 | | |
709 | 710 | | |
710 | 711 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| |||
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
81 | | - | |
82 | 80 | | |
83 | 81 | | |
84 | 82 | | |
| |||
133 | 131 | | |
134 | 132 | | |
135 | 133 | | |
136 | | - | |
| 134 | + | |
137 | 135 | | |
138 | 136 | | |
139 | 137 | | |
| |||
412 | 410 | | |
413 | 411 | | |
414 | 412 | | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
419 | 422 | | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
437 | 429 | | |
438 | 430 | | |
439 | 431 | | |
| |||
557 | 549 | | |
558 | 550 | | |
559 | 551 | | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
560 | 560 | | |
561 | 561 | | |
562 | 562 | | |
563 | 563 | | |
564 | 564 | | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
569 | 565 | | |
570 | 566 | | |
571 | 567 | | |
| |||
606 | 602 | | |
607 | 603 | | |
608 | 604 | | |
| 605 | + | |
609 | 606 | | |
610 | 607 | | |
611 | 608 | | |
| |||
0 commit comments