Commit 79e30b0
committed
Improve executor pool: fix GIL contention and set default to 4
- Add MIN_EXECUTORS (2) and increase MAX_EXECUTORS to 32
- Set default executors to 4 (benchmarked sweet spot)
- Fix GIL contention: acquire GIL only when processing actual work,
not while idle waiting for requests. This prevents idle executor
threads from competing with dirty schedulers running Python work
via the context-based API.
Benchmark results (14 dirty CPU schedulers):
- 4 executors: best sync (400k/sec) and concurrent performance
- Context API: stable regardless of executor count (GIL fix verified)1 parent 941e5d4 commit 79e30b0
4 files changed
Lines changed: 28 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
859 | 859 | | |
860 | 860 | | |
861 | 861 | | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
862 | 866 | | |
863 | 867 | | |
864 | 868 | | |
865 | 869 | | |
866 | | - | |
867 | | - | |
868 | | - | |
869 | 870 | | |
870 | 871 | | |
871 | 872 | | |
872 | 873 | | |
873 | 874 | | |
874 | | - | |
875 | | - | |
876 | | - | |
| 875 | + | |
877 | 876 | | |
878 | 877 | | |
879 | 878 | | |
| |||
890 | 889 | | |
891 | 890 | | |
892 | 891 | | |
893 | | - | |
894 | | - | |
895 | 892 | | |
896 | 893 | | |
897 | 894 | | |
| |||
900 | 897 | | |
901 | 898 | | |
902 | 899 | | |
903 | | - | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
904 | 904 | | |
905 | 905 | | |
906 | | - | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
907 | 910 | | |
908 | 911 | | |
909 | 912 | | |
| |||
913 | 916 | | |
914 | 917 | | |
915 | 918 | | |
916 | | - | |
917 | 919 | | |
918 | 920 | | |
919 | 921 | | |
| |||
953 | 955 | | |
954 | 956 | | |
955 | 957 | | |
956 | | - | |
957 | | - | |
| 958 | + | |
| 959 | + | |
958 | 960 | | |
959 | 961 | | |
960 | 962 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
710 | 710 | | |
711 | 711 | | |
712 | 712 | | |
713 | | - | |
| 713 | + | |
714 | 714 | | |
715 | 715 | | |
716 | 716 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1063 | 1063 | | |
1064 | 1064 | | |
1065 | 1065 | | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
1066 | 1072 | | |
1067 | 1073 | | |
1068 | 1074 | | |
1069 | 1075 | | |
1070 | | - | |
| 1076 | + | |
1071 | 1077 | | |
1072 | 1078 | | |
1073 | 1079 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
40 | 44 | | |
41 | | - | |
| 45 | + | |
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
| |||
0 commit comments