Dynamic Detection of Event Handlers Steven P. Reiss Brown - - PowerPoint PPT Presentation

dynamic detection of event handlers
SMART_READER_LITE
LIVE PREVIEW

Dynamic Detection of Event Handlers Steven P. Reiss Brown - - PowerPoint PPT Presentation

Dynamic Detection of Event Handlers Steven P. Reiss Brown University July 21, 2008 DYMON - Page 1 REACTIONS Server Application Todays complex systems Interactions MSG DBMS Messages CLIENT Replies UI (w/ updates)


slide-1
SLIDE 1

Dynamic Detection of Event Handlers

Steven P. Reiss Brown University

July 21, 2008 DYMON - REACTIONS Page 1

slide-2
SLIDE 2

Server Application

  • Today’s complex systems
  • Interactions
  • Messages
  • Replies
  • UI (w/ updates)
  • Response
  • DB reply
  • Computation
  • Multiple threads

July 21, 2008 DYMON - REACTIONS Page 2

MSG DBMS CLIENT CLIENT CMD SERVER

UI

slide-3
SLIDE 3

What Is Interesting

  • Information per interaction
  • Performance for particular events
  • Inputs, transactions, user actions, …
  • Outputs associated with particular inputs
  • Events that result from other events
  • Protocol model
  • Dependencies between interactions
  • Analysis per interaction
  • How threads are used

7/21/2008 DYMON - REACTIONS Page 3

slide-4
SLIDE 4

What Is Required

  • Understanding event processing
  • How events are processed
  • When events are processed
  • Where events are processed
  • What events are processed
  • What happens when processing events
  • Associating threads with events
  • FIRST STEP:
  • IDENTIFY THE EVENT HANDLERS

7/21/2008 DYMON - REACTIONS Page 4

slide-5
SLIDE 5

What Is An Event Handler

  • “An asynchronous callback subroutine

that handles inputs received in a program” (Wikipedia)

  • Code of the form

LO O P LO O P

E = G et next event E = G et next event Pr ocess event E Pr ocess event E

END END

7/21/2008 DYMON - REACTIONS Page 5

slide-6
SLIDE 6

Complications

  • Code to get event can have many forms:
  • Get next event in a routine
  • Get next event from a queue
  • Get next event by waiting on interrupt/notify
  • Process the read in line (socket read)
  • Check for complete message, loop if not
  • Callback from user interface
  • Callback from asynchronous I/O
  • Observer pattern (publish-subscribe)

7/21/2008 DYMON - REACTIONS Page 6

slide-7
SLIDE 7

Complications

  • Code for event can have many forms
  • Call one routine
  • Call multiple routines
  • Switch to detect event type
  • Then call appropriate routine for event type
  • Parse/decode the message, then call handler
  • Debugging/logging statements

7/21/2008 DYMON - REACTIONS Page 7

slide-8
SLIDE 8

DYPER/DYMON

  • Dynamic analysis of performance issues
  • Fixed overhead analysis
  • Works with multiple dimensions
  • CPU, Memory, I/O, Heap, Threads, Sockets, …
  • Each represented by a proflet
  • Proflets have two components
  • One collects data
  • Based on stack samples
  • Based on scheduled detailed analysis
  • One analyzes and reports the result

7/21/2008 DYMON - REACTIONS Page 8

slide-9
SLIDE 9

Basic Architecture

July 21, 2008 DYMON - REACTIONS Page 9

DYPATCH Program DYMTI DYPER

Proflet Proflet

MSG

DYMON

Proflet Proflet

DYVISION DYMON WebUI

slide-10
SLIDE 10

Reaction Proflet

  • Find event handlers
  • Accumulate performance data per event
  • Components
  • Data collection to find event handlers
  • Based on stack traces
  • Data analysis to identify the handlers
  • Performance analysis based on handlers
  • Counts of time spent in each
  • Detailed analysis by instrumenting the handlers

7/21/2008 DYMON - REACTIONS Page 10

slide-11
SLIDE 11

Data Collection

  • Detect callbacks
  • User routines called from system code
  • Usually (when does it not work?)
  • Consolidating call information
  • Build a trie of calls
  • Accumulated from all threads
  • Leaf is stack base
  • Children are routines called
  • Only do user routines
  • Keep state counts for each node
  • RUN, IO, WAIT

7/21/2008 DYMON - REACTIONS Page 11

slide-12
SLIDE 12

Data Collection Example

<REACTIONS LAST='1216066762950' MONTIME='119488' SAMPLES='3765' TSAMPLES='8017'> <CALLBACK STACK='21' USER='edu.brown.cs.cs032.crawler.crawl.CrawlSwingParser$Callback@handleStartTag' /> <CALLBACK STACK='2' USER='edu.brown.cs.cs032.crawler.crawl.CrawlSwingParser$Callback@handleText' /> <TRIE> <TRIENODE CLASS='edu.brown.cs.cs032.crawler.crawl.CrawlThread' IO='0' METHOD='run' RUN='0' WAIT='0'> <TRIENODE CLASS='edu.brown.cs.cs032.crawler.crawl.CrawlMain' IO='0' METHOD='getNextUrl' RUN='0' WAIT='59753'> <TRIENODE CLASS='edu.brown.cs.cs032.crawler.url.UrlManager' IO='0' METHOD='beginProcessing' RUN='0' WAIT='0'> <TRIENODE CLASS='edu.brown.cs.cs032.crawler.url.UrlManager' IO='1' METHOD='getDirectory' RUN='0' WAIT='0' /> </TRIENODE> </TRIENODE> <TRIENODE CLASS='edu.brown.cs.cs032.crawler.crawl.CrawlThread' IO='0' METHOD='processUrl' RUN='0' WAIT='0'> <TRIENODE CLASS='edu.brown.cs.cs032.crawler.url.UrlHandle' IO='449' METHOD='saveHeader' RUN='0' WAIT='0' /> <TRIENODE CLASS='edu.brown.cs.cs032.crawler.url.UrlHandle' IO='0' METHOD='saveHtml' RUN='1' WAIT='0' /> <TRIENODE CLASS='edu.brown.cs.cs032.crawler.crawl.CrawlParser' IO='0' METHOD='parse' RUN='0' WAIT='0'> <TRIENODE CLASS='edu.brown.cs.cs032.crawler.crawl.CrawlSwingParser' IO='21' METHOD='localParse' RUN='10' WAIT='0' /> </TRIENODE> <TRIENODE CLASS='edu.brown.cs.cs032.crawler.url.UrlHandle' IO='1' METHOD='endProcessing' RUN='1' WAIT='0' /> <TRIENODE CLASS='edu.brown.cs.cs032.crawler.crawl.CrawlThread' IO='2' METHOD='readContents' RUN='1' WAIT='0' /> </TRIENODE> </TRIENODE> <TRIENODE CLASS='edu.brown.cs.cs032.crawler.crawl.CrawlMain' IO='0' METHOD='main' RUN='0' WAIT='0'> <TRIENODE CLASS='edu.brown.cs.cs032.crawler.crawl.CrawlMain' IO='0' METHOD='process' RUN='0' WAIT='0'> <TRIENODE CLASS='edu.brown.cs.cs032.crawler.crawl.CrawlMain' IO='0' METHOD='loadUrls' RUN='0' WAIT='0'> <TRIENODE CLASS='edu.brown.cs.cs032.crawler.url.UrlManager' IO='3763' METHOD='normalizeNewUrl' RUN='2' WAIT='0' /> </TRIENODE> </TRIENODE> </TRIENODE> </TRIE> </REACTIONS>

7/21/2008 DYMON - REACTIONS Page 12

slide-13
SLIDE 13

Data Analysis

  • Handle callbacks
  • Look for Patterns in the trie
  • Ensure significance based on counts
  • Both relative and absolute
  • Cutoffs determined experimentally

7/21/2008 DYMON - REACTIONS Page 13

WAIT RUN WAIT RUN IO RUN IO RUN

slide-14
SLIDE 14

Results Example

<REACTI O N TO TTI M E=' 493. 81' <REACTI O N TO TTI M E=' 493. 81' TO TSAM P=' 39489' > TO TSAM P=' 39489' > <CALLBACK M ETHO D=' edu. br own. c <CALLBACK M ETHO D=' edu. br own. cs. cs

  • s. cs032.
  • 032. cr aw

cr awl er . l er . cr aw cr awl . Cr l . Cr awl S awl Swi ng wi ngPar s Par ser $C er $Cal l b al l back@ ack@ hand handl eEn l eEndTag dTag' ' / > / > <CALLBACK M ETHO D=' edu. br own. c <CALLBACK M ETHO D=' edu. br own. cs. cs

  • s. cs032.
  • 032. cr aw

cr awl er . l er . cr aw cr awl . Cr l . Cr awl S awl Swi ng wi ngPar s Par ser $C er $Cal l b al l back@ ack@ hand handl eSt l eSt ar t T ar t Tag' ag' / > / > <CALLBACK M ETHO D=' edu. br own. c <CALLBACK M ETHO D=' edu. br own. cs. cs

  • s. cs032.
  • 032. cr aw

cr awl er . l er . cr aw cr awl . Cr l . Cr awl S awl Swi ng wi ngPar s Par ser $C er $Cal l b al l back@ ack@ hand handl eEr l eEr r or ' r or ' / > / > <CALLBACK M ETHO D=' edu. br own. c <CALLBACK M ETHO D=' edu. br own. cs. cs

  • s. cs032.
  • 032. cr aw

cr awl er . l er . cr aw cr awl . Cr l . Cr awl S awl Swi ng wi ngPar s Par ser $C er $Cal l b al l back@ ack@ hand handl eTe l eText ' xt ' / > / > <EVENT M ETHO D=' edu. br own. <EVENT M ETHO D=' edu. br own. cs. c

  • cs. cs032
  • s032. cr a

. cr awl er wl er . ur l . ur l . Ur l . Ur l Hand Handl e@ s l e@ saveH aveHt m l ' t m l ' TYPE=' NO DE_I O ' TYPE=' NO DE_I O ' / > / > <EVENT M ETHO D=' edu. br own. <EVENT M ETHO D=' edu. br own. cs. c

  • cs. cs032
  • s032. cr a

. cr awl er wl er . cr a . cr awl . C wl . Cr awl r awl M ai n M ai n@ add @ addRedi Redi r ect r ect Ur l ' Ur l ' TYPE=' NO DE_I O ' TYPE=' NO DE_I O ' / > / > <EVENT <EVENT M ETHO D=' edu. br own. M ETHO D=' edu. br own. cs. c

  • cs. cs032
  • s032. cr a

. cr awl er wl er . ur l . ur l . Ur l . Ur l Hand Handl e@ e l e@ endPr ndPr oces

  • cessi ng

si ng' TYPE=' NO DE_I O ' / > ' TYPE=' NO DE_I O ' / > <EVENT <EVENT M ETHO D=' edu. br own. M ETHO D=' edu. br own. cs. c

  • cs. cs032
  • s032. cr a

. cr awl er wl er . cr a . cr awl . C wl . Cr awl r awl M ai n M ai n@ l oa @ l oadUr l dUr l s' TYPE=' NO DE_W AI T' / > s' TYPE=' NO DE_W AI T' / > <EVENT <EVENT M ETHO D=' edu. br own. M ETHO D=' edu. br own. cs. c

  • cs. cs032
  • s032. cr a

. cr awl er wl er . ur l . ur l . Ur l . Ur l Hand Handl e@

  • l e@
  • penC

penConne

  • nnect i o

ct i on' TYPE=' NO DE_I O ' / > n' TYPE=' NO DE_I O ' / > <EVENT M ETHO D=' edu. br own. <EVENT M ETHO D=' edu. br own. cs. c

  • cs. cs032
  • s032. cr a

. cr awl er wl er . ur l . ur l . Ur l . Ur l Hand Handl e@ s l e@ set Er et Er r or ' r or ' TYPE=' NO DE_I O ' TYPE=' NO DE_I O ' / > / > <EVENT M ETHO D=' edu. br own. <EVENT M ETHO D=' edu. br own. cs. c

  • cs. cs032
  • s032. cr a

. cr awl er wl er . cr a . cr awl . C wl . Cr awl r awl Thr e Thr ead@ r ad@ r eadC eadCont e

  • nt ent s'

nt s' TYPE=' NO DE_I O ' TYPE=' NO DE_I O ' / > / > <EVENT <EVENT M ETHO D=' edu. br own. M ETHO D=' edu. br own. cs. c

  • cs. cs032
  • s032. cr a

. cr awl er wl er . ur l . ur l . Ur l . Ur l Hand Handl e@ s l e@ set Re et Redi r e di r ect Ht ct Ht m l ' TYPE=' NO DE_I O ' / > m l ' TYPE=' NO DE_I O ' / > <EVENT <EVENT M ETHO D=' edu. br own. M ETHO D=' edu. br own. cs. c

  • cs. cs032
  • s032. cr a

. cr awl er wl er . cr a . cr awl . C wl . Cr awl r awl Par s Par ser @ p er @ par se ar se' TYPE=' NO DE_I O ' / > ' TYPE=' NO DE_I O ' / > <EVENT <EVENT M ETHO D=' edu. br own. M ETHO D=' edu. br own. cs. c

  • cs. cs032
  • s032. cr a

. cr awl er wl er . ur l . ur l . Ur l . Ur l Hand Handl e@ s l e@ saveL aveLi nks i nks' TYPE=' NO DE_I O ' / > ' TYPE=' NO DE_I O ' / > </ REACTI O N> </ REACTI O N>

7/21/2008 DYMON - REACTIONS Page 14

slide-15
SLIDE 15

Results

  • Works on a wide variety of applications
  • Peer-to-peer server
  • Particle simulator
  • Web crawler
  • Code search engine
  • Simple test cases
  • Some extra items detected
  • Access$100, uses of reflection
  • Others that are effectively handlers, but not

thought of as such

  • currentTimeMillis()

7/21/2008 DYMON - REACTIONS Page 15

slide-16
SLIDE 16

Applications: DYMON

  • Reaction statistics in DYMON

7/21/2008 DYMON - REACTIONS Page 16

slide-17
SLIDE 17

Other Applications

  • Creating a model of thread behavior
  • Based on what events a thread deals with
  • Based on what each event does
  • Thread states: CPU, WAIT, IO, BLOCK, …
  • Can be used to predict performance
  • Based on # threads, # processors, …
  • Building a model of message processing
  • What messages cause other messages
  • Determining the message protocols

7/21/2008 DYMON - REACTIONS Page 17

slide-18
SLIDE 18

Conclusion

  • Simple dynamic analysis
  • Can identify event handlers
  • Can serve as a basis for event-based analysis
  • Very low overhead
  • The TRIE-counting techniques generalize
  • Building model of thread processing
  • Common understanding of behavior
  • Statistical basis
  • That combines multiple threads or processes
  • IT WORKS

7/21/2008 DYMON - REACTIONS Page 18

slide-19
SLIDE 19

Acknowledgements

  • NSF support: CCR0613162
  • Code is available
  • ftp://ftp.cs.brown.edu/u/spr/wadi.tar.gz
  • Part of the WADI project

DYMON-REACTIONS 19

slide-20
SLIDE 20

July 21, 2008 DYMON - REACTIONS 20

Questions / Comments