8000 gh-110693: Use a Larger Queue for Per-Interpreter Pending Calls (gh-1… · python/cpython@1d33925 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1d33925

Browse files
gh-110693: Use a Larger Queue for Per-Interpreter Pending Calls (gh-118302)
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.
1 parent 194fd17 commit 1d33925

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Include/internal/pycore_ceval_state.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct _pending_call {
2020
int flags;
2121
};
2222

23-
#define PENDINGCALLSARRAYSIZE 32
23+
#define PENDINGCALLSARRAYSIZE 300
2424

2525
#define MAXPENDINGCALLS PENDINGCALLSARRAYSIZE
2626
/* For interpreter-level pending calls, we want to avoid spending too
@@ -31,7 +31,9 @@ struct _pending_call {
3131
# define MAXPENDINGCALLSLOOP MAXPENDINGCALLS
3232
#endif
3333

34-
#define MAXPENDINGCALLS_MAIN PENDINGCALLSARRAYSIZE
34+
/* We keep the number small to preserve as much compatibility
35+
as possible with earlier versions. */
36+
#define MAXPENDINGCALLS_MAIN 32
3537
/* For the main thread, we want to make sure all pending calls are
3638
run at once, for the sake of prompt signal handling. This is
3739
unlikely to cause any problems since there should be very few

Lib/test/test_capi/test_misc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,9 +1570,9 @@ def test_max_pending(self):
15701570
self.assertEqual(added, maxpending)
15711571

15721572
with self.subTest('not main-only'):
1573-
# Per-interpreter pending calls has the same low limit
1573+
# Per-interpreter pending calls has a much higher limit
15741574
# on how many may be pending at a time.
1575-
maxpending = 32
1575+
maxpending = 300
15761576

15771577
l = []
15781578
added = self.pendingcalls_submit(l, 1, main=False)

0 commit comments

Comments
 (0)
0