Tag: performance

  • php-community: a faster-moving, community-driven PHP.

    I’ve just submitted to the PHP internals mailing list a new PHP RFC, for a faster-moving, community-driven PHP: https://wiki.php.net/rfc/php-community

    With this proposal, the entire PHP community gets immediate access to experimental features through an official php-community version of PHP, versioned in a rolling manner (i.e. php-community 2026.03.01), and available on php.net along normal PHP releases, similar to rust-nightly.

    Experimental features are offered as special PHP feature extensions built into PHP by default.

    These special feature extensions are versioned with semver and disabled by default, and can be easily enabled with a single PhpFeature::get($name, $version)->enable() call (i.e. automatically invoked by the Composer autoloader).

    Feature extensions cannot be enabled using php.ini, to allow enabling features on webhosts: however, to allow for proper sandboxing and thus webhost adoption, a new universal sandboxing level configuration key is added to php.ini, effectively offering the same protection offered by disable_functions et al, for all feature extensions, without the need to search which specific functions to disable.

    For the first time, official binaries and packages will be provided for all major Linux distros for php-community releases on php.net (and the usual binary builds for Mac OS and Windows will be provided as well).

    This makes it significantly easier to get real feedback on features from the entire PHP community.

    The main objective of this RFC is to allow the community to “preview” future language changes in an easily accessible manner: while there have been improvements lately with PIE, experimental language features distributed using normal extensions are still not easily accessible to the entire PHP community; every extra installation step is a barrier to entry, and often simply cannot be installed at all in the most popular PHP execution environment: shared hosts.

    To view a full description of the API and how it all works, take a look at the RFC: https://wiki.php.net/rfc/php-community


    Side note, I’m now part of the PHP True Async committee!

    I decided to not present the RFC as explicitly linked to True Async, to explicitly prevent an interpretation where it is something that will allow us to “sneak in” True Async into PHP.

    True Async is one of, but not the only nor the main reason why I created this RFC.

    I truly believe that PHP could really benefit from a more agile community RFC process, that can transform it from just a decent and fast language I and so many others love, to an amazing, blazing fast and actually modern and ergonomic language.

    I believe PHP truly deserves this.

    Let your voice be heard, take part in the discussion for a better future for PHP!

    Join in on the discussion using the PHP internals mailing list, or view it in readonly mode using externals.

  • Psalm v7: up to 10x performance!

    Announcing the public beta of Psalm v7!

    Psalm is one of the biggest and most powerful PHP Static analysis tools, featuring exclusive features like security analysis, and Psalm v7 brings huge performance improvements to security analysis, up to 10x thanks to a full refactoring of both the internal representation of taints, and optimization of the graph resolution logic.

    A major new feature was also added: combined analysis!

    Combined analysis, enabled by default in Psalm v7, allows running normal analysis, security analysis and dead code analysis all at the same time, within a single run, greatly reducing overall runtimes!

    Future beta releases will also enable taint analysis by default, given that now it can be run alongside normal analysis.

    Psalm v7 also brings performance improvements to dead code analysis, and fixes for list types.

    Even more performance improvements and new features will be released soon!

  • Official Psalm docker image

    Psalm is one of the biggest and most powerful PHP Static analysis tools, featuring exclusive features like security analysis, and in Psalm 6.9, an official, hyperoptimized Docker image was introduced.

    Psalm’s docker image uses a custom build of PHP built from scratch with a custom deepbind patch and the jemalloc allocator, running Psalm +30% faster on average than normal PHP (+50% faster if comparing to PHP without opcache installed).

    My deepbind patch was also merged into PHP and will be available to all users (even those not using the Docker image) in PHP 8.5!

    To use it right now, on PHP 8.4, simply run:

    docker run -v $PWD:/app --rm -it ghcr.io/danog/psalm:latest /composer/vendor/bin/psalm --no-cache

    Issues due to missing extensions can be fixed by enabling them in psalm.xml and/or requiring them in composer.json, see here for more info.

    Extensions not stubbed by Psalm itself (and thus not available as a psalm config option) may be stubbed using traditional PHP stubs.


    This post is part of a series of posts about Psalm v6’s new features, click here to see all the other posts in the series, and subscribe to the newsletter to always stay up to date on the latest Psalm news and developments!


  • Psalm v6 Deep Dive: Copy-on-Write + dynamic task dispatching

    Psalm is one of the biggest and most powerful PHP Static analysis tools, featuring exclusive features like security analysis.

    Psalm v6 was recently released, and soon after in Psalm 6.1, I implemented a major refactoring of multithreaded mode (automatically enabled on Linux/Mac OS) based on amphp/parallel, which greatly improved analysis speeds!

    But why was it so effective? To understand, one must first understand that in the vast majority of PHP multithreaded analysis tools, jobs are distributed statically between threads on startup, which means that towards the end of the analysis, a lot of workers just sit there doing nothing, just waiting for the other workers processing bigger and heavier files to finish.

    However, the new multithreaded mode now allows Psalm to dynamically distribute jobs to workers immediately, as soon as they finish processing their current task, reducing idle worker time and maximizing CPU usage, thus reducing the overall runtime!

    Implementation wasn’t as easy as just plugging in amphp/parallel, because Psalm relies heavily on the copy-on-write semantics of fork(): indeed, Psalm’s multithreaded mode was quite fast even before the refactoring because it doesn’t have to copy all type information to all workers when spawning them, as when workers are spawned using the fork() syscall, the entire memory is not copied to the forked process.

    Instead, it is copied only when a memory page is modified by the forked process, which means that unless workers start modifying large amounts of type information (which usually happens pretty rarely, as most of that data is immutable after Psalm’s scan phase), most of the memory is not copied, leading to large performance improvements.

    amphp/parallel does not support using fork() to spawn workers out of the box, however I managed to add support using a custom context class (taking care to avoid some edge cases around reused file descriptors, which can cause issues with the event loop).

    The maintainer of amphp was kind enough to begin integration of Psalm’s fork context inside of parallel itself after I pinged him, which means amphp users will soon be able to make use of Psalm’s fork context to improve worker spawning performance with copy-on-write fork() semantics.

    This release also adds an additional check to ensure VM overcommitting (the feature which allows copy-on-write optimizations) is enabled in the OS when running Psalm, by ensuring that the vm.overcommit_memory kernel setting is always set to 1.


    This post is the first of a series of technical deep dives into Psalm v6’s performance improvements, which will be released over the next weeks, click here to see all the other posts in the series, and subscribe to the newsletter to always stay up to date on the latest Psalm news and developments!

×