{"id":570,"date":"2009-02-05T04:43:59","date_gmt":"2009-02-05T08:43:59","guid":{"rendered":"http:\/\/cd34.com\/blog\/?p=570"},"modified":"2009-02-05T04:43:59","modified_gmt":"2009-02-05T08:43:59","slug":"concurrent-processing","status":"publish","type":"post","link":"https:\/\/cd34.com\/blog\/programming\/concurrent-processing\/","title":{"rendered":"Concurrent processing"},"content":{"rendered":"<p>It has been a while since I&#8217;ve written parallel processing or concurrent processing code.\u00a0 Threaded programming is something that even the experts that wrote apache and php have problems with, yet, writing this type of code is somewhat enjoyable.<\/p>\n<p>It started a few years ago when I replaced 112k lines of C code and libraries that never quite did what the design document specified.\u00a0 I communicated the idea to the coders, the coders wrote the design document and delivered a product that didn&#8217;t even do what the design document specified.<\/p>\n<p>The code was scrapped and rewritten in perl and comprises about 1200 lines of code not including the CPAN libraries used.\u00a0 The code is faster, more reliable, and is very agnostic to its task.\u00a0 It has more capabilities but leaves more of the work to the tasks that is passes around which allows the code to handle communications and dispatch.<\/p>\n<p>While initial testing was rather thorough based on the bugs and issues encountered during the previous version&#8217;s reign.\u00a0 While we&#8217;ve run into minor glitches with the new code, it is considerably more reliable to the point where it is tasked to do more.\u00a0 While the dispatch method was rewritten, concurrent task collision wasn&#8217;t tested nearly enough.<\/p>\n<p>And therein lies the problem.\u00a0 The previous system accepted a task, opened a connection and waited until the task completed.\u00a0 Collisions couldn&#8217;t occur because each task would open a connection to the remote machine and wait until the task completed.\u00a0 For short tasks, this wasn&#8217;t a real issue.\u00a0 Longer tasks risked the socket timing out.\u00a0 If 15 tasks were sent, 15 connections remained open until the tasks completed.<\/p>\n<p>The replacement system handed off the task but didn&#8217;t wait for the task to complete.\u00a0 The remote machine would handle its packet and return the task results.\u00a0 The issue of multiple tasks being added for the same machine results in a few collisions.\u00a0 Task order isn&#8217;t important, but, sometimes a task is fetched twice or a task is missed and left in queue.\u00a0 A task in queue is redispatched, but, the double fetch issue has been difficult to debug.\u00a0 Put in the slightest amount of debugging code and voila, tasks are dispatched properly under every test that can be thrown at it.\u00a0 Remove the debugging code and the error returns.<\/p>\n<p>While the task is left in the queue for processing and the file locking for the state machine has been double and triple checked, but, I&#8217;m sure once I dig into it, I&#8217;ll find some logic error that leaves a stale lock or incorrectly clears a lock.<\/p>\n<p>I remember I used to love writing code like this, though, I always dreaded debugging it.<\/p>\n<div style=\"float:left;\">\n<div id=\"fb-root\"><\/div>\n<fb:like href=\"https:\/\/cd34.com\/blog\/programming\/concurrent-processing\/\" width=\"250\" send=\"false\" show_faces=\"false\" layout=\"button_count\" action=\"recommend\"><\/fb:like>\n<\/div><div style=\"clear:both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>It has been a while since I&#8217;ve written parallel processing or concurrent processing code.\u00a0 Threaded programming is something that even the experts that wrote apache and php have problems with, yet, writing this type of code is somewhat enjoyable. It started a few years ago when I replaced 112k lines of C code and libraries [&hellip;]<\/p>\n<div style=\"float:left;\">\n<div id=\"fb-root\"><\/div>\n<fb:like href=\"https:\/\/cd34.com\/blog\/programming\/concurrent-processing\/\" width=\"250\" send=\"false\" show_faces=\"false\" layout=\"button_count\" action=\"recommend\"><\/fb:like>\n<\/div><div style=\"clear:both;\"><\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-570","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/posts\/570","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/comments?post=570"}],"version-history":[{"count":2,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/posts\/570\/revisions"}],"predecessor-version":[{"id":572,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/posts\/570\/revisions\/572"}],"wp:attachment":[{"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/media?parent=570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/categories?post=570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/tags?post=570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}