This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2010年11月12日 21:24 by pitrou, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| globcache5.patch | pitrou, 2010年11月12日 21:24 | |||
| Messages (6) | |||
|---|---|---|---|
| msg121081 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2010年11月12日 21:24 | |
Here is the Nth patch for a globals/builtins cache. As other caches at the same kind, it shows very small to no gain on non-micro benchmarks, showing that contrary to popular belief, globals/builtins lookup are not a major roadblock in today's Python performance. However, this patch could be useful in combination with other optimizations such as issue10399. Indeed, using the globals/builtins version id, it is easy and very cheap to detect whether the function pointed to by a global name has changed or not. As for micro-benchmarks, they show that there is indeed a good improvement on builtins lookups: $ ./python -m timeit "x=len;x=len;x=len;x=len;x=len;x=len;x=len;x=len;x=len;x=len;" -> without patch: 1000000 loops, best of 3: 0.282 usec per loop -> with patch: 10000000 loops, best of 3: 0.183 usec per loop |
|||
| msg121105 - (view) | Author: Skip Montanaro (skip.montanaro) * (Python triager) | Date: 2010年11月13日 01:56 | |
Might such a cache lay the groundwork for more aggressive optimizations by JITs like Unladen Swallow? |
|||
| msg121147 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2010年11月13日 18:03 | |
Unladen actually has something like this in place for performance optimizations. Not sure how Antoine's approach differs, though. |
|||
| msg121150 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2010年11月13日 18:14 | |
There aren't many possible approaches. The more complex variants of globals caches try to also speedup writes, which is IMO a waste of time since rebinding globals is not a good coding practice, and especially not in the middle of time-critical loops. (by the way, the patch only addresses normal functions, but generators would easily benefit from a similar treatment) And Skip is right that this would be most useful when paired with a JIT (allowing for aggressive specialization, and possibly inlining). |
|||
| msg282608 - (view) | Author: Inada Naoki (methane) * (Python committer) | Date: 2016年12月07日 09:57 | |
dict has ma_version for now. @haypo, how do you think about this patch? Would you reimplement global cache? Or may I update this patch? |
|||
| msg358864 - (view) | Author: Inada Naoki (methane) * (Python committer) | Date: 2019年12月25日 13:42 | |
This is implemented in #26219. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:08 | admin | set | github: 54610 |
| 2019年12月25日 13:42:25 | methane | set | status: open -> closed resolution: fixed messages: + msg358864 stage: patch review -> resolved |
| 2016年12月07日 09:57:49 | methane | set | messages:
+ msg282608 versions: + Python 3.7, - Python 3.3 |
| 2016年01月27日 17:51:48 | methane | set | nosy:
+ methane |
| 2013年04月07日 23:10:18 | vstinner | set | nosy:
+ vstinner |
| 2013年01月11日 17:11:37 | brett.cannon | set | nosy:
- brett.cannon |
| 2011年03月19日 19:10:19 | skip.montanaro | set | nosy:
- skip.montanaro |
| 2010年11月13日 18:14:13 | pitrou | set | messages: + msg121150 |
| 2010年11月13日 18:03:15 | brett.cannon | set | nosy:
+ brett.cannon messages: + msg121147 |
| 2010年11月13日 06:59:25 | georg.brandl | set | nosy:
+ georg.brandl |
| 2010年11月13日 01:56:13 | skip.montanaro | set | nosy:
+ skip.montanaro messages: + msg121105 |
| 2010年11月12日 23:59:49 | eric.smith | set | nosy:
+ eric.smith |
| 2010年11月12日 21:24:29 | pitrou | create | |