Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of select_children() and select_parents() #11099

Merged
merged 2 commits into from
Dec 5, 2024

Conversation

peterallenwebb
Copy link
Contributor

@peterallenwebb peterallenwebb commented Dec 5, 2024

Problem

The select_children() and select_parents() functions have been identified as performance bottlenecks, particularly as they are used via semantic layer code.

We've received reports of projects spending over 15 minutes waiting for these operations.

Solution

The present changes are behavior-neutral, but they avoid the repeated application of networkx graph views, which are slow. We already have some unit tests covering these functions, but went further and tested that the new functions gave the same results as the old on a large set of real-world graphs, choosing sets of "selected" nodes at random at a variety of sizes. I observed a reliable speedup of 60-100x for select_children() and 20-30x for select_parents().

This should reduce the project time mentioned above from 15 minutes to less than 15 seconds.

Checklist

  • I have read the contributing guide and understand what's expected of me.
  • I have run this code in development, and it appears to resolve the stated issue.
  • This PR includes tests, or tests are not required or relevant for this PR.
  • This PR has no interface changes (e.g., macros, CLI, logs, JSON artifacts, config files, adapter interface, etc.) or this PR has already received feedback and approval from Product or DX.
  • This PR includes type annotations for new and modified functions.

@peterallenwebb peterallenwebb requested a review from a team as a code owner December 5, 2024 19:29
@cla-bot cla-bot bot added the cla:yes label Dec 5, 2024
Copy link
Contributor

github-actions bot commented Dec 5, 2024

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

Copy link

codecov bot commented Dec 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.13%. Comparing base (ff6745c) to head (3a7c52d).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11099      +/-   ##
==========================================
- Coverage   89.13%   89.13%   -0.01%     
==========================================
  Files         183      183              
  Lines       23784    23782       -2     
==========================================
- Hits        21200    21198       -2     
  Misses       2584     2584              
Flag Coverage Δ
integration 86.41% <100.00%> (-0.04%) ⬇️
unit 62.20% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Unit Tests 62.20% <100.00%> (-0.01%) ⬇️
Integration Tests 86.41% <100.00%> (-0.04%) ⬇️

@peterallenwebb peterallenwebb merged commit 1472b86 into main Dec 5, 2024
56 checks passed
@peterallenwebb peterallenwebb deleted the paw/better_parents_and_children branch December 5, 2024 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants