Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c7a8f674
Commit
c7a8f674
authored
Nov 15, 2016
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #28618: Mark dict lookup functions as hot
It's common to see these functions in the top 3 of "perf report".
parent
d5f599a3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
Include/pyport.h
Include/pyport.h
+2
-2
Objects/dictobject.c
Objects/dictobject.c
+4
-4
No files found.
Include/pyport.h
View file @
c7a8f674
...
@@ -498,7 +498,7 @@ extern "C" {
...
@@ -498,7 +498,7 @@ extern "C" {
#endif
#endif
/* Py_HOT_FUNCTION
/*
_
Py_HOT_FUNCTION
* The hot attribute on a function is used to inform the compiler that the
* The hot attribute on a function is used to inform the compiler that the
* function is a hot spot of the compiled program. The function is optimized
* function is a hot spot of the compiled program. The function is optimized
* more aggressively and on many target it is placed into special subsection of
* more aggressively and on many target it is placed into special subsection of
...
@@ -506,7 +506,7 @@ extern "C" {
...
@@ -506,7 +506,7 @@ extern "C" {
* locality.
* locality.
*
*
* Usage:
* Usage:
* int Py_HOT_FUNCTION x() { return 3; }
* int
_
Py_HOT_FUNCTION x() { return 3; }
*
*
* Issue #28618: This attribute must not be abused, otherwise it can have a
* Issue #28618: This attribute must not be abused, otherwise it can have a
* negative effect on performance. Only the functions were Python spend most of
* negative effect on performance. Only the functions were Python spend most of
...
...
Objects/dictobject.c
View file @
c7a8f674
...
@@ -683,7 +683,7 @@ the <dummy> value.
...
@@ -683,7 +683,7 @@ the <dummy> value.
For both, when the key isn't found a DKIX_EMPTY is returned. hashpos returns
For both, when the key isn't found a DKIX_EMPTY is returned. hashpos returns
where the key index should be inserted.
where the key index should be inserted.
*/
*/
static
Py_ssize_t
static
Py_ssize_t
_Py_HOT_FUNCTION
lookdict
(
PyDictObject
*
mp
,
PyObject
*
key
,
lookdict
(
PyDictObject
*
mp
,
PyObject
*
key
,
Py_hash_t
hash
,
PyObject
***
value_addr
,
Py_ssize_t
*
hashpos
)
Py_hash_t
hash
,
PyObject
***
value_addr
,
Py_ssize_t
*
hashpos
)
{
{
...
@@ -798,7 +798,7 @@ top:
...
@@ -798,7 +798,7 @@ top:
}
}
/* Specialized version for string-only keys */
/* Specialized version for string-only keys */
static
Py_ssize_t
static
Py_ssize_t
_Py_HOT_FUNCTION
lookdict_unicode
(
PyDictObject
*
mp
,
PyObject
*
key
,
lookdict_unicode
(
PyDictObject
*
mp
,
PyObject
*
key
,
Py_hash_t
hash
,
PyObject
***
value_addr
,
Py_ssize_t
*
hashpos
)
Py_hash_t
hash
,
PyObject
***
value_addr
,
Py_ssize_t
*
hashpos
)
{
{
...
@@ -873,7 +873,7 @@ lookdict_unicode(PyDictObject *mp, PyObject *key,
...
@@ -873,7 +873,7 @@ lookdict_unicode(PyDictObject *mp, PyObject *key,
/* Faster version of lookdict_unicode when it is known that no <dummy> keys
/* Faster version of lookdict_unicode when it is known that no <dummy> keys
* will be present. */
* will be present. */
static
Py_ssize_t
static
Py_ssize_t
_Py_HOT_FUNCTION
lookdict_unicode_nodummy
(
PyDictObject
*
mp
,
PyObject
*
key
,
lookdict_unicode_nodummy
(
PyDictObject
*
mp
,
PyObject
*
key
,
Py_hash_t
hash
,
PyObject
***
value_addr
,
Py_hash_t
hash
,
PyObject
***
value_addr
,
Py_ssize_t
*
hashpos
)
Py_ssize_t
*
hashpos
)
...
@@ -941,7 +941,7 @@ lookdict_unicode_nodummy(PyDictObject *mp, PyObject *key,
...
@@ -941,7 +941,7 @@ lookdict_unicode_nodummy(PyDictObject *mp, PyObject *key,
* Split tables only contain unicode keys and no dummy keys,
* Split tables only contain unicode keys and no dummy keys,
* so algorithm is the same as lookdict_unicode_nodummy.
* so algorithm is the same as lookdict_unicode_nodummy.
*/
*/
static
Py_ssize_t
static
Py_ssize_t
_Py_HOT_FUNCTION
lookdict_split
(
PyDictObject
*
mp
,
PyObject
*
key
,
lookdict_split
(
PyDictObject
*
mp
,
PyObject
*
key
,
Py_hash_t
hash
,
PyObject
***
value_addr
,
Py_ssize_t
*
hashpos
)
Py_hash_t
hash
,
PyObject
***
value_addr
,
Py_ssize_t
*
hashpos
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment