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

Remove @cached decorator and CACHE_MANAGER #2072

Merged

Conversation

jacobtylerwalls
Copy link
Member

Type of Changes

Type
βœ“ πŸ”¨ Refactoring

Description

See discussion in #1780, much of the remaining leaking was due to having an inferior version of the stdlib's @cached_property. There's no reason to maintain a poorer version ourselves.

Closes #1780

Benchmark

From the script linked here, I now see:

python3 memory.py

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)


Nodes INC: 103014
Nodes NEW: 103014
Dicts INC: 55562
Dicts NEW: 55562

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)


Nodes INC: 0
Nodes NEW: 103014
Dicts INC: 27
Dicts NEW: 55589

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)


Nodes INC: 0
Nodes NEW: 103014
Dicts INC: 15
Dicts NEW: 55604

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)


Nodes INC: 0
Nodes NEW: 103014
Dicts INC: 15
Dicts NEW: 55619

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)


Nodes INC: 0
Nodes NEW: 103014
Dicts INC: 15
Dicts NEW: 55634

While "Dicts INC" isn't perfect (isn't 0), I think we've finished all the work we've identified so far, and I'm okay closing the linked issue.

@jacobtylerwalls jacobtylerwalls added this to the 2.16.0 milestone Apr 1, 2023
@codecov
Copy link

codecov bot commented Apr 1, 2023

Codecov Report

Merging #2072 (220d78c) into main (6714f15) will decrease coverage by 0.05%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2072      +/-   ##
==========================================
- Coverage   92.82%   92.78%   -0.05%     
==========================================
  Files          95       94       -1     
  Lines       11066    11043      -23     
==========================================
- Hits        10272    10246      -26     
- Misses        794      797       +3     
Flag Coverage Ξ”
linux 92.54% <100.00%> (-0.05%) ⬇️
pypy 88.09% <100.00%> (-0.09%) ⬇️
windows 92.33% <100.00%> (-0.05%) ⬇️

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

Impacted Files Coverage Ξ”
astroid/manager.py 88.10% <ΓΈ> (-0.11%) ⬇️
astroid/bases.py 88.50% <100.00%> (-0.04%) ⬇️
astroid/decorators.py 84.07% <100.00%> (-1.42%) ⬇️
astroid/nodes/scoped_nodes/scoped_nodes.py 93.07% <100.00%> (+0.01%) ⬆️

... and 1 file with indirect coverage changes

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

Amazing !

@Pierre-Sassoulas
Copy link
Member

I'm wondering if this should go in 2.15.2

@jacobtylerwalls
Copy link
Member Author

I removed @cached without a deprecation warning. It will cause a few breakages in pylint. I know we're becoming more pragmatic about backwards compatibility in astroid, but if we're keeping to semantic versioning, let's not do it in a patch release. WDYT?

@Pierre-Sassoulas
Copy link
Member

Ha ok, we're using it elsewhere too. I thought it was only used in astroid and replaced by a proper cache on the fly. Make sense !

@jacobtylerwalls jacobtylerwalls merged commit c7b2be1 into pylint-dev:main Apr 1, 2023
21 checks passed
@jacobtylerwalls jacobtylerwalls deleted the remove-cache-manager branch April 15, 2023 15:03
@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 2.16.0, 3.0 Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Astroid is leaking memory
2 participants