ni / ni/nitypes-python

DigitalWaveform.signals introduces a reference cycle

Open
#131 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

tech debt
Dominant language
Python
Stars
6
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Tech Debt

There is a reference cycle between DigitalWaveform and DigitalWaveformSignal/DigitalWaveformSignalCollection. Python normally uses reference counting to free objects, but it also has a generational GC that can clean up reference cycles, and apparently this can affect application performance.

We should evaluate whether to use weakref to break this cycle, and if so, how.

  • Should the parent->child link be a weak ref? The parent caches the children and can reconstruct them if needed.
  • Should the child->parent link be a weak ref? Once this is invalidated, the child object is unusable, but many use cases will reference the parent.

AB#3178116

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

Start by tracing references among DigitalWaveform, DigitalWaveformSignal, and DigitalWaveformSignalCollection. Compare the parent-to-child and child-to-parent ownership options described in the issue, then determine whether weakref can break the cycle without making common child usage invalid. Done means the ownership strategy is decided and its performance implications are evaluated.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, performance
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.