mirror of
https://github.com/python/cpython.git
synced 2025-11-27 05:44:16 +00:00
remove vestigal locking from obmalloc (GH-5805)
obmalloc has (empty) macros for locking in the allocator. These aren't needed in CPython; we rely on the GIL.
This commit is contained in:
parent
acd7163c0a
commit
b18f8bc1a7
1 changed files with 0 additions and 39 deletions
|
|
@ -849,30 +849,6 @@ static int running_on_valgrind = -1;
|
||||||
|
|
||||||
/*==========================================================================*/
|
/*==========================================================================*/
|
||||||
|
|
||||||
/*
|
|
||||||
* Locking
|
|
||||||
*
|
|
||||||
* To reduce lock contention, it would probably be better to refine the
|
|
||||||
* crude function locking with per size class locking. I'm not positive
|
|
||||||
* however, whether it's worth switching to such locking policy because
|
|
||||||
* of the performance penalty it might introduce.
|
|
||||||
*
|
|
||||||
* The following macros describe the simplest (should also be the fastest)
|
|
||||||
* lock object on a particular platform and the init/fini/lock/unlock
|
|
||||||
* operations on it. The locks defined here are not expected to be recursive
|
|
||||||
* because it is assumed that they will always be called in the order:
|
|
||||||
* INIT, [LOCK, UNLOCK]*, FINI.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Python's threads are serialized, so object malloc locking is disabled.
|
|
||||||
*/
|
|
||||||
#define SIMPLELOCK_DECL(lock) /* simple lock declaration */
|
|
||||||
#define SIMPLELOCK_INIT(lock) /* allocate (if needed) and initialize */
|
|
||||||
#define SIMPLELOCK_FINI(lock) /* free/destroy an existing lock */
|
|
||||||
#define SIMPLELOCK_LOCK(lock) /* acquire released lock */
|
|
||||||
#define SIMPLELOCK_UNLOCK(lock) /* release acquired lock */
|
|
||||||
|
|
||||||
/* When you say memory, my mind reasons in terms of (pointers to) blocks */
|
/* When you say memory, my mind reasons in terms of (pointers to) blocks */
|
||||||
typedef uint8_t block;
|
typedef uint8_t block;
|
||||||
|
|
||||||
|
|
@ -944,15 +920,6 @@ struct arena_object {
|
||||||
|
|
||||||
/*==========================================================================*/
|
/*==========================================================================*/
|
||||||
|
|
||||||
/*
|
|
||||||
* This malloc lock
|
|
||||||
*/
|
|
||||||
SIMPLELOCK_DECL(_malloc_lock)
|
|
||||||
#define LOCK() SIMPLELOCK_LOCK(_malloc_lock)
|
|
||||||
#define UNLOCK() SIMPLELOCK_UNLOCK(_malloc_lock)
|
|
||||||
#define LOCK_INIT() SIMPLELOCK_INIT(_malloc_lock)
|
|
||||||
#define LOCK_FINI() SIMPLELOCK_FINI(_malloc_lock)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pool table -- headed, circular, doubly-linked lists of partially used pools.
|
* Pool table -- headed, circular, doubly-linked lists of partially used pools.
|
||||||
|
|
||||||
|
|
@ -1381,7 +1348,6 @@ pymalloc_alloc(void *ctx, void **ptr_p, size_t nbytes)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOCK();
|
|
||||||
/*
|
/*
|
||||||
* Most frequent paths first
|
* Most frequent paths first
|
||||||
*/
|
*/
|
||||||
|
|
@ -1537,13 +1503,11 @@ pymalloc_alloc(void *ctx, void **ptr_p, size_t nbytes)
|
||||||
goto init_pool;
|
goto init_pool;
|
||||||
|
|
||||||
success:
|
success:
|
||||||
UNLOCK();
|
|
||||||
assert(bp != NULL);
|
assert(bp != NULL);
|
||||||
*ptr_p = (void *)bp;
|
*ptr_p = (void *)bp;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
UNLOCK();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1612,8 +1576,6 @@ pymalloc_free(void *ctx, void *p)
|
||||||
}
|
}
|
||||||
/* We allocated this address. */
|
/* We allocated this address. */
|
||||||
|
|
||||||
LOCK();
|
|
||||||
|
|
||||||
/* Link p to the start of the pool's freeblock list. Since
|
/* Link p to the start of the pool's freeblock list. Since
|
||||||
* the pool had at least the p block outstanding, the pool
|
* the pool had at least the p block outstanding, the pool
|
||||||
* wasn't empty (so it's already in a usedpools[] list, or
|
* wasn't empty (so it's already in a usedpools[] list, or
|
||||||
|
|
@ -1798,7 +1760,6 @@ pymalloc_free(void *ctx, void *p)
|
||||||
goto success;
|
goto success;
|
||||||
|
|
||||||
success:
|
success:
|
||||||
UNLOCK();
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue