chep ‘06 david lawrence jlab c++ introspection and object persistency through jil david lawrence...

18
CHEP ‘06 David Lawrence JLab C++ Introspection and Object Persistency through JIL David Lawrence Ph. D. Jefferson Lab, Newport News VA

Upload: lewis-lawrence

Post on 14-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 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

C++ Introspection and Object Persistency through JIL

David Lawrence Ph. D.

Jefferson Lab, Newport News VA

Page 2: 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.

Page 3: 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

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)

Page 4: 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

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.

Page 5: 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

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

Page 6: 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

A Simple Example

Page 7: 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

Use Gnu Debugger (gdb) to mine class/struct structure

Page 8: 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

XML representation of “myClass”

Page 9: 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

(De)Serializer Routines:• Auto-generated code• Convert complex structure into “simple” type problem

Page 10: 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

Page 11: 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

Writing objects to a file

Page 12: 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

Reading objects from a file

Page 13: 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

Serialization time vs. # events

Page 14: 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

Deserialization time vs. # events

Page 15: 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

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

Page 16: 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

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]

Page 17: 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

Extra Slides

Page 18: 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

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.