Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: [OT] Software Architecture - Pipe and Filter

by BrowserUk (Patriarch)
on Feb 10, 2016 at 07:46 UTC ( [id://1154810]=note: print w/replies, xml ) Need Help??


in reply to Re^2: [OT] Software Architecture - Pipe and Filter
in thread [OT] Software Architecture - Pipe and Filter

I guess the equivalent Perl5 is to create an iterator and threads and one thread pushes onto the queue and another one takes off the queue? So you have essentially a bucket brigade of threads. Each thread performs a filtering process and passes on to the next filter. So what is the approach to scale this idea so that each filter can be replaced / modified / added / deleted?

Unfortunately, the overhead of Perl's implementation of shared data is such that passing individual pieces of data between threads becomes prohibitively expensive.

This can be mitigated to some extent by batching the individual elements into chunks. This is fairly easy to do using a wrapper class over the Thread::Queue module; or better yet, a custom queue module that avoids locking contention by batching to a non-shared buffer and only locking when a buffer is ready to be exchanged.

Another alternative it to use either pipes or sockets for the transfer of data; both of which do their own batching (buffering), but unless you carefully design the size of the elements to fit those buffers, it can lead to less than optimal transfers because of elements straddling buffer boundaries.

The fastest, most efficient solution is to drop into C for the queue, and bypass Perl's shared memory entirely. Unfortunately, the per thread, memory allocation pool model employed by threaded perl's makes this far more difficult to realise correctly than it should be.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re^3: [OT] Software Architecture - Pipe and Filter

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1154810]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-19 17:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found