Skip to content

Speed up debugger connection#2231

Merged
AlexandraTrifan merged 3 commits intomainfrom
slow-debugger
Apr 1, 2026
Merged

Speed up debugger connection#2231
AlexandraTrifan merged 3 commits intomainfrom
slow-debugger

Conversation

@andreidanila1
Copy link
Copy Markdown
Contributor

Existent problem

Connecting to a device-heavy IIO context (e.g. M2k, ADRV9009) caused the IIOExplorer UI to freeze for several seconds before becoming responsive. Profiling identified two root causes:

Stylesheet propagation over hundreds of already-constructed widgets

Style::setBackground is called in IIOExplorer::setupUI, after IIOModel has already been constructed with all its IIOWidget children attached to m_mainWidget. Setting a stylesheet on a parent widget triggers Qt to recursively re-polish every child widget in the hierarchy. With hundreds of IIOWidgets already attached, this single call accounted for 64.7% of the total freeze.

Blocking IIOWidget construction on the UI thread

IIOModel::IIOModel built all IIOWidget instances for every device and channel attribute at connection time. Internally, IIOWidgetBuilder::createUIS() performs synchronous libiio reads for every attribute that exposes an _available variant:

res = iio_channel_attr_read(m_channel, m_optionsAttribute, buffer, ATTR_BUFFER_SIZE);                                                              
res = iio_device_attr_read(m_device,  m_optionsAttribute, buffer, ATTR_BUFFER_SIZE); 

These reads are blocking network calls (USB/IP backend) made on the UI thread, one per attribute, before the window even appears. On a device with 20 channels × 5 _available attributes this results in 100 sequential blocking reads. Beyond the libiio reads, IIOWidgets construction itself is expensive (especially for device-heavy contexts) - each widget goes through style application, layout setup (and others) at creation time.

Changes

  • Postpone IIOWidget construction to first expand/select
    • Building IIOWidgets for every device and channel attribute at connection time caused multi-second UI freezes on device-heavy contexts (e.g. M2k, ADRV9009).
  • Background population of all device/channel nodes
    • Populate the IIOTree nodes in different QEvents to prevent the application from freezing. I also retain the previous commit's functionality, allowing a node to be loaded on demand by selecting or expanding it.
  • IIOExplorer API updates

Tested on

I've tested this on Ubuntu 22.10, Kuiper 2-64, and Windows ADI using the ADRV9009 multidevice emu.
If possible, please also test on arm32 (and arm64) as well as macOS.
On Ubuntu, the performance improved from 4 seconds to 100 ms, and on Kuiper from ~50 seconds to ~2 seconds.

Copy link
Copy Markdown
Contributor

@Andrei-Fabian-Pop Andrei-Fabian-Pop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice, Godspeed 🫶

@andreidanila1 andreidanila1 marked this pull request as draft March 27, 2026 16:38
Building IIOWidgets for every device and channel attribute at
connection time caused multi-second UI freezes on device-heavy
contexts (e.g. M2k, ADRV9009).

Signed-off-by: andreidanila1 <andrei.danila@analog.com>
Store iio_context on context and context-attribute items so that
CliDetailsView can query libiio directly without depending on
IIOWidget data strategies. Guard connectLog against empty widget
lists to support eagerly created attribute items.

Signed-off-by: andreidanila1 <andrei.danila@analog.com>
@andreidanila1 andreidanila1 force-pushed the slow-debugger branch 2 times, most recently from 2678dcb to 5ba28a7 Compare April 1, 2026 05:31
…View.

Create all device/channel attribute items at connection time without
constructing IIOWidgets, so the tree is fully populated for search
immediately. Rewrite CliDetailsView to query libiio directly on a
background thread instead of reading from IIOWidget data strategies.

Signed-off-by: andreidanila1 <andrei.danila@analog.com>
@andreidanila1 andreidanila1 marked this pull request as ready for review April 1, 2026 07:19
Copy link
Copy Markdown
Contributor

@bindea-cristian bindea-cristian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super fast loading

Copy link
Copy Markdown
Contributor

@IonutMuthi IonutMuthi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested both using ssh and remote connection via IP on ADRV9375

Using ssh works fast.

Using the IP throw Analog VPN is slow, but this is generally true when using the VPN to access devices in the network

@AlexandraTrifan AlexandraTrifan merged commit 5752ace into main Apr 1, 2026
37 checks passed
@AlexandraTrifan AlexandraTrifan deleted the slow-debugger branch April 1, 2026 12:44
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.

5 participants