Day: January 14, 2008

PHP

PHP File IO concurrency issues with Windows

A project that I am currently dealing with at work involves writing a large number of files to disk on Windows via PHP, and then pulling them into a database via a LOAD DATA INFILE call. The problem I am running into is that the file writes are backgrounded by the system while the PHP script keeps trucking along, pushing the PHP system resources through the roof while paging most of the running processes, further slowing down the disk IO. Finally, once the scripts have have started and backgrounded all these file writes, the next script can’t read in the files to load them into the database.

So far I haven’t found any hints on this anywhere yet. If any of my readers know of any file IO tricks for PHP on Windows please let me know! (I’m talking to both of you!)

Edit: It seems the issue was caused by having XDebug running while trying to write the files. I thought I had turned it off, but I hadn’t so it was writing cachegrind files while the scripts were trying to write their files, and well, it wasn’t pretty.

Read More