Commit c397718
committed
#53: Looking at the completed optimization work, here's a commit description for the changes:
Optimize exception handling in ext/async with fast save/restore operations
This commit replaces standard exception save/restore patterns with optimized
fast variants throughout the ext/async extension to improve performance during
coroutine context switching and async operations.
Changes include:
* scheduler.c: Optimize 7+ exception handling points including:
- TRY_HANDLE_SUSPEND_EXCEPTION macro implementation
- cancel_queued_coroutines() function
- async_scheduler_coroutine_suspend() function
- async_scheduler_dtor() cleanup
* coroutine.c: Optimize save/restore pairs in:
- async_coroutine_finalize()
- finally_handlers_iterator_handler()
* scope.c: Optimize scope completion callback exception handling
* zend_common.c: Optimize zend_exception_merge() function
* exceptions.c: Optimize async_extract_exception() function
The optimization uses direct pointer manipulation instead of repeated EG()
macro access, following the pattern:
zend_object **exception_ptr = &EG(exception);
zend_object **prev_exception_ptr = &EG(prev_exception);
zend_exception_save_fast(exception_ptr, prev_exception_ptr);
// ... code execution ...
zend_exception_restore_fast(exception_ptr, prev_exception_ptr);
This reduces overhead in exception state management during async operations
while maintaining identical exception handling semantics.1 parent e34d7d1 commit c397718
4 files changed
+56
-37
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
500 | 500 | | |
501 | 501 | | |
502 | 502 | | |
| 503 | + | |
| 504 | + | |
503 | 505 | | |
504 | 506 | | |
505 | 507 | | |
| |||
510 | 512 | | |
511 | 513 | | |
512 | 514 | | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
517 | 519 | | |
518 | 520 | | |
519 | | - | |
| 521 | + | |
520 | 522 | | |
521 | 523 | | |
522 | 524 | | |
| |||
545 | 547 | | |
546 | 548 | | |
547 | 549 | | |
548 | | - | |
| 550 | + | |
549 | 551 | | |
550 | 552 | | |
551 | 553 | | |
| |||
569 | 571 | | |
570 | 572 | | |
571 | 573 | | |
572 | | - | |
| 574 | + | |
573 | 575 | | |
574 | 576 | | |
575 | 577 | | |
| |||
611 | 613 | | |
612 | 614 | | |
613 | 615 | | |
614 | | - | |
| 616 | + | |
615 | 617 | | |
616 | 618 | | |
617 | 619 | | |
| |||
983 | 985 | | |
984 | 986 | | |
985 | 987 | | |
| 988 | + | |
| 989 | + | |
986 | 990 | | |
987 | | - | |
988 | | - | |
989 | | - | |
990 | | - | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
991 | 996 | | |
992 | 997 | | |
993 | 998 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
289 | | - | |
290 | | - | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
291 | 293 | | |
292 | 294 | | |
293 | 295 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
588 | 588 | | |
589 | 589 | | |
590 | 590 | | |
591 | | - | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
592 | 595 | | |
593 | 596 | | |
594 | 597 | | |
| |||
614 | 617 | | |
615 | 618 | | |
616 | 619 | | |
617 | | - | |
618 | | - | |
| 620 | + | |
| 621 | + | |
619 | 622 | | |
620 | 623 | | |
621 | 624 | | |
622 | 625 | | |
623 | 626 | | |
624 | 627 | | |
625 | | - | |
| 628 | + | |
626 | 629 | | |
627 | 630 | | |
628 | 631 | | |
| |||
1071 | 1074 | | |
1072 | 1075 | | |
1073 | 1076 | | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
1074 | 1080 | | |
1075 | 1081 | | |
1076 | 1082 | | |
| |||
1122 | 1128 | | |
1123 | 1129 | | |
1124 | 1130 | | |
1125 | | - | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
1126 | 1135 | | |
1127 | 1136 | | |
1128 | 1137 | | |
| |||
1131 | 1140 | | |
1132 | 1141 | | |
1133 | 1142 | | |
1134 | | - | |
1135 | | - | |
| 1143 | + | |
| 1144 | + | |
1136 | 1145 | | |
1137 | 1146 | | |
1138 | 1147 | | |
| |||
1156 | 1165 | | |
1157 | 1166 | | |
1158 | 1167 | | |
1159 | | - | |
| 1168 | + | |
1160 | 1169 | | |
1161 | 1170 | | |
1162 | 1171 | | |
| |||
1165 | 1174 | | |
1166 | 1175 | | |
1167 | 1176 | | |
1168 | | - | |
| 1177 | + | |
1169 | 1178 | | |
1170 | | - | |
| 1179 | + | |
1171 | 1180 | | |
1172 | 1181 | | |
1173 | | - | |
| 1182 | + | |
1174 | 1183 | | |
1175 | 1184 | | |
1176 | 1185 | | |
| |||
1208 | 1217 | | |
1209 | 1218 | | |
1210 | 1219 | | |
1211 | | - | |
| 1220 | + | |
1212 | 1221 | | |
1213 | 1222 | | |
1214 | 1223 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
112 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
113 | 116 | | |
114 | 117 | | |
115 | | - | |
116 | | - | |
| 118 | + | |
| 119 | + | |
117 | 120 | | |
118 | 121 | | |
119 | 122 | | |
120 | | - | |
| 123 | + | |
121 | 124 | | |
122 | 125 | | |
123 | 126 | | |
| |||
127 | 130 | | |
128 | 131 | | |
129 | 132 | | |
130 | | - | |
131 | | - | |
132 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
133 | 136 | | |
134 | | - | |
135 | | - | |
| 137 | + | |
| 138 | + | |
136 | 139 | | |
137 | 140 | | |
138 | 141 | | |
| |||
0 commit comments