Monday, 22 June 2020

Tools of the Trade

Before Leonardo da Vinci could create The Mona Lisa, he had to learn to use a paintbrush. As mundane as it seems, there was a day (at least one) when the only things Leonardo could paint wouldn't be worthy of a place on the fridge door.

A paintbrush is pretty simple, essentially a stick with some bristles attached ... I'm a bit dumb about art, but a painter would seem to have it easy in comparison to an auto-mechanic.

I don't know if you've ever looked in an auto-mechanics toolbox, those big red things with lots of drawers ... you maybe got a peek in the top two trays when your were having your oil changed and seen lots and lots of sockets of different sizes and drives, and extension bars, and things that look like they have universal joints in the middle.

The most interesting cavity in an auto-mechanics toolbox is usually the bottom draw and or cupboard. They spent a considerable amount of money filling up their toolbox with tools for every imaginable job, and then they found that there are some jobs that have no tool, or more commonly the official tool is extortionately expensive, so they welded a thing to another thing and chopped it into the right sort of shape to do the job. These tools they made don't only make the impossible possible, they might in some cases save literally hours of work ... absolutely ingenious.

However, what would you think if you took your car to an auto-mechanic to have the tires changed and they started loosening the wheel nuts using a blow torch, and then set about hitting the wheel nuts in the right direction using a chisel and a hammer ?

Let's talk about the tools of our trade ...

This slightly tongue in cheek tweet generated a lot of discussion, and a fair amount of heat.

The most surprising perhaps from well known members of the community:

I thought I would join in the conversation with this:

I thought I was being pretty precise, but it turns out what I wanted to say has more nuance than you can fit into a tweet, and is too complex to follow for a twitter thread.

My Name Is

The very fact that you can use the form "my name is" and have it make sense, means you are a well known professional at the top of your field.

There is no way that these people can't use a debugger.

During your career, you develop what feels like intuition about code ... It isn't intuition, it's informed by the model you have in your head of the languages and components that you use. As precision of the model increases so does your "intuition".

Being able to get through the development of a thing without experiencing the kinds of bugs that should require you to use a debugger is obviously the goal for any professional.

It's not very surprising therefore that you have professionals that say they don't use a debugger.

Don't and can't are very different.

That's Not Very Nice

This came in various forms:

  • You don't deserve a team
  • I wouldn't want to be on your team anyway
  • Oh, so you don't teach ?

Even a junior professional is expected to know how to use the tools of their trade, to some degree ... of course I would help them to use the debugger.

Below a junior, there might be an intern. An intern, that is a member of the team, or hopes to be one day, is welcome to camp out (virtually) next to me, ask me as many questions as they like.

Do What You Like

You must be the people who wouldn't mind having their cars set on fire in the course of having their wheels changed.

If I told you that I have never dumped a variable while writing a script, you would know I was lying.

When you are on your own, working locally on a thing, I don't care if you use alchemy and witchcraft to write your code.

However, once you have committed to a collaborative environment, that is obviously no longer okay.

Am I going to let you commit debugging statements to a staging server while you try to figure something out !? Obviously and clearly not, I wouldn't be doing my job if I did. 

If you don't have your development environment setup to debug the collaborative environment, or the requisite knowledge to do so, knowing that this is a thing you might have to do, you would seem unprepared to do your job properly.

Teams tend to develop a DSL for talking about bugs, they communicate with screenshots and internal references, line numbers and variable names and such.

This is a waste of time, there exists a very precise DSL for talking and communicating about bugs, and it belongs to your debugger.

We don't only collaborate on our successes, we sometimes need other members of the team to see exactly what we see. The fastest way to communicate and find your way out of these situations is using the tools of your trade.

Our Tools

On a scale of complexity from painter (my dumb idea of a painter) to mechanic, I guess we are somewhere in the middle, maybe a little closer to the mechanic.

I don't dispute that there is more complexity involved in setting up a collaborative debugging environment, than there is in a var dump ... because I'm not crazy, or being mean, or provocative just because we're on the internet.

Investing the time in learning how to use the tools of your trade properly, in discussing as a team how you will handle those situations where collaborative debugging is going to be required is just good sense.

Maybe, as a team, you will never need several of your skill sets to solve a bug, but you should definitely prepare for that eventuality.

Maybe, as an individual member of the team, you will never need a debugger locally, but you too should prepare for that eventuality.

Peace out phomies ...

Wednesday, 23 October 2019

PHP: Past and Future

We can all think of somebody who upon saying the wrong thing, maybe only once, has irreversibly ruined their reputation, possibly even after having apologised for whatever they said. Maybe it's a television presenter, or journalist of another kind, maybe it's not someone in the mainstream media but a tech-celebrity or social influence of some kind.

When an adult, especially in the public eye, says or does the wrong thing and suffers severe consequences as a result, we can all reason that adults are or should be in control of what they are saying and doing, and at bottom they deserve some consequences, though we may quibble about the severity.

When an immature mind says or does the wrong thing, nobody seeks retribution or wills punishment in the same way, whether the mind is your kin or not.

Next year, PHP will be celebrating 25 years of innovation on the web. The releases that are coming in 2020 bear no resemblance to the thing that was released all those years ago. PHP is finally a "grown up language", able to just-in-time compile user code and execute it directly on the CPU. It has a reasonably coherent object model and type system, it's the most exciting release of PHP since inception.

In the modern PHP world, when we talk about PHP, the vast majority of people can think back only as far as PHP 5, they consider PHP 5 and 7 to be the entire history of PHP, and or simply don't care about versions before it.

In the rest of the programming community, the reputation PHP has was not forged by PHP 5 or 7, versions which have seen huge improvements to almost every area of PHP, and its ecosystem, but is largely informed by PHP 4, when the web was really booming.

So today, for giggles, let's compare one aspect of PHP 4 and the upcoming PHP 8 ...

Set aside all the other improvements in the language, ecosystem, and processes used to develop the language and just focus on performance - money in other words ...

For this make-a-sort-of-point-but-otherwise-totally-useless test, I've run the Zend/bench.php script from the 7.2 branch, since it's the last version of the script that can run unmodified by the last release of PHP 4 - which is 4.4.9, released August 2008.


This is a disable all production build, with no additional extensions loaded:

The total execution time is 6.069 seconds.


This is a disable all production build, and contains a run with no extensions first (comparable to above), and one with the jit enabled:

Total execution time is 0.383 seconds without JIT and 0.108 seconds with JIT.

PHP 4 was the adolescence of PHP. PHP 5 developed the ecosystem, and PHP 7 developed the runtime and language. In PHP 8 everything comes together in a symphony of speed and impressiveness.

For those of you whose opinions are informed by an adolescent PHP, this should be enough evidence to force you to reconsider. I shouldn't have to expound the benefits of a stable release cycle, more open development process, and thriving ecosystem ... so I won't ...

I'm making this blog post some year before PHP 8 will become generally available, on purpose: I don't expect you to drop what you are doing and rewrite it in PHP, but I would hope that PHP 8 is on the radar for some upcoming project.

Peace out, future phomies ...

Wednesday, 25 September 2019

Flossing Thoroughly

Fig 1. Some Floss

In general, we initially contribute to open source software for selfish reasons: Perhaps we are interested in some code, or we want or need to fix something, or we just want to write something cool. Whatever the motivation, we imagine that we are going to extract more in benefits than it costs us to contribute ... even if the benefits are just internet points.

I haven't said anything surprising ... It seems obvious that people that contribute to open source are getting something out of it.

This, I think, is what makes business feel comfortable in failing to compensate those people that work in the open on software which they depend.

It should be no surprise that contributing can become a burden, which we tend to bear silently.

The Preface

How often do you go into your living room, or garden, or to a field, and just stand there, doing absolutely nothing ?

I never do this, and nor does my wife, as far as I know. I think it's because free time doesn't actually exist ...

We can say for sure that humans require certain things to function at an optimum level. Take away one of these things and this affects our ability to perform, to interact, to function in general.

Maybe you want to say that free time is that time which we spend engaging our hobbies ...

Preventing burn out is extremely important. Some industries have laws preventing employees from working for too many hours at once, in effect regulating how much sleep they must have.

Unfortunately, we have no such direct protections. While it's true that in general most of us should be protected by some kind of employment law (or contractual clauses), it's also true that most of us have heard a manager talk with pride on the subject of being able to push their team to work unreasonable hours in the pursuit of achieving goals which they determined.

Having hobbies is a part of a healthy work ethic that managers should encourage, and workers should be unapologetic for.

Maybe you want to say that free time is that time which we spend with our families or friends ...

We may be responsible for some family members, calling any time we spend with our children free time is nonsense: Parenting doesn't just happen, you actually have to put effort in, and that's what we are doing, all the time.

Time we spend with our significant others or friends is necessary for the maintenance of those relationships. The loss of any one of these relationships can potentially destroy our ability to function, perhaps beyond repair.

Tech is a very unbalanced industry in terms of diversity. I think this makes it all the more important that people that work within the industry have strong influences from outside. Obviously, this doesn't solve the problem in our industry, but it's interesting to ponder what difference it would make if the influence of peer groups were taken away.

Even if you are one of those street performers that take up temporary residence in city centres the world over on weekends to entertain us with juggling and mime, perhaps while (miming) riding a little bike .... maybe it takes you three hours to get ready to do that because you're a perfectionist and makeup is hard ... that's not free time, that's time you need, to be you ...

The Deal

Most human beings that manage to survive to adulthood have to earn a living to support themselves and possible dependants.

As adults we strike a deal with one or many employers, or otherwise establish an income or several income streams. We trade some of our lives for these streams of income so that we have money for makeup, those little white gloves you need to mime stuff (and perhaps little bikes).

All of the rest of our time on earth is not free time in any sense, it belongs to us ... it belongs to our friends, our family.

The Problem

When we start a project, or on our journey of contributing, we are essentially gifting the community with some code, or some work of some kind. We trade some of our life for whatever the perceived benefits of contributing will be.

Maybe we miss a weekend out with our friends, or we miss dinner with the kids for a few days to make that initial contribution ... We accept that because we obviously enjoy what we are doing, and secondarily (for most people) we want to try to provide something useful.

Now, in those cases where a contribution needs maintenance - you publish a component/library/extension/whatever - we obviously know that this means an ongoing commitment is required. The fact of the matter is, our calculation of this ongoing commitment is just another quote or guesstimate that we get wrong, and that can only be expected.

Way before you actually "succeed" - your project becomes popular, or input becomes sought after - maintaining the project, or otherwise continuing to contribute begins to steal time from other activities. The more successful you are, the more incorrect your guesstimate and so the more pronounced the problem.

This is not part of the deal: We are essentially functioning as we would for an employer, but nobody is paying us.

The Solution

It's quite simple: We need to start compensating those people who maintain or otherwise heavily contribute to projects our businesses rely on.

We need to do that because these people are essentially in our employ ... and that's the deal ...

The Conclusion

I hope you look around at your stack and think about how your (employer's) business would continue to function if some open project disappeared, or otherwise stopped being developed.

I hope I have made the position that people who work in the open don't need to be compensated, something between awkward and morally (or socially) untenable, obviously destructive, and self destructive.

I hope you look around your community, and identify those people that deserve to be compensated.

You can compensate me personally via Patreon.

Peace out, phomies ...

Thursday, 12 September 2019

Missing Bits

Fig 1. A tweet I tweeted
It's 1989, I'm 5 years old, my hair is terrible and my shorts are as long as my socks. It's the end of my third day of school, and as I queue to leave the classroom, I notice a boy standing at the doorway holding a large colourful bag. As the queue progresses, gossip fills the air and excitement grows. I get to the front of the queue and am told to put my hand in the bag and grab something. I did so, quickly and rushed, or was pushed out of the door by the queue ... I'm outside, and can hardly believe that I, without having to perform any parlour tricks like tidying my bedroom, have in my possession a free bag of candy.

Getting things for free is really awesome. But, we're not five years old anymore and understand that nothing is really free, least of all candy. Somebody pays for everything; The only questions are who, and how.

The freedom that allows us to give software away for free is one of the most valuable things we have, for those of us that have it.

We can't know when we decide to release some software how popular it will become. We release it in the hope it's useful, and in the hope that any sustenance the project requires beyond that which we are willing (or rather practically able) to provide will, in the long term, be provided organically by the community that uses it.

This ideal typically works: While no money is changing hands, the community is paying, with time and expertise, to push the software forward.

The opposing forces in OSS are the force applied by peers to provide ever greater software on one side, and on the other side the forces applied by having to hold down a full time job combined with the force applied by all or one of your family, friends, and train shop, to spend more time with your family, friends, or toy trains respectively.

For every project that has reached equilibrium and sustains itself ideally, there are hundreds that don't because they can't. Eventually these projects are at risk of being poorly maintained, abandoned, or worst of all are no longer able to provide what they provide today for free.

I'm going to take Xdebug as an example here, but the same is applicable to many open source projects that we all use ...

When Derick released the first version of Xdebug 17 years ago, he started out a provider. While it took a lot of expertise to release the first version, nobody at that time would have called him an expert.

For the first couple of years until 2004, Xdebug was developed in his spare time. In 2004-2009 he worked at eZ Systems and was allowed to work on Xdebug as part of his contract. The time allowed or used was roughly (and from fuzzy memory of a long time ago) 10-20%.

When I asked Derick if during those 5 years, he worked on Xdebug less during his free time, he said no "because there is fuck all to do in Norway". I think this outlook is mostly a result of his cheerful disposition. I've asked a few people that have been allowed to work on OSS as an employee the same question and got the same response - it doesn't tend to reduce the amount of free time you use for OSS.

For the rest and the vast majority of the last 17 years, every patch, fix, improvement, and new version of Xdebug was written, tested, and released when Derick should have been doing normal life things.

At a certain point, and as a result of the entire community asking questions of Derick and demanding solutions and improvements to the problem of debugging PHP software, he transitioned to a domain expert.

It so happens that I personally have some expertise in this area, and so when I say that the number of domain experts in this field can be counted on your fingers, you can believe me: It's not an exaggeration to say that we have in Derick a world class domain expert.

In these circumstances, where the skills and knowledge required to maintain some software simply do not exist in the wider community, and are contained only within the expert (or possibly experts) we have created, equilibrium is obviously not achievable.

Through sheer passage of time and number of users the pressure on Derick, or any OSS project maintainer in a similar position, has increased to almost unmanageable proportions that could not have been forseen.

I've used Xdebug as an example here because I know a bit about the area, and it's possibly the most glaring example in the ecosystem of a project that without funding will struggle to be maintained at a reasonable pace, and can't reasonably be developed or improved. The fact is that many such projects, pillars of the ecosystem which we all rely on to make a living, are in the same position.

I hope, I've said enough words to convince you that making monetary contributions or approaching your employer with a request to make monetary contributions to projects that your income or business relies upon is the right thing to do, and in some cases necessary for the ongoing health of the project.

Identifying maintainers that need help is simple - It's the maintainers that are asking for help ...

Peace out, phomies ...

Thursday, 29 August 2019


Fig 1. Some Bearings
There is a lot of talk about the direction of PHP as a language, there have been discussions on internals and open letters from community bloggers ...

I think, actually, there is rather a lot of confusion in the air, and so I'm seeking to cleanse that air with this post.


A lot of the discussion is based on an assertion made during the P++ discussion that there are two camps of developers, one that prefers the language to retain as much of its dynamic nature as it has today, and another who would like to move away from the historically dynamic nature of PHP towards a more strict language.

This assertion is palpably false, and I have seen almost every internals developer that has been involved in the conversation recently point out this falsehood.

You can tell by looking at the history of RFCs that these factions do not in fact exist, you can tell that in every case, a majority of people voted for features that make PHP more strict (importantly, as an opt-in feature), a majority introduced types, a majority does everything. We move forward together, or not at all.

When you take away the problem of imaginary factions, a lot of the discussions going on seem to have no basis at all, including the P++ discussion itself.


Like many open source projects, PHP internals have a bunch of processes we are supposed to follow for fixing bugs and introducing features into the language.

The rules were written many years ago - arguably for a totally different, pre social coding world - we mostly do a good job of following the rules as they are written.

Recently I pushed through some changes to the rules to make sure that there is always sufficient voting time and majority (2/3) support for a change before it's accepted.

It's important to point out that the rules are not exhaustive, a lot of how we behave is determined by convention. You can argue against this and say that we should try to exhaustively enumerate every possible action a contributor might take and document exactly how they should take it ... it would be a pretty silly argument, but you could make it ...

Recently an RFC was conducted to deprecate and remove short PHP tag syntax, it is unlucky that the contributor that conducted the RFC was new to internals, and that they weren't aware of convention.

Conventionally, when it comes to deprecation and removal of features, we tend to decide if we're going to deprecate something, and removal follows if we accept that the feature needs to be deprecated. Deprecation does not disable a feature, it raises a deprecation notice only.

Unfortunately, without awareness of this convention, the conductor of the RFC created a vote that asked separately if we should deprecate and disable short tags in 7.4 (to which the answer was yes), and if we should remove short tags in a 8.0 (to which the answer was yes).

This result is in part the basis for the faction claim: It looks like there are a bunch of us that would prefer to just remove cruft, and balls to the developer, and a bunch of us that want to take a more gentle path and deprecate things before removal, or not deprecate them at all.

In actual fact, everyone was likely confused about the questions being asked, and the vote should have been stopped before it reached completion the first time round.

What we have here is a failing of our processes and nothing more. I and likely others are considering how we might avoid this very same failure in the future. It seems desirable at this time to introduce a formal deprecation policy, this both achieves the goal of avoiding this very same failure, and can potentially increase confidence when it comes to adopting new versions of PHP.


You can't stand on the ocean shore and grab a cup full of water and conclude that there is nothing more to find in the ocean than there is in the cup.

You can't look at the last two or three discussions and make any conclusions based upon them, and formulating plans based on those conclusions makes absolutely no sense whatsoever.

As already mentioned, you can look at the broad history of PHP as recorded by RFC's and make determinations about where PHP might head in the future, but taking a small sample can't work.


Now, I want to reply to some specific points raised in the open letter to internals ...

Internals have been discussing voting mechanics and what to do with controversial RFCs for months now.
Shouldn't we start looking at how other communities do this? For sure PHP can't be the only open source language out there?
First, for the sake of clarity. You must be careful how you determine something to be controversial. Loud, is not the same as controversial. Attracting a lot of attention from two or three contributors does not make a controversial topic, it makes loud contributors.

Whatever, it's a fact that we've been concerned with our processes and have made some changes - It's somewhere between difficult and impossible to call anything with 2/3 majority support garnered over a period of at least two weeks controversial.

The time and effort it takes to change our processes is considerable, and only becomes a priority when it's obvious that our processes are failing, or have the potential to fail and do damage.

PHP isn't special in this regard, while the details vary, all open source projects roughly work the same. They determine a set of rules for them which everyone has to follow which includes a workflow, everyone tries to follow it, and when it's broken it gets fixed.

the same discussions happen over and over again on a weekly or monthly basis without any progress

I'm sure that you have a sample of data that shows you this, or you surely wouldn't have made this claim. But history disagrees with you, almost all of the big features introduced into PHP in recent years have gone through several iterations before being accepted, for scalar types it was 5 iterations I think. With every iteration, with every "no", progress is being made.

When you open an RFC you are essentially asking "Is solution X the best way to approach problem Y?". The answer yes, is just as valid as the answer no. It just so happens that the RFC should come prepared with solution X, so the answer yes seems like the better and it certainly is the faster route.

people are personally attacking others regularly
I dispute the use of the word regularly, but it occurs to me that my ability to dispute it may be down to my use of spam filters, and my method of subscription.

It's a matter of fact that some people can't seem to behave themselves on the internet, while I'm sure (read: must believe) they are reasonable people in real life. These people make themselves obvious very quickly and prove they have nothing much to say. Like any form of communication you are free to block that which you do not want to hear, you should not be afraid to do that if it increases your own happiness.

It's common now, even among seasoned contributors, to use the very excellent interface to consume internals mailing lists, and I'm not sure if this has a block/silence feature, maybe the owners could be approached about that ...

an insignificant RFC takes months of discussion and requires a re-vote after being accepted

I think I've covered this under Failings ...

 there aren't any good ways to share constructive feedback apart from the big mailing list
 I can't argue that mailing lists are a good way to communicate, but it's what we have.

However, it's not all we have:

  • You can email any contributor you like
  • You can get involved in the conversation on github pull requests
  • You can go to #php.pecl on IRC
  • You can scream out of your office window - may not work as form of communication, but may relieve stress.
Genuinely constructive feedback will be well received no matter the method of delivery, and no matter how much noise the form of communication seems to carry with its signal.

There are several windows on PHP development, and internals is only one ... There is nothing wrong with approaching a smaller group of developers by email, or in IRC, or on Stackoverflow, so that you can further formulate your feedback with the input of other internals developers before sending to internals for mass consumption. Of course it's not obvious, but many of us operate like this. It's perfectly healthy, there are discussions going on all the time, everywhere internals developers gather.

the group of voters doesn't seem to be an accurate representation the actual PHP community

This is regularly mentioned, and I think I'll be the first one to point out that to the extent which that is true, it is the communities fault.

It takes hardly any effort to earn yourself a voice as a voting internals contributor, you don't need to know C, you don't need to spend hours and hours every day working for free, you have to expend hardly any effort.

You surely want voters to have earned a vote, to somehow have a vested interest in the future of PHP. They are the people that have votes, I fail to see the problem.

If you're going to make the argument that not everyone has time to find a way to contribute to PHP, but they still deserve a voice, then you have to consider that if they have no time to contribute to earn the voice, they have no time to contribute to exercise it responsibly.

Voting takes more time than clicking yes or no, participating in one vote, any vote, is going to take more time than it takes to earn the voice.

Having said all that, there are still provisions to give voting powers to representatives from the PHP community (lead framework devs and such) who otherwise do not contribute to internals, and some such voters exist. If you want to say there are not enough such representatives, then I want to ask what more can we do than make the provision ?

If there are representatives in the community who want to engage in internals but don't have a vote, then they need to make this known ... we can only make the provision.

Peace out, phomies :)

Tuesday, 20 August 2019


Regarding contribution to open source projects

The following scenario has been played out countless times, by a large number of [first time] contributors, to a large number of OSS projects:

  • Find OSS project we love
  • Attempt to navigate [source of] project
  • Find this confusing
  • Decide that there needs to be some "cleanup"
  • Start making pull requests to cleanup [the source code]
  • Pull requests are ignored, refused, or argued against
  • Dismay

Most of the time, we quickly get a feel for the kind of pull requests that will be accepted, everybody moves on ...

But I wonder if they move on before putting any effort into explaining why this type of contribution is not always met with jumps for joy ...

I wonder if we can't say some things about all open source projects, that might guide new contributors to making the kind of contributions that have a good chance of being accepted. Perhaps, more importantly, making contributions in such a way that the (new) contributor becomes an asset for the project.


Communicating with a group of people at once, often about complicated technical matters, is not an easy thing, no matter the calibre of the programmer.

The following sections will seek to provide guidance regarding communications with existing contributing members of a project.

Signal to Noise

Contributing members of a project generally have a steady signal to noise ratio, that's to say, on a yearly (or quarterly, whatever) basis, they make about the same amount of noise, as they do contribute to progress. The ratio varies, depending on the contributor, but steadiness makes for normality, so typically we all get used to even the loudest contributors.

New contributors on the other hand, if nothing else than by virtue of the fact that they have more questions to ask than anybody else, tend to have an unsteady signal to noise ratio, and because the entities you are dealing with are human, this simply annoys them.

The people being annoyed, they very well remember being just as annoying as you are being, so don't take it to heart ...

But maybe there are some things you can do as a new contributor to try and keep a steady ratio ...

Mental Metabolism

New contributors are in learning mode, no matter how familiar they are with the subject matter, language, or patterns used in the project.

In learning mode, we tend to ask as many questions as occur to us, and seek answers as quickly as possible.

This tends to result in noisy communications: A thing to consider is that for every communication you might be sending notification to every subscriber to the medium, be it a github repository, mailing list, forum, or whatever.

Unless you are providing a patch for a life support system and lives are in danger, there is absolutely nothing that can't wait 24 hours.

By waiting a day between your communications, you are affording other contributors time to have their say (and possibly answer questions before you have had the opportunity to ask them). You are also providing yourself much more thinking time, possibly increasing the quality of your communication, and certainly reducing noise.

O(1) Communications

New contributions tend to garner responses or input from several sources, and having waited 24 hours since your last communication, you might have a pile of communications to respond to.

You can further reduce noise levels by responding to everybody at once, don't be afraid to tag people, segment, or otherwise format communications to achieve this.

Once you have the response for the day written out, you might try to compress it by finding overlap, you might even try to preempt what will happen next and try to provide answers to the coming questions in advance.

Source of Truth

Healthy projects tend to develop experts that don't necessarily have any involvement in contributing directly to the project: There are many many more Ruby experts than there are Ruby contributors, mutatis mutandis, the same is true for any project you like. These experts tend to be available outside of official channels, sometimes in groups, sometimes even in realtime.

Let opening an issue, pull request, or otherwise sending "official" communications be a last resort. Realise that the project you are dealing with is never the only source of truth, and that by finding other sources you can further and greatly reduce your noise level.

Choosing Battles

Be ready to gracefully walk away from any contribution or idea you had, be ready before you send your first communication to just be wrong.

Begin wrong is fine, that's how we learn ... It's sometimes hard to see that in the moment though, and find ourselves fighting tooth and nail for what we think is correct.

Realise that your first contributions are not likely to be your most important. You're dealing with humans, and if you make a lot of noise at an early stage, your voice will carry less weight later on.

The Pull Request

Whether communication should precede a pull request is sometimes determined by the rules of the project.

If you are making this decision, then consider how well the project deals with and responds to pull requests. 

If there seems to be evidence that the project struggles to deal with pull requests and if there is a channel for communications other than the channel opened with the pull request, consider communicating before opening a pull request.

Cost and Value

A pull request must result in a net gain for the project.

There are so many ways to achieve a gain that it would be pointless to try to enumerate them. The most common path to a loss is as a result of miscalculation of cost.

As the author of the pull request, you might want to say that the cost associated is whatever it cost you to write the pull request.

But that's not the only cost associated, here's a better starting place for a list of costs:

  • The time it took you to write the pull request
  • The time it's going to take someone, or some people to review the pull request
  • The time it's going to take someone to merge the pull request
  • The time it's going to take someone, or some people to document your changes
  • The time it's going to cost anyone familiar with whatever you are changing

All of this, before the correctness of the pull request even matters. 

Of course, correctness does matter, as well as the content of the pull request ... In some cases, a pull request will have an ongoing, or ongoing costs associated with it. 

Generally, if that ongoing cost is going to be incurred by humans we call it technical debt.

Generally, if that ongoing cost is going to be incurred by the machines executing the code, we refer to it as implementation complexity, or some other fancy term.

These costs hard to quantify, and there is likely disparity between your method of calculating these costs and the methods of existing contributors.

The value your pull request provides must exceed the sum of these costs (as calculated by existing contributors) to be worthwhile, and you should be utterly confident that it does that before you open the pull request.

Final Words

Don't let anything, including the words herein, deter you from your goal of becoming a contributor. 

Achieving your goal will be your reward ...

Sunday, 28 July 2019

Nailed Lids

Fig 1. A Black Box

When we are developing, we go to great lengths to take measurements and gather insights with every kind of testing under the sun, coverage, reviews and so on. These measurements, insights, and processes give us the confidence to take what we made to production.

Production ... a kind of black box, with the lid nailed shut.

You can take a crow bar and pry open one corner of the lid, and using the torch on your phone illuminate one corner of the box. Common crow bars are the Xdebug profiler and XHprof ... These are all great tools, but they are still only illuminating a tiny part of the box, one process at a time.

A technology gaining popularity in recent years is Application Performance Monitoring. APM solutions, typically by taking a large hammer to the box, can provide valuable insight. The large hammer leaves its mark though.

Note: I can only see the source code of open source APM agents.

All of these solutions have one very major drawback: They undertake their work in the same thread as is supposed to be executing PHP - it doesn't matter how well written the code is, or how low the vendor claims the overhead is. It is a mathematical certainty that using these solutions will have a detrimental impact on the performance of the code they are meant to be profiling and or providing insights about.

Clever APM agents will send data in parallel, nevertheless, the majority of their work is still done in the PHP thread.

All of these solutions do one or both of:

  • override the executor function
  • overwrite functions in function tables

Without going into too much detail: Ordinarily the vm is stackless, that means when the executor function (the vm) is entered and a function is called in the code being executed, the executor is not re-entered. Setting the executor function breaks this behaviour, meaning that recursion can lead to stack overflow.

Overwriting functions used to be the bread and butter of hacky extensions like runkit and uopz, and it used to be simple. With the advent of immutable classes, it's not so simple anymore - the function table of the class you are editing, and functions therein, may reside in opcache's SHM. Changing that memory is considered illegal. The VM aggressively uses caching to avoid hashtable lookups, changing a function that exists in the run time cache of another function will lead to faults if that cache entry is subsequently referenced.

A quick word on XHprof and (some) derivatives ... these use the RDTSC instruction as a timing source, have a quick read of the Wikipedia, this hasn't been a good idea in a very long time. They do indeed set affinity to maximize reliability, nevertheless the fragility of using this is unquestionable, and more modern portable API's exist ... nevertheless, it works, and I don't hear everyone being confused that their profiles don't make sense, so more of a technical gripe than anything.

Note: Tideways no longer uses RDTSC, but does use the modern equivalent.

Of course, you can find safe ways to overwrite functions, and maybe a recursive executor is not so terrible for you ...

Conventional wisdom is that if you want to trace or otherwise observe the runtime of PHP, you have to use the hooks that Zend provides and your knowledge of how the Zend layer works. As a result many extensions do these things, or otherwise have a similar detrimental impact on the performance of code. But, they are generally aimed at development time, not production. Doing these things in one process so that Xdebug can debug (or profile) it, pcov can provide coverage for it, or uopz can let your 100 year old tests run is not so bad, a reasonable price to pay for the value being extracted.

Doing these things to a few processes at a time in production, such that APM solutions have enough of a stream of data to provide valuable insights, might also be reasonable. Similarly an APM agent may be extremely lightweight and perform something more akin to the function of a request logger than that of a profiler, limiting their ability to provide insight but making them suitable for production.


First some words about the differences between our development and production environments ...

Our development and staging environments may well operate at capacity, they may well have no spare cores, and no spare cycles - they have every core pinned at 100% usage or close and no capacity to create more processes.

Our production environments must by definition have the ability to deal with production demand. While every core that is running a PHP process might be pinned at 100% or close, we have spare cores and or idle processes.

Getting the lid off the box ...

Stat is a super modern, high performance provider of profile information for production. It uses parallel uio and an atomic ring buffer to make profile data for a set of PHP processes available in realtime over a unix or TCP socket.

Stat does all its work in parallel to PHP, which overcomes the first major drawback of any existing solution. It has no need to set an executor, or otherwise interfere with the runtime of PHP.

Stat is a work in progress, and it may be a month or more before the first release happens, however, if anyone wants to get started on working on any user interfaces (which I will not be writing), I'd be happy to start collaborating on that immediately.

You can find a bit more information in the readme.

That's all I have to say about that right now ...