CPSC-662 Distributed Computing Java/DSM DSM Case St udy I : J ava/ DSM A Plat f orm f or Het erogeneous Comput ing W. Yu, A. Cox Depar t ment of Comput er Science Rice Univer sit y J uly, 1997 J ava/ DSM: I nt r oduct ion • DSM (as opposed t o, e.g., message passing) allows t o f ocus on algor it hmic issues inst ead t han on managing par t it ioned dat a set s. • J ava RMI = RPC + suppor t f or obj ect ref erences acr oss machines • However : – Pr ogr ammer st ill needs t o manage coher ency of r eplicat ed dat a – Pr ogr ammer st ill needs t o f ine-t une r emot e int er f aces 1
CPSC-662 Distributed Computing Java/DSM J ava/ DSM: Mot ivat ion • Syst ems f or het er ogeneous comput ing envir onment s: – Shared memory abst ract ion : (Agor a, Mer maid) • Mermaid based on I VY DSM syst em; support s C language. • Hardware dif f er ences are exposed t o programmer (padding and ordering of aggregat e st ruct ures) • Mermaid aut omat ically perf orms f ormat conversions bet ween machine, but requires non-st andar d compiler support . – Message passing • MPI , PVM, et c… • PVM: send()/receive() primit ives, and programmer needs t o marshal dat a using pack()/unpack() r out ines. • Lit t le/ no suppor t f or sharing of complex dat a st ruct ures. – RPC/ RMI • Programmer must decide when/ t o whom/ what t o communicat e J ava/ DSM: User I nt erf ace • One J ava VM per host . • J ava VM similar t o J DK J ava VM, except t hat all obj ect s ar e allocat ed in shared memor y r egion. • Thr eads cannot migr at e. • RMI : – Remot e obj ect can only be accessed t hr ough r emot e int er f ace met hods. • J ava/ DSM: – Remot e obj ect s ar e accessed j ust as local obj ect s. – St at ic var iables ar e shar ed by all obj ect s in t he syst em. 2
CPSC-662 Distributed Computing Java/DSM J ava/ DSM: Memory Management • Do not want t o maint ain ent ire obj ect ref erence graph across all machines. • I nst ead, have each machine perf orm garbage collect ion independent ly. • However, need t o be caref ul t hat obj ect s ref erenced only by remot e machines are not premat urely reclaimed. • J ava/ DSM garbage collect or: – Each collect or maint ains an export list , and an import list : – Export list : remot e ref erences t o locally creat ed obj ect s. Maint ained by parsing all out going messages. – I mport list : local ref erences t o remot e obj ect s. Maint ained by parsing incoming messages. • During GC: – Export ed ref erences are t reat ed as root set of ref erences. – I mport ed ref erences t hat are not marked are sent back t o t heir owners. – Owners use ref erence count ing t o decide when a ref erence can be removed f rom t he export list . • Occasionally, synchronized collect ion is needed t o reclaim cyclic st ruct ures. J ava/ DSM: Dat a Conversion • When a dat a it em is passed bet ween machines, dat a conver sion is r equir ed. • Type lookup: Type information – Obj ect s in J DK-1.0.2: handle & body handle body – Add back point er f rom body t o handler. Type information handle body – Require all obj ect s allocat ed f rom t he same page t o be of same size. – Given an address, can ident if y page number, look up size of obj ect s wit hin t he page, f ind beginning of obj ect , and f ollow back point er t o f ind t ype inf ormat ion. • Special pr oblem when a dat a it em cr osses a page boundar y. 3
CPSC-662 Distributed Computing Java/DSM J ava/ DSM: Dat a Conversion page_number = (page_start – first_shared_page) / page_size; object_size = page_info[page_number].size; /* size of objects in this page. */ addr = page_start; while (addr < next_page) { back_pointer_address = addr + back_pointer_offset; back_pointer = (JHandle*)(*(long*) back_pointer_address); class = back_pointer -> class; convert_pointer(back_pointer_address); addr += sizeof(long*); /* locate the start of data. */ for (i = 0; i < class->fields_count; i++) { type_code = class->fields[i].signature; convert(addr, type_code); addr += field_length(type_code); } } J ava/ DSM: Changes t o J VM • The heap is allocat ed using Thr eadMar ks’ shar ed memor y allocat ion r out ine • Classes loaded by t he J VM ar e put in shar ed memor y. The loading is synchr onized. • Dur ing gar bage collect ion, t he GC must r ecognize obj ect s cr eat ed by r emot e machines, mar k t hose r ef er ences locally, and send t he unused r emot e r ef er ences t o t heir owner s af t er t he collect ion. • To suppor t dat a conver sion, we r equir e a mapping f r om an ar bit r ar y addr ess t o t he obj ect ’s handle. The st r aight f or war d solut ion is t o r equir e t hat all obj ect s on a page ar e t he same size, and put a point er t o t he handle at t he beginning of ever y obj ect . • Most of t he changes ar e in t he memor y management module. Rest of J VM is vir t ually unchanged. 4
CPSC-662 Distributed Computing Java/DSM Example Applicat ion: Dist ribut ed Spreadsheet • Dist r ibut ed spr eadsheet based on public domain sc . • Ext ensions f or dist r ibut ed oper at ion: – Def ine r egions of cells. – Assign r ead/ wr it e pr ivileges f or each r egion t o user s. – Lock a r egion t o pr event ot her s f r om wr it ing it . – Check if ot her user s have made changes. – I ncor por at e changes made by ot her user s. • I nt er nal dat a st r uct ur e: – Cells ar e or ganized in a t wo-dimensional ar r ay. – Each cell ent r y cont ains inf or mat ion such as it s t ype, curr ent value, pr int able f or m, and a lock bit . – I f ent r y is expr ession, t his is st or ed in f or m of an E-t r ee (expr ession t r ee) wit h r ef er ences t o ot her cells. Dist r ibut ed Spr eadSheet : Realizat ion • DSM (simple!) – I dent if y r ace condit ions – Add synchr onizat ion • RMI – Cent r al ser ver gives poor per f or mance • Server does not scale well (hot spot ) • I nt erf ace t o remot e obj ect s must be f ine t uned (e.g. must be able t o aggregat e request s t o clust ers of cells) – Replicat ed dat a needs suppor t f or coher ence • Updat e scheme: changes t o t he spreadsheet are act ively propagat ed t o ot hers. Simple, but has much overhead. • I nvalidat e scheme: short invalidat ion messages are sent inst ead of t he changed dat a. Higher perf ormance, but requires complicat ed t imest amp mechanism t o t r ack ordering of event s. 5
CPSC-662 Distributed Computing Java/DSM Problem: Ref erence Marshaling in RMI Version Example: cell A[0] contains expression Pass-by-reference Pass-by-copy 6
Recommend
More recommend