Skip to content

Fixed #30498 -- Fixed proxy class caching in lazy(). - #11399

Merged
felixxm merged 1 commit into
django:masterfrom
bluetech:fix-lazy-perf
May 22, 2019
Merged

felixxm merged 1 commit into
django:masterfrom
bluetech:fix-lazy-perf

Conversation

@bluetech

Copy link
Copy Markdown
Contributor

@bluetech bluetech changed the title Fixed #30498 -- Fixed lazy() class preparation not being cached correctly Fixed #30498 -- Fixed lazy() class preparation not being cached correctly. May 22, 2019
@felixxm felixxm self-assigned this May 22, 2019
@felixxm

felixxm commented May 22, 2019

Copy link
Copy Markdown
Member

@bluetech Thanks for this patch 🚀 Can we add a test?

@bluetech

Copy link
Copy Markdown
Contributor Author

@felixxm Thanks for taking a look. I didn't add a test because this is a performance bug, not a logic bug (the behavior before is the same, just slower). I can't come up with a test which would not involve peeking into the internal implementation bowls of lazy (e.g. check that __prepare_class__ is only called once).

@charettes

Copy link
Copy Markdown
Member

I think it might be worth adding a regression test even if it asserts against internals else this is likely to regress.

def identity(x): return x
lazy_identity = lazy(identity, int)
self.assertTrue(lazy_identity(1).__class__._proxy____prepared)

It might be worth adding a comment explain the reasoning behind this assertion.

@bluetech

Copy link
Copy Markdown
Contributor Author

OK then, I added a test. It fails before and passes after.

@felixxm felixxm changed the title Fixed #30498 -- Fixed lazy() class preparation not being cached correctly. Fixed #30498 -- Fixed proxy class caching in lazy(). May 22, 2019
@felixxm

felixxm commented May 22, 2019

Copy link
Copy Markdown
Member

@bluetech Thanks for this patch 🚀

lazy() should prepare the proxy class only once (the first time it's
used) not on every call.

Regression in b4e76f3.
@felixxm
felixxm merged commit a2c31e1 into django:master May 22, 2019
@drewpc

drewpc commented Jul 29, 2019

Copy link
Copy Markdown

@felixxm this patch was merged into django:master on May 22 but has not been released in any of the bug fix releases for 1.11, 2.1, or 2.2 since May. What needs to happen for this fix to be released in a near-term bug fix release? Should PRs be opened applying the same fix to those stable branches?

@felixxm

felixxm commented Jul 29, 2019

Copy link
Copy Markdown
Member

This patch doesn't qualify for a backport.

davidgegiya added a commit to davidgegiya/agent-orchestrator that referenced this pull request Nov 8, 2026
…ctly

Pin b711eafd2aabdf22e1d529bfb76dd8d3356d7000 and its regression selectors for reproducible runs.

Source: django/django#11399
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.

4 participants