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

Use the inference cache when no context is provided #2257

Merged
merged 1 commit into from
Jul 19, 2023

Conversation

jacobtylerwalls
Copy link
Member

Type of Changes

Type
🔨 Refactoring

Description

Previously, without an explicit InferenceContext instance, no checks were done against the global inference cache, and no entries were stored in it. This is a problem given how often the default context=None is used.

Refs #529. The third point of #529 muses about some sort of global inference cache, which was added later in cf6528c. This current PR just finishes the job. I'll leave remarks on #529 about the remaining possible improvements.

There will be one change needed in pylint where the checker depends on retroengineering a particular inference path being traveled twice, but I've already got a patch for it.

Previously, without an explicit InferenceContext instance,
no checks were done against the global inference cache,
and no entries were stored in it.
@jacobtylerwalls jacobtylerwalls added topic-performance pylint-tested PRs that don't cause major regressions with pylint labels Jul 19, 2023
@jacobtylerwalls jacobtylerwalls added this to the 3.0.0a9 milestone Jul 19, 2023
@codecov
Copy link

codecov bot commented Jul 19, 2023

Codecov Report

Merging #2257 (c03af60) into main (4c3bebb) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2257      +/-   ##
==========================================
- Coverage   92.80%   92.78%   -0.03%     
==========================================
  Files          94       94              
  Lines       10941    10937       -4     
==========================================
- Hits        10154    10148       -6     
- Misses        787      789       +2     
Flag Coverage Δ
linux 92.59% <100.00%> (-0.03%) ⬇️
pypy 90.89% <100.00%> (-0.01%) ⬇️
windows 92.37% <100.00%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
astroid/nodes/node_ng.py 93.57% <100.00%> (-0.10%) ⬇️

... and 3 files with indirect coverage changes

* Use the global inference cache when inferring, even without an explicit
``InferenceContext``. This is a significant performance improvement given how
often methods default to ``None`` for the context argument. (Linting ``astroid``
itself now takes ~5% less time on Python 3.12; other projects requiring more
Copy link
Member Author

Choose a reason for hiding this comment

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

I saw a 14% improvement with music21. We can do an alpha and eyeball the pylint primer numbers.

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.

Sounds amazing !

@jacobtylerwalls jacobtylerwalls merged commit cf8763a into pylint-dev:main Jul 19, 2023
20 checks passed
@jacobtylerwalls jacobtylerwalls deleted the more-cache-hits branch July 19, 2023 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pylint-tested PRs that don't cause major regressions with pylint topic-performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants