Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
PHP-level Performance Optimization with Blackfire
Jun 22, 2018 @ 16:49:40

On the SitePoint PHP blog they've posted a tutorial that continues their series covering the creation of a simple image gallery blog application. In this latest part of the series the author covers the use of the Blackfire.io service for performance testing.

Throughout the past few months, we’ve introduced Blackfire and ways in which it can be used to detect application performance bottlenecks. In this post, we’ll apply it to our freshly started project to try and find the low-points and low-hanging fruit which we can pick to improve our app’s performance.

If you’re using Homestead Improved (and you should be), Blackfire is already installed.

While it’s useful to be introduced to Blackfire before diving into this, applying the steps in this post won’t require any prior knowledge; we’ll start from zero.

The tutorial walks you through some of the basics of Blackfire and what kind of information it will report back. After a small change to the Homestead YAML configuration, they show how to profile the landing page and what the resulting graph looks like. It then goes through the code, finding each of the pain points and refactoring them to improve performance.

tagged: blackfireio series performance optimize tutorial

Link: https://www.sitepoint.com/php-level-performance-optimization-blackfire/

Colin O'Dell:
Optimizing colinodell/json5 with Blackfire
Jan 15, 2018 @ 15:50:37

In a post to his site Colin O'Dell shows how he used the Blackfire.io service to optimize the colinodell/json5 package he created to parse JSON5 in PHP. Blackfire.io is a performance profiling service (from the folks behind Symfony) that shows where the pain points are in your code. They also have a "developer" plan that you can use to try out the service.

Back in November, I released colinodell/json5 - a JSON5 parser for PHP. It's essentially a drop-in replacement for PHP's json_decode() function, but it allows things like comments, trailing commas, and more.

Fast forward to this weekend when I received [a] bug report from a user named Antonio [about slowness in parsing large JSON documents]. Yikes! I always knew that a PHP-based implementation would be slower than PHP's native C implementation, but execution time measured in minutes was completely unacceptable!

So I fired up Blackfire (which I've previously used to optimize league/commonmark) and got to work.

He starts off by getting a baseline to work from, executing the parsing on a custom document he created (not quite as large as in the bug report but still large). After locating a few issues he then started in on the optimizations. The first was an issue with the use of mb_substr, the second was around the remainder of the document to parse and the last an optimization for a regular expression. The post ends with a few other micro-optimizations he also made to the package and a check to use json_decode for faster parsing and only kick in the JSON5 parsing when needed.

tagged: optimize json json5 package blackfireio performance

Link: https://www.colinodell.com/blog/201801/optimizing-colinodelljson5-blackfire

Trivago Tech Blog:
Continuous Performance Monitoring for PHP - The tale of Blackfire at trivago
Oct 30, 2017 @ 16:48:38

On the Trivago Tech blog they've shared some of their experience in continuous performance improvements in PHP applications and how the Blackfire.io service helped them get their best performance.

Our mission is to provide the user with the ideal hotel at the lowest rate. Our backend consists of several services written in different languages. To succeed at this goal we do complex tasks in our main application developed in PHP. While doing this we need to keep the website as fast as possible.

We started to look for some tool that could help us identify performance issues in our code base. We evaluated Blackfire and decided that it was a good fit for our use case.

The article starts by answering the question of "why Blackfire?" and continues on, showing how they integrated it with their workflow. They use the SaltStack tooling to set up servers and configure them so it was just a matter of integrating the Blackfire agent and probe extension via that. They include an overall diagram of how it fits into the architecture and how they worked around the lack of Bitbucket server support. The post finishes with some examples of performance metrics from before and after the optimizations from their results stored in InfluxDB.

tagged: trivago continuous performance monitoring blackfire blackfireio metrics results architecture

Link: http://tech.trivago.com/2017/10/27/continuous-performance-monitoring-for-php---the-tale-of-blackfire-at-trivago/

Blackfire.io Blog:
PHP 7 performance improvements (5 Part Series)
Dec 13, 2016 @ 17:54:21

The Blackfire.io blog has just wrapped up their series of posts covering some of the performance improvements that came along with PHP 7. In each post of the series they get into detail on one area, sharing some brief code samples and screenshots from the service showing the performance different between PHP 7 and PHP 5.

Julien Pauli, PHP contributor and release manager, details what changed between PHP 5 and PHP 7, and how to migrate and make effective use of the language optimizations. All statements are documented with specific examples and Blackfire profiles.

The topics covered are:

While some of the examples are (sort of) Symfony related, they're mostly about generic language level features and include some other considerations to think about when using the feature and the performance impact on your application.

tagged: blackfireio php7 performance improvement series

Link: https://blog.blackfire.io/category/tech

SitePoint PHP Blog:
An in-Depth Walkthrough of Supercharging Apps with Blackfire
Jan 14, 2016 @ 17:30:32

The SitePoint PHP blog has a new tutorial posted by Reza Lavaryan showing you how to "supercharge your applications" with the help of the Blackfire.io profiling service.

With profiling, we can spot the performance bottlenecks in the code and do something about them. There is a variety of profiling tools out there, each taking a different approach. [...] With profiling, we can spot the performance bottlenecks in the code and do something about them. There is a variety of profiling tools out there, each taking a different approach. [...] Blackfire.io is the new generation of web profilers, which takes the automatic instrumentation approach, but without imposing a performance impact on our application.

First he defines some of the basic terms it's helpful to know when profiling and using Blackfire. He then walks you through getting what you'll need set up:

  • a Homestead VM instance with the necessary configuration options
  • a script using Faker to generate and write user data to a local database

He then shows you how to execute the first profiling run and what the results look like in the Blackfire views. He uses these results to make some modifications to the script and re-runs the tests to see what kind of gains it provides. Most of his examples use the web interface for the service but the post ends with a look at using the command line tool and getting back some simple metrics as a result.

tagged: profiling performance evaluate blackfireio service introduction faker

Link: http://www.sitepoint.com/an-in-depth-walkthrough-of-supercharging-apps-with-blackfire/

Colin O'Dell:
Optimizing league/commonmark with Blackfire.io
Jan 06, 2016 @ 18:47:38

Colin O'Dell has a post to his site talking about how he used the Blackfire.io service to optimize league/commonmark, a library that's a part of The PHP League making it easier to work with Markdown content in PHP.

As you may know, I am the author and maintainer of the PHP League's CommonMark Markdown parser. [...] This last goal [of being well-written and super-extensible so that others can add their own functionality] is perhaps the most challenging, especially from a performance perspective. Other popular Markdown parsers are built using single classes with massive regex functions.

He shares some brief benchmarks of parsing the same document with four different parsers, including an older version of CommomMark (coming in last, unfortunately). With the goal of optimization in mind, he tried out the Blackfire.io service to locate the bottlenecks in his library. Based on the results from the tests he found two optimizations that could be made relatively easily: switching from single-character parsing to regex and more correctly replacing newlines with breaks where needed.

tagged: commonmark blackfireio profile phpleague package markdown

Link: http://www.colinodell.com/blog/2015-11/optimizing-league-commonmark-blackfire-io

Lakion Blog:
How we sped up Sylius' Behat suite with Blackfire
Dec 01, 2015 @ 18:08:57

On the Lakion blog there's a recent post sharing how they used the Blackfire.io profiling service to [speed up their application's tests] (Behat)(http://lakion.com/blog/how-did-we-speed-up-sylius-behat-suite-with-blackfire) and find the "pain points" to fix.

Feedback time is one of the most crucial factors during development and the red - green - refactor cycle. In case of Sylius, the full build used to take two and a half hour, including 55 minutes for only PHP 5.6 jobs. Waiting so long for feedback is not an option for a project of this size and with so many active contributors. As much as I am Xdebug fan, I have never really used it for profiling - the snapshots generation was slowing down the profiled script significantly and resulted in monstrous files, which weren't easy to read.

Half a year after I have first heard of blackfire.io I decided to give it a try. It resulted in a series of pull requests that speeds up Sylius test suites 6 times and reduces memory usage to one tenth.

They go through some of the major bottlenecks that the service helped them locate including:

  • an issue with the login process and their role evaluation handling
  • problems with time spent doing router initialization
  • Doctrine performance issues running it without a class metadata cache

For each item they describe what the service was reporting and how they corrected it in the application. Most of the changes were relatively small, fortunately. They also link to the results from before and after the changes so you can see the difference. As their environment is Symfony-based they end the post with some other helpful Symfony tips to getting the most out of your application and enhancing its performance in a few simple ways.

tagged: blackfireio behat test suite performance improvement profiling

Link: http://lakion.com/blog/how-did-we-speed-up-sylius-behat-suite-with-blackfire

Blackfire.io Blog:
How Blackfire leverages Docker
May 01, 2015 @ 15:08:34

The Blackfire.io PHP debugging service (from SensioLabs) has a new post to thier blog today talking about how the service makes use of Docker to build the environments for testing out their users' code.

As you may know, Blackfire was represented at the SymfonyLive conference in Paris. During this event, several people came to us and asked how we use Docker at Blackfire.io. One of our goals is to make profiling straightforward for anyone, and it means that we need to be able to easily test our product on a lot of different platforms. And Docker gives us the ability to spin up new containers in milliseconds.

Moreover, our website relies a lot on different tools, so containers can also help us reach an iso-production development environment. But Docker is only available on Linux and a big part of the Blackfire's team is using MacOS X. So how one using MacOS X can use the best of both worlds?

The post goes on to talk about their use of the boot2docker tool and how they can use it to help with the environment customization most developers want out of their testing. They show how it updates the network settings, works with file sharing, allows for multiple domain names/containers and solutions to some other common issues including no container access, no name resolution and a "bonus" section with a Skydock plugin for custom DNS naming.

tagged: blackfireio docker example common issue boot2docker

Link: http://blog.blackfire.io/how-we-use-docker.html


Trending Topics: