mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	gh-131586: Avoid refcount contention in some "special" calls (#131588)
In the free threaded build, the `_PyObject_LookupSpecial()` call can lead to reference count contention on the returned function object becuase it doesn't use stackrefs. Refactor some of the callers to use `_PyObject_MaybeCallSpecialNoArgs`, which uses stackrefs internally. This fixes the scaling bottleneck in the "lookup_special" microbenchmark in `ftscalingbench.py`. However, the are still some uses of `_PyObject_LookupSpecial()` that need to be addressed in future PRs.
This commit is contained in:
		
							parent
							
								
									3d4ac1a2c2
								
							
						
					
					
						commit
						67fbfb42bd
					
				
					 16 changed files with 450 additions and 374 deletions
				
			
		|  | @ -433,6 +433,12 @@ static void | |||
| gc_visit_thread_stacks(PyInterpreterState *interp, struct collection_state *state) | ||||
| { | ||||
|     _Py_FOR_EACH_TSTATE_BEGIN(interp, p) { | ||||
|         _PyCStackRef *c_ref = ((_PyThreadStateImpl *)p)->c_stack_refs; | ||||
|         while (c_ref != NULL) { | ||||
|             gc_visit_stackref(c_ref->ref); | ||||
|             c_ref = c_ref->next; | ||||
|         } | ||||
| 
 | ||||
|         for (_PyInterpreterFrame *f = p->current_frame; f != NULL; f = f->previous) { | ||||
|             if (f->owner >= FRAME_OWNED_BY_INTERPRETER) { | ||||
|                 continue; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Sam Gross
						Sam Gross