Lately at work I’ve been doing a performance analysis of a product which has been in development for quite some time. Well, quite some time by ColdFusion standards at least. The particular piece I developed which I’m testing uses the ColdFusion 7 event gateway to essentially fire off threads which each run individual long running processes. As an aside, one thing that I absolutely love about the Event Gateway feature is the ability to control the number of running threads for a given gateway instance, as well as the ability to queue events beyond the number of active threads. This is a very nice feature and keeps me from having to somehow manually manage that which would be quite the conundrum.

Anyhow, during said testing, I’ve uncovered several instances of thread unsafe code which to me is no surprise given the rather large code base this product currently occupies. Surprisingly to me a couple of the instances of thread unsafe code were commonly distributed UDF’s from CFLib from well known people in the CF community. I went to check the UDF’s in question out again on CFLib and they been updated and fixed, so there is no reason for me to really point out anything specific (and I’m not that sort of person anyhow.. I’d contact them in private about it). In reality the versions of UDF’s contained in the code base I’m working with could of been up to a couple of years old. That said, if you have some UDF’s in your code base that you didn’t write yourself, you might want to see if they’ve been updated since adding them in.

This testing process which has uncovered thread unsafe code before actually doing a formal load test analysis has certainly had me thinking though. Using the Event Gateway feature seems like a really good way to perhaps implement automated thread safe unit testing through something such as CFCUnit, without needing to do a full load test to uncover thread unsafe code. For instance this would be especially advantageous if your organization depends on some sort of 3rd party to do load testing; it would be a good idea to take care of any code upfront which was not thread safe. Anyhow, just a fleeting thought really; unfortunately I don’t have the time at the moment to pursue this to see how feasible it is.