Skip to content

Simplify connection topology detection#276

Open
Sympatron wants to merge 1 commit intogoToMain:masterfrom
Sympatron:simpler-topology-check
Open

Simplify connection topology detection#276
Sympatron wants to merge 1 commit intogoToMain:masterfrom
Sympatron:simpler-topology-check

Conversation

@Sympatron
Copy link
Contributor

Disjoint set uses over 1 kB of stack and the algorithm used is O(n²) in all cases.

This uses 1kB less stack space and is O(n) in case of a single channel and in case of one PD per channel.
It also needs less flash.

The runtime complexity is not the main issue here, just a side effect. I mainly started working on this, because I got stack overflow errors in my application during setup.

Disjoint set uses a kB of stack and the algorithm used is O(n²) in all cases. This uses way less stack space, is O(n) in case of a single channel and in case of one PD per channel and it also needs less flash.
@sidcha
Copy link
Member

sidcha commented Feb 4, 2026

Can you please post something about failure? Like, how does your channel topology look? I know this code hasn't been touched in a while, so maybe it's broken.

It's not a whole lot of code, so I can't imagine any serious change in code size with either approach.

@Sympatron
Copy link
Contributor Author

The code was fine. The problem was that my stack was not large enough. On a tiny microcontroller 1kB can be a lot. When I made the stack bigger it worked. But I still think it would be better to not use so much RAM if it is not necessary. Especially stack which can be surprising and very hard to diagnose if it goes wrong in a microcontroller (i.e. without MMU).

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.

2 participants