-
Couldn't load subscription status.
- Fork 1
#59: TrueAsync API performance optimization: void→bool refactoring #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#59: TrueAsync API performance optimization: void→bool refactoring #63
Conversation
EdmondDantes
commented
Sep 25, 2025
Comprehensive performance optimization of TrueAsync API to eliminate expensive EG(exception) checks in hot execution paths by refactoring function signatures from void to
bool and replacing exception-based error handling with direct return value checks.
Key changes:
- Updated function typedefs: zend_async_event_del_callback_t, zend_async_event_stop_t, zend_async_event_dispose_t (void→bool)
- Refactored zend_async_callbacks_remove to return bool
- Updated all del_callback, stop, and dispose function implementations with proper return values
- Fixed forward declarations compatibility issues
- Optimized all function call sites to use if (!function()) return false; pattern instead of EG(exception) checks
- Applied optimization to ~80 functions across coroutine, scope, curl, and libuv reactor modules
Performance impact:
Replaces expensive exception checks with fast boolean operations in critical async execution paths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a comprehensive performance optimization of the TrueAsync API by refactoring function signatures from void to bool and replacing expensive EG(exception) checks with direct return value checks across ~80 functions.
- Converts event system function typedefs and implementations from void to bool return types
- Refactors scheduler and coroutine functions to return success/failure status directly
- Updates all call sites to use fast boolean checks instead of exception state inspection
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| scope.c | Updates scope event handlers and disposal functions to return bool, optimizes timer event callback handling |
| scheduler.h | Changes scheduler function signatures from void to bool |
| scheduler.c | Implements bool return values for scheduler launch, suspend, and enqueue functions |
| libuv_reactor.c | Converts all libuv event handlers (poll, timer, signal, etc.) to return bool with proper error handling |
| coroutine.h | Updates coroutine function signatures to return bool |
| coroutine.c | Implements bool returns for suspend, resume, cancel, and event system functions |
| async_API.c | Updates spawn and microtask functions with boolean return patterns |
| async.c | Optimizes main async functions to use boolean checks |
| CHANGELOG.md | Documents the performance optimization |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if (!event->del_callback(event, callback)) { | ||
| // Optimized: ignore del_callback failure in callback context | ||
| } |
Copilot
AI
Sep 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Silently ignoring the failure contradicts the purpose of returning boolean status. Consider logging the failure or handling it appropriately, even if it's just a debug trace.