Skip to content

docs: correct what makes path_generation() slow - #41

Merged
HugoFara merged 1 commit into
mainfrom
docs/correct-path-generation-cost
Sep 4, 2026
Merged

HugoFara merged 1 commit into
mainfrom
docs/correct-path-generation-cost

Conversation

@HugoFara

@HugoFara HugoFara commented Sep 4, 2026

Copy link
Copy Markdown
Owner

The benchmarks page told users the wrong thing about path_generation(), and I wrote it. Profiling for #29 shows both of its claims are false.

What it said

It searches over n_orientation_samples candidate orientations (36 by default) and runs Burmester synthesis for each, which is why it costs well over a second.

If you need it faster, lowering n_orientation_samples trades solution coverage for time roughly linearly.

What is actually true

Verification dominates, not search. Simulating each surviving candidate through _verify_coupler_path is 67% of the runtime; Burmester synthesis is 21%.

n_orientation_samples is close to inert. It feeds:

per_axis = max(6, int(round(n_samples ** (1.0 / free))))

With 4 precision points free = 3, so n_samples**(1/3) stays under 6 for every value up to 216 — the floor swallows the parameter. Its only other use is a cap of n_samples * n_samples, a quadratic cap on a grid of size 6**free.

n_orientation_samples README points benchmark points
6 338 ms, 10 solutions 511 ms, 0 solutions
12 340 ms, 10 solutions 1668 ms, 10 solutions
36 (default) 336 ms, 10 solutions 1676 ms, 10 solutions
72 337 ms, 10 solutions 1679 ms, 10 solutions

Lowering it does not buy time. It eventually just returns nothing.

max_solutions is the real control, since the search stops once it has that many verified solutions:

max_solutions Time Solutions
1 124 ms 1
10 (default) 338 ms 10
20 1181 ms 20
None 2316 ms 79

Cost depends on which points you ask for. Two four-point problems, both returning ten solutions: 336 ms for the README's points, 1676 ms for the benchmark's. The headline table reports the slower one, so the page now frames it as an upper bound rather than a typical figure.

Changes

  • docs/source/benchmarks.md: replaces the wrong explanation with a breakdown of where the time goes, the max_solutions table, the point-set sensitivity, and a note that n_orientation_samples is not a working control.
  • path_generation() docstring: says verification dominates, points users at max_solutions, and warns that n_orientation_samples is a weak control.

This documents current behaviour only. Whether n_orientation_samples should be repaired or removed is a decision for #29 — as is the fact that switching verification to step_fast() would collapse that 67%, which is blocked on #40.

The benchmarks page blamed the orientation sweep and advised lowering
n_orientation_samples, saying it trades coverage for time roughly
linearly. Profiling shows neither claim holds.

Verification, not search, dominates: simulating each surviving candidate
through _verify_coupler_path is 67% of the runtime, Burmester synthesis
21%.

n_orientation_samples is close to inert. It feeds

    per_axis = max(6, int(round(n_samples ** (1.0 / free))))

so with 4 precision points the per-axis resolution is 6 for every value
up to 216. Measured on the README's points, 6/12/36/72 all take the same
time and return the same ten solutions; on the benchmark's points, 6
returns zero solutions and is not faster.

max_solutions is the real control -- 124 ms for one solution, 338 ms for
ten, 2316 ms for all 79 -- because the search stops once it has that many
verified solutions. The page and the docstring now say that, and the page
records that cost depends heavily on which points are asked for: two
four-point problems each returning ten solutions measured 336 ms and
1676 ms.

Documents current behaviour. Whether n_orientation_samples should be
repaired or removed is left to #29.
@HugoFara
HugoFara merged commit 0774301 into main Sep 4, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant