What’s New in TrueAsync PHP 0.4.0? Performance, UDP, SSL, and Memory Optimizations

Version 0.4.0 of the TrueAsync PHP library introduces major performance and memory‑management enhancements, adds asynchronous UDP socket support and SSL for socket streams, fixes numerous bugs, and outlines new requirements and breaking API changes for developers.

Open Source Tech Hub
Open Source Tech Hub
Open Source Tech Hub
What’s New in TrueAsync PHP 0.4.0? Performance, UDP, SSL, and Memory Optimizations

v0.4.0 Release Highlights

Version 0.4.0 focuses on performance optimization, memory management, and event‑handling improvements while adding UDP and SSL support and fixing multiple bugs.

Core Performance Improvements

Reduced unnecessary LibUV calls in the scheduler tick, lowering kernel function‑call overhead.

Optimized network_async_accept_incoming to attempt accept() earlier, decreasing latency for incoming connections.

Introduced a dedicated queue for resumed coroutines, which isolates them from the main scheduler queue and improves stability under heavy load.

Replaced expensive EG(exception) checks in the TrueAsync API with a direct bool return value, eliminating the need for exception handling in fast paths.

Event Descriptor Cache

Added the zend_async_poll_proxy_t structure to manage file‑descriptor state more efficiently.

Implemented caching of socket event handlers, preventing costly reconstruction of the EventLoop for each new socket.

Provided poll‑proxy event aggregation with improved lifecycle handling, reducing the number of poll registrations.

Enabled automatic cleanup of waker events during coroutine recovery via the ZEND_ASYNC_WAKER_CLEAN_EVENTS flag.

Memory Allocation Optimizations

Fixed reference‑count logic in the zend_async_event_callback_t structure to prevent memory leaks.

Re‑organized the memory layout of the waker trigger structure, resulting in better cache locality.

Adjusted allocation patterns for asynchronous structures to reduce fragmentation.

Enhanced resource cleanup and lifecycle management across the async subsystem.

New Features

Full asynchronous UDP socket operations are now available through the TrueAsync API, supporting non‑blocking send/receive and multicast.

SSL/TLS support has been added for socket streams, allowing encrypted communication in async contexts.

Bug Fixes

Corrected the iterator logic in awaitXXX functions, ensuring proper progression of awaitable objects.

Resolved process‑wait handling issues on UNIX‑like systems, fixing dead‑lock scenarios.

Fixed compilation errors in curl_async.c that prevented building on some platforms.

Improved iterator state management when multiple coroutines operate concurrently.

Requirements

LibUV >= 1.45.0 (upgrade from 1.44.0 to address a critical timer bug).

PHP 8.5 or newer.

Supported platforms: Linux, macOS, Windows, FreeBSD, etc.

Breaking Changes

TrueAsync API functions now return bool instead of void to improve performance and error signalling.

Waker events are automatically cleaned up when a coroutine is recovered, eliminating stale wake‑ups.

Important Note

For a complete list of technical changes, see the CHANGELOG at https://github.com/true-async/php-async/blob/v0.4.0/CHANGELOG.md.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Memory ManagementPHPAsyncSSLUDP
Open Source Tech Hub
Written by

Open Source Tech Hub

Sharing cutting-edge internet technologies and practical AI resources.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.