Redbeard Creations Redbeard's home on the web

Benchmarking the PHP Classname Resolution Keyword

Posted on in programming

Recently I had need to determine roughly what happened (and how quickly) when you use the ::class class name resolution keyword in PHP. If you don't know, this special use of the class keyword was added to PHP 5.5 to provide an easy means of determining the name of a class. It is frequently recommended for use in dependency injection containers. So, how does it perform? This post attempts to address that. But first, some background.

Quite some time ago, I added a dependency injection container to the legacy project I maintain. Specifically, I set up Aura.Di, although that's not really relavent to what I'm talking about today. What is relevant is how I was specifying classes to the container.

Read the rest »

LVM adds storage just in time

Posted on in sysadmin

I've been using LVM (Logical Volume Manager) on Linux ever since I first heard about it several years ago. I use it fairly mundanely and just use it to be able to resize the multiple partitions I carve out of a single drive on the fly. But that capability has helped at times. Earlier tonight, for instance.

I was restoring from SQL dumps a database that has a fairly big (6G) table with an even bigger index (about 15G). This is a slow process on my home machine (it's been running for nearly five hours now). Somewhere along the way I got a desktop notification saying that the MySQL partition had less than 1G free. I checked and, yep, only 931K. And going down slowly (the index was being rebuilt). What to do?

Well, I intentionally don't use all of my drive when I set up machines. It lets me increase space where I need it, while keeping each type of data relatively separate (MySQL, music, stock images). So, I knew I could increase the size with LVM. Here's how:

$ pydf # A pretty version of df
Filesystem           Size  Used Avail Use%                 Mounted on
. . .
/dev/ixchel/mysql     29G   27G  931M 91.8 [############.] /var/lib/mysql
. . .

$ sudo lvextend -L +20G /dev/ixchel/mysql  # Expand the requisite partition by 20G.

$ sudo resize2fs /dev/ixchel/mysql # Make the FS understand.

$ pydf
Filesystem           Size  Used Avail Use%                 Mounted on
. . .
/dev/ixchel/mysql     49G   32G   14G 66.1 [#########....] /var/lib/mysql
. . .

And done. In just a few (<5) minutes.

Now, most places that talk about lvextend and resize2fs warn that you could lose stuff. But I've been doing live resizes for years and haven't run into any problems (yet). Backups are, of course, important. But doing this live resize saved me from having to re-run the restore.

Making remote connections to MySQL

Posted on in database, programming

I sometimes connect to live or staging databases from my development machine. I do this by tunneling the MySQL connection over SSH. It's useful for viewing or testing against real and current data. It's also useful for cleaning up botched data from time to time.

Since this is a frequent occurrence for me, I usually set up my .ssh/config file so the tunnel is easily made. It looks something like this:

Read the rest »

What this site is missing

Posted on in about

So this site has been up officially for just shy of a month. It has, of course, gotten virtually no traffic of note. I've been hit by the Google bot1 and myself several times, and probably a few other minor things. But that's about it. That's ok, though. This site is more for me to have a place to put down thoughts than a traffic generator ;) But I'm going to fuss over it for quite a while, until I'm completely happy about it. So this page will be a sort of placeholder for what needs to be done still (besides writing meaningful articles).


  1. The site shows up on Google if you search for redbeard php world. YAY! 

php[world] 2015 - 07. Going home

Posted on in phpworld

The return trip from php[world] 2015 was worse than the trip there. During the final keynote I got a message from the airline that my flight (which wasn't supposed to leave until 7:30) was delayed by 40 minutes. That wouldn't be a big deal, but I had a connecting flight that was supposed to leave just 10 minutes after the first flight was now expected to land. I was going to see what I could do about it after lunch.

Read the rest »