wiring hacker synapses

Upload: mustafa-k-isik

Post on 31-May-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/14/2019 Wiring Hacker Synapses

    1/28

    Wiring Hacker Synapses

    Mustafa K. Isikcodesurgeonblog.com

    Scott Lewiscomposent.com

    Eclipse Communication FrameworkEclipseDay at the GoogleplexJune 24th, 2008Mountain View, CA

  • 8/14/2019 Wiring Hacker Synapses

    2/28

    Who has seen the

    screencast?

  • 8/14/2019 Wiring Hacker Synapses

    3/28

  • 8/14/2019 Wiring Hacker Synapses

    4/28

    Collaborative Coding andTeam Tooling in Eclipse

  • 8/14/2019 Wiring Hacker Synapses

    5/28

    Collaborative Coding

    Real-Time Shared Editing with Cola

    Motivation

    Conceptual Overview

    Challenges

    Solutions

    The Future

  • 8/14/2019 Wiring Hacker Synapses

    6/28

    Motivation

    Enable Pair Programming

    Live Code Review

    Help, Tutor, Mentor

    Tap into Domain/API Knowledge

    Independent of Geographic Restrictions

    Resilient to Location Limitations

  • 8/14/2019 Wiring Hacker Synapses

    7/28

    Make Coding More Social,Effective & Fun

  • 8/14/2019 Wiring Hacker Synapses

    8/28

    Conceptual Overview

    2 Participants working on the samedocument

    text file, java source code, etc.

    On different machines

    changes sent over the network

    Consistent document state

    No unintended changes

  • 8/14/2019 Wiring Hacker Synapses

    9/28

    Conflict Free IdealAnna Zo

    time

    ins(a)

    index a

    ins(a)

    initial consistent doc initial consistent doc

    index a

    ins(a)

    ins(0)

    ins(a)ins(0)

    index 0ins(a)ins(0)

    index 0

  • 8/14/2019 Wiring Hacker Synapses

    10/28

    ReviewAnna Zo

    time

    initial consistent doc initial consistent doc

    Some Editing

    Consistent Documents

    Intention Preserving Changes

  • 8/14/2019 Wiring Hacker Synapses

    11/28

    Review (cont.) No conflicts because

    Anna generates change on common documentstate, sends to Zo

    Zo updates unmodified local doc withincoming change

    Zo generates change on updated document,

    sends to Anna

    Anna updates common doc state with incomingchange

    Strictly Sequential Execution ideal, but unrealistic

  • 8/14/2019 Wiring Hacker Synapses

    12/28

    Challenge Out of Order sending/reception

    time

    ins(a)

    index a

    ins(a)

    ins(0)

    index 0

    ins(a)ins(0)

    Anna

    initial consistent doc

    Zo

    initial consistent doc

    index 0

    ins(0)

    index a

    index 0

    ins(0)

    index a

    ins(a)

  • 8/14/2019 Wiring Hacker Synapses

    13/28

    Solution

    In-order Message sending/reception

    network protocols to the rescue

    build on TCP

    build on application level protocol relyingon TCP, e.g. XMPP

    ECF provides for abstraction fromunderlying protocol, XMPPS, Skype, etc.

  • 8/14/2019 Wiring Hacker Synapses

    14/28

    Challenge

    Text Editor Responsiveness

    Local changes need to be applied

    immediately

    Network Latency

    Messages crossing on the wire

    Immediate application of local changes andNetwork Latency High Probability forConflicts

  • 8/14/2019 Wiring Hacker Synapses

    15/28

    Cross-on-Wire Conflicttime

    ins(a)

    index a

    ins(a)

    Anna Zo

    initial consistent doc initial consistent doc

    ins(0)

    ins(a)ins(0)

    index 0

    index 0

    ins(0)

    ins(0)

    index 0

    ins(a)

    index a

  • 8/14/2019 Wiring Hacker Synapses

    16/28

    Solution

    Resolution mechanism for conflicting,mutually directed changes operationaltransformations

    precondition: locally applied operationand incoming remote operation originatefrom same document state

    postcondition: transformed remoteoperation ready for intention-preservingapplication to local document

  • 8/14/2019 Wiring Hacker Synapses

    17/28

    Operational

    Transformations How to determine origination state/

    compatibility?

    stamp each locally generated operationwith counters

    local operation count

    remote operation count

  • 8/14/2019 Wiring Hacker Synapses

    18/28

    Operational

    Transformations cont. compare counters on incoming remoteoperation & conflicting, already appliedlocal operation

    cola operational transformation

    input: conflicting incoming remote op &

    already applied local op

    output: updated remote op, ready forlocal application, e.g. index update

  • 8/14/2019 Wiring Hacker Synapses

    19/28

    Operational Transformation for Cross-on-Wire Conflict Resolution

    ins(a)

    index a

    ins(a)

    Anna Zo

    initial consistent doc initial consistent doc

    ins(0)

    ins(a)ins(0)

    index 0

    index 0

    ins(0)

    coopt( ) ins(a) ins(0) ins(a+L)

    ins(0)

    index 0 index a + L

    ins(a+L)

    coopt( ) ins(a)ins(0) ins(0)

    updated index!no update necessary!

    time

  • 8/14/2019 Wiring Hacker Synapses

    20/28

    Pseudocode:

    Resolving Cross-On-Wire//assert operation compatibility, i.e. sameorigination state

    Assert.isTrue(

    localOp.sentCount == remoteOp.receivedCount );

    if ( localOp.isIns && remoteOp.isIns ) {if( localOp.index < remoteOp.index){

    //move remoteOp.index right by length oflocalOp

    } else if (localOp.index == remoteOp.index) {

    //notion of docOwner, consistently clarify

    preference} else if (localOp.index > remoteOp.index) {

    //do nothing to remote op, apply withoutmodification

    }

    }

  • 8/14/2019 Wiring Hacker Synapses

    21/28

    Combinatorial

    Ex losion Determine atomic operations, e.g. del, ins

    to be transformed against each other

    The fewer the better

    model compound operations from simple

    ones (e.g. replacement as deletion andinsertion)

  • 8/14/2019 Wiring Hacker Synapses

    22/28

    Combinatorial

    Ex losion cont. |cases| |atomic operations| ^ 2 O(n^2)

    |cases| * |index_checks = 3| still O(n^2) though

    Not runtime problem, but

    implementation complexity

    The fewer atomic operations the better!

  • 8/14/2019 Wiring Hacker Synapses

    23/28

    Divergence by More

    than one O eration Generation of multiple local changes while

    remote operation is traveling

    that is: upon arrival of remote operation,local doc changed by more than locallyapplied operation

    precondition for operationaltransformation not met

  • 8/14/2019 Wiring Hacker Synapses

    24/28

    Divergence by More than One

    Op. (cont.)ins(a)

    ins(a)

    Anna Zo

    initial consistent doc initial consistent doc

    time

    ins(v)

    ins(a) ins(v)

    ins(z)

    ins(z)

    coopt( ? ) ?ins(z)

    ins(a) ins(z)

    coopt( ) ins(a) ins(z) ins(a)

    no update necessary!

    coopt( ) ins(z)ins(v) ins(v)

    no update necessary!

    ins(a) ins(z)ins(v)

  • 8/14/2019 Wiring Hacker Synapses

    25/28

    coopt( ) where y = x + Length of

    ins(x) ins(v)

    ins(v)

    Resolution

    ins(a)

    ins(a)

    Anna Zo

    initial consistent doc initial consistent doc

    time

    ins(v)

    ins(a) ins(v)

    ins(z)

    ins(z)

    ins(a) ins(z)

    coopt( ) ins(a) ins(z) ins(a)

    no update necessary!

    coopt( ) ins(z)ins(v) ins(v)

    no update necessary!

    ins(a) ins(z)ins(v)

    coopt( )

    where x = z + Length of

    ins(z) ins(a)

    ins(a)

    ins(x)

    ins(y)

    ins(a) ins(v) ins(y)

  • 8/14/2019 Wiring Hacker Synapses

    26/28

    Additional Details Manage local queue of unacknowledgedoperations

    add local operations as executed

    remove local operations as implicitlyacknowledged by remote operationsappropriate counter

    virtual update of queued up, appliedlocal ops properties not in this talk

    Helps to introduce notion of state-space

    which is being traversed

    not in this talk

  • 8/14/2019 Wiring Hacker Synapses

    27/28

    The Future More than 2 session participants

    Project Sharing

    API for Cola and its Model for OptimisticConcurrency Control

    Diagrams, anyone?

    Deeper Integration

    Multiple Cursors

    Highlighted Areas

    More on this from Scott ... time left?

  • 8/14/2019 Wiring Hacker Synapses

    28/28

    ResourcesMustafas blog http://codesurgeonblog.com

    Scotts ECF blog http://eclipseecf.blogspot.com/

    ECF Eclipse Wiki http://wiki.eclipse.org/Eclipse_Communication_Framework_Project

    ECF Project Home http://www.eclipse.org/ecf/

    Cola Screencast

    http://www.vimeo.com/1195398

    6000+ views in 6 days