the diary of a datum the diary of a datum
Transcript of the diary of a datum the diary of a datum
the diary of a datumthe diary of a datum
((modeling runtime behavior in framework-based applications)modeling runtime behavior in framework-based applications)
Nick Mitchell, Gary Sevitsky, Harini SrinivasanIBM T.J. Watson Research Center
Hawthorne, NY USA
July 7, 2006
the diary of a timecardthe diary of a timecard
parseXML
documentbusinessobject
MQmessage
extractcontent
store inDB2
record
copy (andrepackage)serialize serialized
Java objectDB2blob
DB2record
cost of parsestep:- 2000 calls- 300 objects
● from a deployed server application– extensively uses frameworks (large-scale applications act as integrators)
– this is par for the course for rich clients, too
● that's a lot of work for such a simple task!– what makes this silly is the large number of data transformations
hotspot-free bloathotspot-free bloat
● tuning the easy stuff may remove hot spots– bye bye bubble sort!
● but bloat remains– the runtime complexity and cost of hotspot-free programs is high
parseXML
documentbusinessobject
MQmessage
extractcontent
store inDB2
record
copy (andrepackage)serialize serialized
Java objectDB2blob
DB2record
cost of parsestep:- 2000 calls- 300 objects
the diary of a datum methodologythe diary of a datum methodology
● the analysis scenario– structure activity based on information flow
● code-agnostic classification– label forms of data, and transformations between them, according to the
purpose they serve in the scenario
● behavior signatures– quantify runtime complexity and costs of a scenario in code-agnostic terms
part I: the analysis scenariopart I: the analysis scenario
structuring computation as flows of the physical forms of logical content
information contentinformation content
● various physical representations– binary (MQ message)
– unicode XML (SOAP)
– heap object (Java)
– binary (serialized Java object)
– binary (DB2 blob)
● one a logical collection of information– timecard
● each at the same level of granularity– record (e.g. timecard)
– field (e.g. dates, serial number, manager)
– subfield (e.g. month or day of a date)
an example analysis scenarioan example analysis scenario
analysis scenariocode:
logical content:source:
sink:
Trade benchmark v.3.1 (acting as a SOAP client)
stock purchase date (field granularity)
subsequence of a SOAP message (as bytes)
a field in a Java object (used for subsequent HTML rendering)
Copy to another
version of the
business object
Calendar*(Java field)
Date*(Java field)
bytes(SOAP)
Parse, set field
in business object
Cost:- 268 calls- 70 objects
*new objects
the diary of a datethe diary of a date
code:logical content:
source:sink:
Trade benchmark v.3.1 (acting as a SOAP client)
stock purchase date (field granularity)
subsequence of a SOAP message (as bytes)
a field in a Java object (used for subsequent HTML rendering)
analysis scenario
Copy to another
version of the
business object
Calendar*(Java field)
Date*(Java field)
bytes(SOAP)
Parse, set field
in business object
Cost:- 268 calls- 70 objects
*new objects
zooming in on the SOAP parsingzooming in on the SOAP parsing((detail of just the first step of the previous slide)detail of just the first step of the previous slide)
Parse (using SOAP CalendarDeserializer)
parse using Simple-Date-
Format
String* Date*
parse time zone and
millis; reformat without them
Cost:- 11 calls- 6 objects
add in timezone and millis
Dateextract
value from SOAP tag
bytes(SOAP) String*
Cost:- 30 calls- 3 objects
getschema
info
XML andJava types
BeanPropertyDescriptor
Cost:- 10 calls- 0 objects
get de-serializer
Cost:- 51 calls- 5 objects
Deserializer*
buildCalendar
Calendar*+ 11 arrays*+ TimeZone*
set time
Cost:- 7 calls- 1 object
Cost:- 15 calls- 15 objects
Calendar
Cost:- 95 calls- 39 objects
Cost:- 4 calls- 0 objects
ParsePosition*
TimeZone*(constant)
SimpleDateFormat+ Calendar
2 longs(TZ and millis)
Set business object field via reflection
box into array
call invoke()
onsetter
Object[]*
Cost:- 6 calls- 1 object
Calendar
*new objects
zooming in on zooming in on SimpleDateFormat.parseSimpleDateFormat.parse
extract and parse subfield
set field in Calendarint
String x 6 forYY,MM, DD, ...
Calendarcompute
time
create Datefromtime
long Date*
Cost:- 4 calls- 1 object
Cost:- 14 calls- 6 objects
Cost:- 1 calls- 0 objects
Cost:- 0 calls- 1 object
boolean[]**new objects
zooming in on the subfield parsingzooming in on the subfield parsing(called for every month, day, year, ...)(called for every month, day, year, ...)
Parse number using DecimalFormat.parse()
Parse long using DigitList.getLong()
extractdigitsString copy digits toString() parse box intValue()Digit-
ListString-Buffer* String* long Long* int
Cost:- 11 calls- 5 objectsCost:
- 4 calls- 3 objects- 600 instructions
Cost:- 1 call- 0 objects
Parse-Position*
boolean[]*
*new objects
Copy:Bit change:Type change:Id change:Create:
Copy-Type changeId change-
Physical change
Copy-Type changeId changeCreate
--Type changeId changeCreate
CopyBit changeType changeId change-
Copy-Type changeId changeCreate
Copy-Type changeId change-
Phenomenon Structure copy Structure copy Rewrap Convert Box Unbox
Fundamental properties
part II: the purpose ofpart II: the purpose ofobjects and transformationsobjects and transformations
a multi-dimensional labeling of diagrams
transformations as switchestransformations as switches
data data immediatelyimmediately used for... used for...
input data output data
faci
ltat
ors
only and eventuallyonly and eventually used for... used for...
faci
ltat
or
only and eventuallyonly and eventually used for... used for...
faciltator-related activity
faci
ltat
or
the purpose of a datumthe purpose of a datum (a taxonomy)(a taxonomy)
the purpose of a datumthe purpose of a datum (a taxonomy)(a taxonomy)
the forms of theinformation produced
by the analysis scenario
the purpose of a datumthe purpose of a datum (a taxonomy)(a taxonomy)
e.g. SimpleDateFormat,ByteToCharConverter,
XML deserializers
example: classifying data by example: classifying data by immediateimmediate purpose purpose
Parse (using SOAP CalendarDeserializer)
parse using Simple-Date-
Format
String* Date*
parse time zone and
millis; reformat without them
Cost:- 11 calls- 6 objects
add in timezone and millis
Dateextract
value from SOAP tag
bytes(SOAP) String*
Cost:- 30 calls- 3 objects
getschema
info
XML andJava types
BeanPropertyDescriptor
Cost:- 10 calls- 0 objects
get de-serializer
Cost:- 51 calls- 5 objects
Deserializer*
buildCalendar
Calendar*+ 11 arrays*+ TimeZone*
set time
Cost:- 7 calls- 1 object
Cost:- 15 calls- 15 objects
Calendar
Cost:- 95 calls- 39 objects
Cost:- 4 calls- 0 objects
ParsePosition*
TimeZone*(constant)
SimpleDateFormat+ Calendar
2 longs(TZ and millis)
Converter
Converter
Carrier
Cursor
Converter
Carrier
Set business object field via reflection
box into array
call invoke()
onsetter
Object[]*
Cost:- 6 calls- 1 object
Calendar
*new objects
Carrier Carrier Carrier Carrier Carrier Carrier Carrier
Schema
how transformationshow transformationsalter carrier dataalter carrier data
input data output data
how transformationshow transformationsalter carrier dataalter carrier data
● physical changes– copy
– bit change
– type change
– id change
– new object created
● logical changes– instance
– value
– granularity
how transformationshow transformationsalter carrier dataalter carrier data
● physical changes– copy
– bit change
– type change
– id change
– new object created
● logical changes– instance
– value
– granularity
StringBuffer String
how transformationshow transformationsalter carrier dataalter carrier data
● physical changes– copy
– bit change
– type change
– id change
– new object created
● logical changes– instance
– value
– granularity
StringBuffer String
an instance ofan instance ofa a rewraprewrap idiom idiom
of physical changeof physical change
how transformationshow transformationsalter carrier dataalter carrier data
● physical changes– copy
– bit change
– type change
– id change
– new object created
● logical changes– instance
– value
– granularity
StringBuffer String
an instance of anan instance of aninformation-preservinginformation-preservingidiom of logical changeidiom of logical change
how transformationshow transformationsalter carrier dataalter carrier data
● physical changes– copy
– bit change
– type change
– id change
– new object created
● logical changes– instance
– value
– granularity
byte[] char[]
ByteToCharConverter
how transformationshow transformationsalter carrier dataalter carrier data
● physical changes– copy
– bit change
– type change
– id change
– new object created
● logical changes– instance
– value
– granularity
byte[] char[]
ByteToCharConverter
an instance ofan instance ofa a convertconvert idiom idiom
of physical changeof physical change
how transformationshow transformationsalter carrier dataalter carrier data
● physical changes– copy
– bit change
– type change
– id change
– new object created
● logical changes– instance
– value
– granularity
addsales taxprice price
New York sales tax
labeling transformations according labeling transformations according to to physical changephysical change
Parse number using DecimalFormat.parse()
Parse long using DigitList.getLong()
extractdigitsString copy digits toString() parse box intValue()Digit-
ListString-Buffer* String* long Long* int
Cost:- 11 calls- 5 objectsCost:
- 4 calls- 3 objects- 600 instructions
Cost:- 1 call- 0 objects
Parse-Position*
boolean[]*
*new objects
Copy:Bit change:Type change:Id change:Create:
Copy-Type changeId change-
Physical change
Copy-Type changeId changeCreate
--Type changeId changeCreate
CopyBit changeType changeId change-
Copy-Type changeId changeCreate
Copy-Type changeId change-
Phenomenon Structure copy Structure copy Rewrap Convert Box Unbox
Fundamental properties
part III: behavior signaturespart III: behavior signatures
counting transformations by purposeto quantify the complexity and costs
of an analysis scenario
even the simple thingseven the simple thingsare hard to get rightare hard to get right
copiespre-1.4.2 1 2 0 11.4.2 1 2 1 01.5.0 1 1 0 0
JDKversion
bitchanges
informationexchanges
carrierscreated
● three versions of StringBuffer.append(int)
even the simple thingseven the simple thingsare hard to get rightare hard to get right
copiespre-1.4.2 1 2 0 11.4.2 1 2 1 01.5.0 1 1 0 0
JDKversion
bitchanges
informationexchanges
carrierscreated
● three versions of StringBuffer.append(int)
two “behavior signatures” of physical change
even the simple thingseven the simple thingsare hard to get rightare hard to get right
copiespre-1.4.2 1 2 0 11.4.2 1 2 1 01.5.0 1 1 0 0
JDKversion
bitchanges
informationexchanges
carrierscreated
● three versions of StringBuffer.append(int)
one “behavior signature” of logical change
even the simple thingseven the simple thingsare hard to get rightare hard to get right
copiespre-1.4.2 1 2 0 11.4.2 1 2 1 01.5.0 1 1 0 0
JDKversion
bitchanges
informationexchanges
carrierscreated
● three versions of StringBuffer.append(int)
one “behavior signature” of object purpose
benchmark versus applicationbenchmark versus application(analyzed by idioms of physical change)(analyzed by idioms of physical change)
box/unbox rewrap convertbenchmark 0 0 1 1
app1 3 0 0 1app2 0 2 2 4
structurecopy
box/unbox rewrap convertbenchmark 0 0 1 1
app2 4 1 1 5
structurecopy
● analysis scenario: Date field
● analysis scenario: BigDecimal field
a language for discourse about a language for discourse about runtime complexityruntime complexity
● evaluating benchmarks● choosing a framework implementation to use● API design and implementation● identify new compiler optimizations
● inspire adoption of good language constructs– warning: two years later, we'll be back where we started :)