chep ‘06 david lawrence jlab c++ introspection and object persistency through jil david lawrence...
TRANSCRIPT
CHEP ‘06 David Lawrence JLab
C++ Introspection and Object Persistency through JIL
David Lawrence Ph. D.
Jefferson Lab, Newport News VA
CHEP ‘06 David Lawrence JLab
Introspection and Object Persistency
• Introspection: Ability for a program to query the structure of its classes from within the program.
• Object Persistency: Writing the data portion of an object to a file so that it can be re-created later by another program.
CHEP ‘06 David Lawrence JLab
Motivation for JIL• CPU intensive analyses need staging (e.g.
track fitting first, then physics analysis later) The GlueX experiment will require this
• Make general use tool that allows 3rd party objects to be made persistent without modification of 3rd party source
• Allow object persistence to be added to legacy file formats (CODA)
• Incorporate object meta-data in persistency framework (DANA factory tags)
CHEP ‘06 David Lawrence JLab
Serializers
Files are 1-dimensional things. In order to write a multi-dimensional “object” into a file, it must be serialized.
A corresponding deserializer must also be written to reconstitute the object later.
CHEP ‘06 David Lawrence JLab
Multiple approaches to creating serializers in the absence of introspection
• C++ parser/interpreter (ROOT)
• Write class definitions in XML format and generate C++ headers
• Hand coded serializers
CHEP ‘06 David Lawrence JLab
A Simple Example
CHEP ‘06 David Lawrence JLab
Use Gnu Debugger (gdb) to mine class/struct structure
CHEP ‘06 David Lawrence JLab
XML representation of “myClass”
CHEP ‘06 David Lawrence JLab
(De)Serializer Routines:• Auto-generated code• Convert complex structure into “simple” type problem
CHEP ‘06 David Lawrence JLab
CHEP ‘06 David Lawrence JLab
Writing objects to a file
CHEP ‘06 David Lawrence JLab
Reading objects from a file
CHEP ‘06 David Lawrence JLab
Serialization time vs. # events
CHEP ‘06 David Lawrence JLab
Deserialization time vs. # events
CHEP ‘06 David Lawrence JLab
Summary
• JIL provides a mechanism to add object persistency through files to C++ projects
• JIL can use either C++ code or XML as the source from which to generate serializer methods
• JIL can be used to make 3rd party objects persistent without modifying the 3rd party source code
CHEP ‘06 David Lawrence JLab
Summary
• JIL (optionally) uses zlib compression which reduces file size by a factor of 3
• JIL is multi-thread enabled (not just thread-safe)
• JIL allows users to implement customized file format
• Alpha development stage. For more info, contact: [email protected]
CHEP ‘06 David Lawrence JLab
Extra Slides
CHEP ‘06 David Lawrence JLab
Surely the object persistency problem has been solved for
C++ many times before.
• Yes. Projects like ROOT, s11n, Poet, ROM, and MSVSC++ add object persistence.
• However, only ROOT is really designed for high volume, efficient, compact usage like in HEP and MENP.