dfinity / dfinity/candid

perf: Subtype checking should not perform quadratic traversal

Open
#603 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
301
Forks
85
Avg merge
1h 4m
Merged PRs (30d)
4

Description

The equality check performed at the beginning of subtype checking: https://github.com/dfinity/candid/blob/30c388671462aecdc4a3a9753d50dc2e8208c200/rust/candid/src/types/subtype.rs#L39-L41
should only do a cheap check for "physical" equality (using ptr_eq on anything non-primitive).

Otherwise we do full traversals of complex nested types at every level (quadratic).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read rust/candid/src/types/subtype.rs around lines 39–41 and trace the equality check at the start of subtype checking. Confirm that non-primitive types use a physical ptr_eq check rather than repeatedly traversing nested types, while preserving the existing subtype behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, performance
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.