afluentes - concurrent i/o made easy with lazy evaluation

27
CIn.ufpe.br Afluentes Concurrent I/O Made Easy With Lazy Evaluation Saulo Medeiros de Araujo [email protected]

Upload: saulo-araujo

Post on 04-Jul-2015

87 views

Category:

Software


1 download

TRANSCRIPT

Page 1: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

CIn.ufpe.br

AfluentesConcurrent I/O Made Easy With Lazy Evaluation

Saulo Medeiros de Araujo

[email protected]

Page 2: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

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

Page 3: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

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

Page 4: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

CIn.ufpe.br

Page 5: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

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

Page 6: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

CIn.ufpe.br

Calculating b2-4ac with Synchronous Methods

Page 7: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

CIn.ufpe.br

Page 8: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

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

Page 9: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

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?

Page 10: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

CIn.ufpe.br

Page 11: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

CIn.ufpe.br

The Afluentes Framework Strategy

AsynchronousMethods

SynchronousMethods

Evaluators

Adapters

Adapters

Page 12: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

CIn.ufpe.br

Evaluators

• Evaluators are synchronous methods, therefore, composing them is

easy

• They receive evaluations as parameters

• They produce evaluations as results

Page 13: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

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

Page 14: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

CIn.ufpe.br

Page 15: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

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

Page 16: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

CIn.ufpe.br

The Afluentes Framework Strategy

• The Afluentes framework represents methods, both

synchronous and asynchronous, and callbacks through objects

that implement specific interfaces

Page 17: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

CIn.ufpe.br

Synchronous Functions

Page 18: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

CIn.ufpe.br

Calculating b2-4ac with Synchronous Functions

Page 19: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

CIn.ufpe.br

Asynchronous Functions

Page 20: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

CIn.ufpe.br

Callbacks

Page 21: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

CIn.ufpe.br

Page 22: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

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)

Page 23: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

CIn.ufpe.br

Concurrent I/O Opportunities

Page 24: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

CIn.ufpe.br

Introducing the Afluentes Framework

Page 25: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

CIn.ufpe.br

Evaluation Results

Page 26: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

CIn.ufpe.br

What We Are Cooking

Page 27: Afluentes - Concurrent I/O Made Easy with Lazy Evaluation

CIn.ufpe.br

Thanks!

github.com/afluentes