]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-110693: Use a Larger Queue for Per-Interpreter Pending Calls (gh-118302)
authorEric Snow <ericsnowcurrently@gmail.com>
Sat, 27 Apr 2024 01:13:44 +0000 (19:13 -0600)
committerGitHub <noreply@github.com>
Sat, 27 Apr 2024 01:13:44 +0000 (19:13 -0600)
This is an improvement over the status quo, reducing the likelihood of completely filling the pending calls queue.  However, the problem won't go away completely unless we move to an unbounded linked list or add a mechanism for waiting until the queue isn't full.

Include/internal/pycore_ceval_state.h
Lib/test/test_capi/test_misc.py

index 1831f58899b7458e0030e658f47786b63c5112e7..11f2a100bf531e6726b0f6a3fdebfbe549573687 100644 (file)
@@ -20,7 +20,7 @@ struct _pending_call {
     int flags;
 };
 
-#define PENDINGCALLSARRAYSIZE 32
+#define PENDINGCALLSARRAYSIZE 300
 
 #define MAXPENDINGCALLS PENDINGCALLSARRAYSIZE
 /* For interpreter-level pending calls, we want to avoid spending too
@@ -31,7 +31,9 @@ struct _pending_call {
 #  define MAXPENDINGCALLSLOOP MAXPENDINGCALLS
 #endif
 
-#define MAXPENDINGCALLS_MAIN PENDINGCALLSARRAYSIZE
+/* We keep the number small to preserve as much compatibility
+   as possible with earlier versions. */
+#define MAXPENDINGCALLS_MAIN 32
 /* For the main thread, we want to make sure all pending calls are
    run at once, for the sake of prompt signal handling.  This is
    unlikely to cause any problems since there should be very few
index 49d1056f05046715334e9336da6d36e8282b4f5c..020e8493e57c0c1cab7e69c53efb4050d5cb2054 100644 (file)
@@ -1570,9 +1570,9 @@ class TestPendingCalls(unittest.TestCase):
             self.assertEqual(added, maxpending)
 
         with self.subTest('not main-only'):
-            # Per-interpreter pending calls has the same low limit
+            # Per-interpreter pending calls has a much higher limit
             # on how many may be pending at a time.
-            maxpending = 32
+            maxpending = 300
 
             l = []
             added = self.pendingcalls_submit(l, 1, main=False)