Skip to content

Conversation

@google-labs-jules
Copy link
Contributor

Implemented lru_cache for namedtuple creation in src/graphinate/modeling.py to improve performance. Verified with reproduction script and existing tests.


PR created automatically by Jules for task 1723915907974247202 started by @erivlis

Optimization:
The `element` function in `src/graphinate/modeling.py` was creating a new `namedtuple` class on every call, even for identical types and field names. This is expensive as it involves dynamic code generation and compilation. This change adds an `lru_cache` to cache the generated `namedtuple` classes, significantly improving performance for repeated element creation.

Impact:
- Reduces overhead of creating graph elements (nodes/edges) by ~30x in micro-benchmarks (10k items: 1.05s -> 0.033s).
- Reduces memory churn by reusing class definitions.
@google-labs-jules
Copy link
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@deepsource-io
Copy link

deepsource-io bot commented Jan 5, 2026

Here's the code health analysis summary for commits c36ff9b..ddf7860. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource JavaScript LogoJavaScript✅ SuccessView Check ↗
DeepSource Test coverage LogoTest coverage⚠️ Artifact not reportedTimed out: Artifact was never reportedView Check ↗
DeepSource Python LogoPython✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 5, 2026

@codacy-production
Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-0.05% (target: -1.00%) 85.71%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (c36ff9b) 1007 928 92.15%
Head commit (ddf7860) 1013 (+6) 933 (+5) 92.10% (-0.05%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#32) 7 6 85.71%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@codecov
Copy link

codecov bot commented Jan 5, 2026

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.32%. Comparing base (c36ff9b) to head (ddf7860).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/graphinate/modeling.py 71.42% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #32      +/-   ##
==========================================
- Coverage   90.46%   90.32%   -0.15%     
==========================================
  Files          22       22              
  Lines        1007     1013       +6     
  Branches       92       93       +1     
==========================================
+ Hits          911      915       +4     
- Misses         79       80       +1     
- Partials       17       18       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@erivlis erivlis closed this Jan 8, 2026
@erivlis erivlis deleted the bolt-cache-namedtuple-1723915907974247202 branch January 8, 2026 22:57
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