afluentes - concurrent i/o made easy with lazy evaluation
TRANSCRIPT
CIn.ufpe.br
AfluentesConcurrent I/O Made Easy With Lazy Evaluation
Saulo Medeiros de Araujo
CIn.ufpe.br
A Little Bit About Me
• I have been working in the Brazilian software industry for almost 20
years now
• I cofounded a startup (1999-2004)
• I worked in medium and large sized companies (2004-2006)
• Currently, I am working at the Brazilian Central Bank (2006-Present)
• I have been acting mainly as a software architect for object-oriented
web applications backed by relational databases
• This experience is the starting point of the Afluentes framework
CIn.ufpe.br
Context
• Many systems are I/O intensive
• Several I/O intensive systems exhibit few dependencies among data transfer and processing tasks
• The performance of these systems may be significantly improved by requesting I/O operations concurrently
• This is because these operations will be performed in parallel, if the necessary resources are available
• Despite this huge potential, most systems request I/O operations sequentially
CIn.ufpe.br
CIn.ufpe.br
Context
• Mainstream mechanisms for concurrent I/O make programming harder
• Synchronous I/O primitives with multithreaded programming– Race conditions
– Deadlocks
– Scalability issues
• Asynchronous I/O primitives– Callback hell
– Pyramid of doom
CIn.ufpe.br
Calculating b2-4ac with Synchronous Methods
CIn.ufpe.br
CIn.ufpe.br
Asynchronous Methods and Callbacks Issues
• More lines of code
• The programmer has to manually coordinate the execution of asynchronous methods manually
• Callbacks should be just a mechanism for asynchronous methods deliver their executions results
• In the absence of further programming language support, programmers end up using callbacks to manage communication and synchronization among different execution contexts
• This is how things become nasty
CIn.ufpe.br
Synchronous and Asynchronous Methods
• Synchronous Methods– Deliver their results through return values
– Easily composed
– The runtime system coordinates their executions
– Are sequentially executed
• Asynchronous methods– Deliver their results through callbacks
– Composing them is hard
– The programmer has to manually coordinate their executions
– Are concurrently executed
• Is it possible to combine the advantages of synchronous and asynchronous methods?
CIn.ufpe.br
CIn.ufpe.br
The Afluentes Framework Strategy
AsynchronousMethods
SynchronousMethods
Evaluators
Adapters
Adapters
CIn.ufpe.br
Evaluators
• Evaluators are synchronous methods, therefore, composing them is
easy
• They receive evaluations as parameters
• They produce evaluations as results
CIn.ufpe.br
(Lazy) Evaluations
• Evaluations are objects built by evaluators
• They encapsulate
– A method to be invoked
– The parameters (other evaluations) with witch this method must be invoked
• When executed, an evaluator composition builds an evaluation tree
CIn.ufpe.br
CIn.ufpe.br
Problem in the Paradise
• Methods are not first class citzens in Java
• They cannot be stored in attributes, passed as parameters, etc.
• This is a necessary condition for implementing evaluations
CIn.ufpe.br
The Afluentes Framework Strategy
• The Afluentes framework represents methods, both
synchronous and asynchronous, and callbacks through objects
that implement specific interfaces
CIn.ufpe.br
Synchronous Functions
CIn.ufpe.br
Calculating b2-4ac with Synchronous Functions
CIn.ufpe.br
Asynchronous Functions
CIn.ufpe.br
Callbacks
CIn.ufpe.br
CIn.ufpe.br
Experimental Evaluation
• Java web application that allows its users to exchange messages
– Sort of e-mail
• Persists objects in a relational database (MySQL)
• Interacts with this database through an object-relational mapper
(Hibernate)
CIn.ufpe.br
Concurrent I/O Opportunities
CIn.ufpe.br
Introducing the Afluentes Framework
CIn.ufpe.br
Evaluation Results
CIn.ufpe.br
What We Are Cooking
CIn.ufpe.br
Thanks!
github.com/afluentes