Skip to content

feat: support doc comments in Motoko bindgen#634

Merged
christoph-dfinity merged 15 commits intomasterfrom
christoph/resolved-idl-prog
Jul 8, 2025
Merged

feat: support doc comments in Motoko bindgen#634
christoph-dfinity merged 15 commits intomasterfrom
christoph/resolved-idl-prog

Conversation

@christoph-dfinity
Copy link
Copy Markdown
Contributor

@christoph-dfinity christoph-dfinity commented Jul 2, 2025

Overview
Adds support for reflecting doc comments from Candid declaration files to the Motoko generated bindings.

Internally, it adds the IDLMergedProg which is constructed when parsing the Candid declarations and is passed to the Motoko bindings generator. It containts the syntax types along with the associated comments, and it's traversed in parallel with the inner types by the binding generator.

Follow-up PRs will add support for doc comments in the other bindings generators.

Closes #625.

@christoph-dfinity christoph-dfinity requested a review from ilbertt July 2, 2025 07:50
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jul 2, 2025

Name Max Mem (Kb) Encode Decode
blob 4_224 4_206_559 2_121_055 ($\textcolor{green}{-0.00\%}$)
btreemap 75_456 4_261_360_630 15_191_359_361 ($\textcolor{green}{-0.33\%}$)
nns 192 1_966_454 ($\textcolor{green}{-0.01\%}$) 5_468_145 ($\textcolor{green}{-0.03\%}$)
nns_list_proposal 1_088 6_814_372 ($\textcolor{red}{0.00\%}$) 66_996_590 ($\textcolor{green}{-1.29\%}$)
option_list 128 7_481_063 ($\textcolor{red}{0.08\%}$) 25_531_164 ($\textcolor{green}{-0.95\%}$)
text 6_336 4_203_506 7_877_219 ($\textcolor{green}{-0.00\%}$)
variant_list 128 7_537_258 ($\textcolor{red}{0.08\%}$) 24_121_592 ($\textcolor{green}{-0.57\%}$)
vec_int16 16_704 123_693_002 1_019_238_917 ($\textcolor{green}{-4.71\%}$)
  • Parser cost: 15_211_448 ($\textcolor{red}{0.01\%}$)
  • Extra args: 3_165_441 ($\textcolor{red}{0.59\%}$)
Click to see raw report
---------------------------------------------------

Benchmark: blob
  total:
    instructions: 6.33 M (-0.00%) (change within noise threshold)
    heap_increase: 66 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 4.21 M (no change)
    heap_increase: 66 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 2.12 M (-0.00%) (change within noise threshold)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: text
  total:
    instructions: 12.08 M (-0.00%) (change within noise threshold)
    heap_increase: 99 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 4.20 M (no change)
    heap_increase: 66 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 7.88 M (-0.00%) (change within noise threshold)
    heap_increase: 33 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: vec_int16
  total:
    instructions: 1.14 B (improved by 4.22%)
    heap_increase: 261 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 123.69 M (no change)
    heap_increase: 261 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 1.02 B (improved by 4.71%)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: btreemap
  total:
    instructions: 19.45 B (-0.26%) (change within noise threshold)
    heap_increase: 1179 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 4.26 B (no change)
    heap_increase: 159 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 15.19 B (-0.33%) (change within noise threshold)
    heap_increase: 1020 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: option_list
  total:
    instructions: 33.01 M (-0.72%) (change within noise threshold)
    heap_increase: 2 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 7.48 M (0.08%) (change within noise threshold)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 25.53 M (-0.95%) (change within noise threshold)
    heap_increase: 2 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: variant_list
  total:
    instructions: 31.66 M (-0.41%) (change within noise threshold)
    heap_increase: 2 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 7.54 M (0.08%) (change within noise threshold)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 24.12 M (-0.57%) (change within noise threshold)
    heap_increase: 2 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: nns
  total:
    instructions: 23.49 M (-0.00%) (change within noise threshold)
    heap_increase: 3 pages (no change)
    stable_memory_increase: 0 pages (no change)

  0. Parsing (scope):
    calls: 1 (no change)
    instructions: 15.21 M (0.01%) (change within noise threshold)
    heap_increase: 3 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 1.97 M (-0.01%) (change within noise threshold)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 5.47 M (-0.03%) (change within noise threshold)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: nns_list_proposal
  total:
    instructions: 73.81 M (-1.17%) (change within noise threshold)
    heap_increase: 17 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 6.81 M (0.00%) (change within noise threshold)
    heap_increase: 3 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 67.00 M (-1.29%) (change within noise threshold)
    heap_increase: 14 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: extra_args
  total:
    instructions: 3.17 M (0.59%) (change within noise threshold)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Summary:
  instructions:
    status:   Improvements detected 🟢
    counts:   [total 9 | regressed 0 | improved 1 | new 0 | unchanged 8]
    change:   [max +18.60K | p75 -10 | median -130.93K | p25 -875.77K | min -50.33M]
    change %: [max +0.59% | p75 -0.00% | median -0.26% | p25 -0.72% | min -4.22%]

  heap_increase:
    status:   No significant changes 👍
    counts:   [total 9 | regressed 0 | improved 0 | new 0 | unchanged 9]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

  stable_memory_increase:
    status:   No significant changes 👍
    counts:   [total 9 | regressed 0 | improved 0 | new 0 | unchanged 9]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

---------------------------------------------------

Only significant changes:
| status | name                   | calls |   ins |  ins Δ% |  HI |  HI Δ% | SMI |  SMI Δ% |
|--------|------------------------|-------|-------|---------|-----|--------|-----|---------|
|   -    | vec_int16              |       | 1.14B |  -4.22% | 261 |  0.00% |   0 |   0.00% |
|   -    | vec_int16::2. Decoding |     1 | 1.02B |  -4.71% |   0 |  0.00% |   0 |   0.00% |

ins = instructions, HI = heap_increase, SMI = stable_memory_increase, Δ% = percent change

---------------------------------------------------
Successfully persisted results to canbench_results.yml

@christoph-dfinity christoph-dfinity force-pushed the christoph/resolved-idl-prog branch from d04c3da to e298c4a Compare July 2, 2025 09:56
@christoph-dfinity christoph-dfinity force-pushed the christoph/resolved-idl-prog branch from e298c4a to b96a124 Compare July 2, 2025 11:03
@ilbertt ilbertt self-assigned this Jul 2, 2025
Comment thread rust/candid/src/types/syntax.rs Outdated
Comment thread rust/candid/src/types/syntax.rs Outdated
@ilbertt ilbertt changed the title wip: Constructs a merged IDLProg feat: support doc comments in Motoko bindgen Jul 7, 2025
@christoph-dfinity christoph-dfinity marked this pull request as ready for review July 7, 2025 10:09
@christoph-dfinity christoph-dfinity requested a review from a team as a code owner July 7, 2025 10:09
@christoph-dfinity christoph-dfinity requested a review from lwshang July 7, 2025 11:12
@christoph-dfinity christoph-dfinity merged commit a9509b2 into master Jul 8, 2025
11 checks passed
@christoph-dfinity christoph-dfinity deleted the christoph/resolved-idl-prog branch July 8, 2025 05:50
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.

3 participants