Storing a Persistent Transactional Object Heap on Flash Memory


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Interoperable: Applets developed with Java Card technology will run on any Java Card technology-enabled smart card, independently of the card vendor and underlying hardware. Secure: Java Card technology relies on the inherent security of the Java programming language to provide a secure execution environment. Designed through an open process, the platform's proven industry deployments and security evaluations ensure that card issuers benefit from the most capable and secure technology available today. Multi-Application-Capable: Java Card technology enables multiple applications to co-exist securely on a single smart card. Dynamic: New applications can be installed securely after a card has been issued, enabling card issuers to respond to their customer's changing needs dynamically. Compatible with Existing Standards: The Java Card API is compatible with international standards for smart cards such as ISO7816, or EMV. Major industry-specific standards such as Global Platform and ETSI refer to it. ------------------------------------------------------ The Java Card Virtual Machine Specification defines the features, services, and behavior that an implementation of the Java Card technology must support. It includes the instruction set of a Java Card Virtual Machine (VM), the supported subset of the Java language, and the file formats used to install applets and libraries into smart cards and other devices that host Java Card technology. The Java Card Runtime Environment Specification defines the necessary behavior of the runtime environment (RE) in any implementation of the Java Card technology, which must include implementations of the Java Card Virtual Machine, the Java Card API classes, and runtime support services such as the selection and deselection of applets. API for the Java Card Platform complements the Java Card Runtime Environment Specification, and describes the application programming interface of the Java Card technology. The API is compatible with formal international standards and industry-specific standards. It contains the class definitions required to support the Java Card VM and the Java Card RE.
  • Storing a Persistent Transactional Object Heap on Flash Memory

    1. 1. Speaker: Jungkuk Kim Storing a Persistent Transactional Object Heap on Flash Memory ACM 2006 Conference on Languages, Compilers, and Tools for Embedded Systems (LCTES ’06) ~o~
    2. 2. Java Card Platform <ul><li>Java Card Technology </li></ul><ul><ul><li>enables smart cards and other devices with very limited memory to run small applications (applets) that employ Java technology </li></ul></ul><ul><ul><li>provides smart card manufacturers with a secure and interoperable execution platform that can store and update multiple applications on a single device </li></ul></ul><ul><ul><li>compatible with existing smart card standards. </li></ul></ul><ul><li>Almost any type of smart card can benefit from java card Technology </li></ul><ul><ul><li>Subscriber Identity Module (SIM) cards , used in cell phones on most wireless networks </li></ul></ul><ul><ul><li>Financial cards supporting both online and offline transactions </li></ul></ul><ul><ul><li>Government and health-care identity cards </li></ul></ul><ul><ul><li>Cards that provide logical access and physical access to enterprise resources </li></ul></ul><ul><ul><li>Smart tickets for mass transit </li></ul></ul><ul><li>EEPROM is widely used today to store Java Card objects </li></ul><ul><ul><li>persistent random-access device </li></ul></ul><ul><ul><li>single byte to be read or written  data structures designed for RAM can be used </li></ul></ul><ul><ul><li>part of EEPROM is used for a commit buffer, which serves as redo or undo log </li></ul></ul>
    3. 3. Contribution <ul><li>T INY S TORE </li></ul><ul><ul><li>to meet the requirement of Java Card implementations that use NOR flash as their persistent storage </li></ul></ul><ul><ul><li>heap sub-system that allows Java Cards to use flash memory efficiently </li></ul></ul><ul><ul><li>persistent, transactional, garbage-collected memory-management system </li></ul></ul><ul><ul><li>the first such system: </li></ul></ul><ul><ul><ul><li>existing java cards use EEPROM which does not require sophisticated heap system </li></ul></ul></ul><ul><ul><ul><li>or emulate EEPROM on flash </li></ul></ul></ul>
    4. 4. Java Card Memory Model <ul><li>In most java platforms (J2ME,J2SE,J2EE), </li></ul><ul><ul><li>Objects : stored in volatile memory </li></ul></ul><ul><ul><li>Persistence : achieved by using files, databases </li></ul></ul><ul><li>In Java Card Platform </li></ul><ul><ul><li>Data structures manipulation </li></ul></ul><ul><ul><ul><li>Java Card Objects : always persistent </li></ul></ul></ul><ul><ul><ul><li>Automatic values (the stack) : always transient </li></ul></ul></ul><ul><ul><ul><li>Arrays : persistent or transient </li></ul></ul></ul><ul><ul><ul><li>fields in new objects : automatically initialized to default value (zero) </li></ul></ul></ul><ul><ul><li>three atomicity models for persistent data </li></ul></ul><ul><ul><ul><li>accesses to data items : atomic and serialized (at least logically) </li></ul></ul></ul><ul><ul><ul><li>explicit transaction </li></ul></ul></ul><ul><ul><ul><ul><li>to group together to a set of operations that are executed atomically </li></ul></ul></ul></ul><ul><ul><ul><ul><li>either completed successfully or rolled back to the prior state </li></ul></ul></ul></ul><ul><ul><ul><ul><li>can abort by explicit API, lack of resources, or system failure </li></ul></ul></ul></ul><ul><ul><ul><ul><li>doesn’t support nested or concurrent transactions </li></ul></ul></ul></ul><ul><ul><ul><li>only used for a filling or copying a section of an array </li></ul></ul></ul><ul><ul><ul><ul><li>atomically ( arraycopy ) / non-atomically ( arrayCopyNonAtomic ) </li></ul></ul></ul></ul><ul><ul><ul><ul><li>optimization opportunity </li></ul></ul></ul></ul><ul><ul><li>Garbage collector included or not </li></ul></ul>
    5. 5. Design Goals <ul><li>Assumption </li></ul><ul><ul><li>H/W characteristics of smart cards and java cards </li></ul></ul><ul><ul><ul><li>a small RAM (1MB flash, 32KB/8KB ram) and slow clock speed </li></ul></ul></ul><ul><ul><li>using Flash devices </li></ul></ul><ul><ul><ul><li>memory mapped for reading  NOR (not for NAND) </li></ul></ul></ul><ul><ul><ul><li>special device driver routine for programming and erasing </li></ul></ul></ul><ul><li>T INY S TORE features and APIs </li></ul><ul><ul><li>to be called by the JVM (java virtual machine) of the Java Card </li></ul></ul><ul><ul><li>API functions </li></ul></ul><ul><ul><ul><li>to create persistent objects and arrays </li></ul></ul></ul><ul><ul><ul><li>allow JVM to explicitly delete objects and arrays if GC not used </li></ul></ul></ul><ul><ul><ul><li>access optimization : supports read-optimized and modify-optimized representation for objects </li></ul></ul></ul><ul><ul><ul><li>atomic explicit transaction support </li></ul></ul></ul><ul><ul><ul><li>automatic mark-sweep garbage collection </li></ul></ul></ul><ul><ul><ul><li>array utilities </li></ul></ul></ul><ul><ul><li>wear-leveling </li></ul></ul><ul><ul><li>physical pointer is more efficient when read frequently </li></ul></ul><ul><ul><li>Implemented in C </li></ul></ul>
    6. 6. Low-level Data Structures <ul><li>same as TFFS (transactional flash file system for NOR) in prior study </li></ul><ul><li>Logical Pointers and structure of erase unit </li></ul><ul><li>Efficient Pruned Versioned Search Trees </li></ul><ul><ul><li>to find objects, arrays, and other data items </li></ul></ul><ul><ul><li>one or two versions of search tree </li></ul></ul><ul><ul><li>(a dictionary data structure w/ ordered keys) </li></ul></ul><ul><ul><li>which formally is a directed acyclic graph w/ one or two roots </li></ul></ul><ul><ul><li>One version  read-only search tree for look-up operation </li></ul></ul><ul><ul><li>The other version  read-write version for new (key-value) pairs to be added, deleted, replaced </li></ul></ul><ul><ul><li>if the read-write version committed, it becomes read-only and older version disappears </li></ul></ul><ul><ul><li>O(log(n+k), where n : size of the read-only dictionary, k : # of modifications on read-write tree </li></ul></ul><ul><li>Log Structure </li></ul><ul><ul><li>log (journal) to perform certain operations atomically </li></ul></ul><ul><ul><li>array of fixed size of records called entries </li></ul></ul><ul><ul><li>fills entire erase unit and doesn’t have logical number </li></ul></ul>HEADER logical erase unit Sector descriptor Sector#0 Sector#1 Sector descriptor Kind of data, # of erase, Error-detection Code, Etc. Objects, Arrays, Headers of objects & arrays, Search-tree nodes logical pointer (erase unit #, sector #)
    7. 7. Java Card Memory Management System <ul><li>T INY S TORE supports </li></ul><ul><ul><li>physical addressing of objects and arrays </li></ul></ul><ul><ul><li>object-optimized field modifications </li></ul></ul><ul><ul><li>array-optimized element modifications </li></ul></ul><ul><ul><li>global operations on array </li></ul></ul><ul><ul><li>garbage collection </li></ul></ul>
    8. 8. <ul><li>JVM names objects and arrays in T INY S TORE ’s API calls using references </li></ul><ul><li>references  unique ID that T INY S TORE generates when objects created </li></ul><ul><li>In versioned search tree, called REF tree </li></ul><ul><ul><li>to map references to the flash addresses of objects/arrays </li></ul></ul><ul><ul><li>Each leaf in the tree maps one reference </li></ul></ul><ul><ul><li>The leaf contains </li></ul></ul><ul><ul><ul><li>the reference itself </li></ul></ul></ul><ul><ul><ul><li>kind </li></ul></ul></ul><ul><ul><ul><li>logical pointer </li></ul></ul></ul><ul><ul><ul><li>some additional data items </li></ul></ul></ul>Mapping References to Flash Address
    9. 9. <ul><li>Sometimes we compact the lists </li></ul><ul><ul><li>if the lists doesn’t have room for a new value for the field and it reached maximal length </li></ul></ul><ul><li> we must compact it. </li></ul><ul><ul><li>when the JVM requests its physical address by calling GetPhysicalPointer </li></ul></ul>On-Flash Representation of Objects GUID Valid Flag Initialization Flag
    10. 10. On-Flash Representation of Arrays <ul><li>Arrays larger than compile-time threshold t (we set 255 which is maximal number of field) </li></ul><ul><ul><li>if the array is larger than one erase unit </li></ul></ul><ul><ul><li>if one or a few elements are modified more frequently than the rest </li></ul></ul><ul><li>section descriptors are the leaves of the pruned versioned tree </li></ul><ul><ul><li>search keys are the sequential section numbers </li></ul></ul><ul><li>array utility functions for bulk operations by TinyStore rather than by JVM </li></ul>list of array records Valid Flag (‘0’ 이면 invalid) Initialization Flag (‘0’ 이면 filed 사용 )
    11. 11. Garbage Collection <ul><li>T INY S TORE </li></ul><ul><ul><li>provides support for GC in RAM-limited systems </li></ul></ul><ul><ul><li>supports a stop-the-world mark-sweep collector </li></ul></ul><ul><ul><li>GC regard the heap as a directed graph </li></ul></ul><ul><ul><ul><li>vertices are objects and arrays </li></ul></ul></ul><ul><ul><ul><li>edges are object references </li></ul></ul></ul><ul><ul><ul><li>to deallocate all the objects and arrays that are not reachable from the roots </li></ul></ul></ul><ul><ul><li>Stack of reference and mark flags are stored in GC unit (single erase unit) </li></ul></ul><ul><ul><li>two in-RAM indices into this array </li></ul></ul><ul><ul><ul><li>Ram index b : points to the first element of the on-flash array </li></ul></ul></ul><ul><ul><ul><li>Ram index n : the first unused location in the on-flash array </li></ul></ul></ul>Stack of reference to know whether already been visited Mark flags indicates reachable or not (sorted order)
    12. 12. Transaction Supports and Atomicity <ul><li>Commit buffer </li></ul><ul><ul><li>conventional way to support atomicity and explicit transactions in Java Cards </li></ul></ul><ul><ul><li>two ways  values are duplicated in the buffer </li></ul></ul><ul><ul><ul><li>undo log  the old values </li></ul></ul></ul><ul><ul><ul><li>redo log  the new values </li></ul></ul></ul><ul><ul><li>appropriate for EEPROM implementations </li></ul></ul><ul><li>T INY S TORE </li></ul><ul><ul><li>both the old and new values are always stored persistently on flash w/o commit buffer </li></ul></ul><ul><ul><ul><li> because TinyStore always stores updated information in new memory location </li></ul></ul></ul><ul><ul><li>to use a log (journal) data structure </li></ul></ul><ul><ul><ul><li>doesn’t contain copies of fields/array elements </li></ul></ul></ul><ul><ul><ul><li>contain pointers to the new and/or old copies of objects and tree nodes </li></ul></ul></ul>
    13. 13. Experimental Setup <ul><li>Configurations </li></ul><ul><li>5 types of workloads ( object field modification operation type ) </li></ul><ul><ul><li>TotallyRandom : updates random fields within a random objects </li></ul></ul><ul><ul><li>20/80AllFields : 20% hot objects (P=0.9) / 80% cold objects (P=0.1) </li></ul></ul><ul><ul><li>until 100,000 times erased for one erase unit </li></ul></ul><ul><li>Metric </li></ul><ul><ul><li>number of counts : read, write, erase operations </li></ul></ul><ul><ul><li>t flash (ns) = 100 n r + 30 x 10 3 n w + 500 x 10 6 n e </li></ul></ul><ul><ul><li>t eeprom (ns)= 100 n r + 30 x 10 3 n w + 3.5 x 10 6 n e </li></ul></ul><ul><ul><li>N w , N r , N e : total counts , N : total # of fields modified , n w (amortized # of writes) = N w / N </li></ul></ul>emulated Flash (NOR) 448KB, 8 KB erase unit emulated EEPROM T INY S TORE JVM C program emulate Running applets GC disabled At most 2 record in lists 8KB erase unit
    14. 14. Experimental Results <ul><li>< EEPROM operations > </li></ul><ul><li>Independent of fullness and object size </li></ul><ul><li>In-place update strategy </li></ul><ul><li>Inefficiency in copying of every fields to the commit buffer </li></ul><ul><li> when large objects and all fields modified </li></ul><ul><li>< TinyStore operations > </li></ul><ul><li>highly dependent of fullness and workload </li></ul><ul><li>More write operations than EEPROM </li></ul><ul><li>In case of larger object, all fields </li></ul><ul><li>Fewer write (simply writes new field values ) than EEPROM </li></ul><ul><li>Fewer erasures </li></ul><ul><li> Estimated times are much faster than EEPROM </li></ul>
    15. 15. Experimental Results <ul><li>< Endurance > </li></ul><ul><li>TotallyRandom </li></ul><ul><li> TinyStore incurs erasures due to REF tree </li></ul><ul><li>20/80AllFields </li></ul><ul><li> Better than EEPROM </li></ul>
    16. 16. Experimental Results <ul><li>< Storage Overhead of TinyStore > </li></ul><ul><li>-> to create fixed-size arrays until we run out of memory, and then check allocated user data space </li></ul><ul><li>Overhead </li></ul><ul><li> By REF tree , object descriptor, flags, NEXT field </li></ul><ul><li>Small arrays </li></ul><ul><li> <=40% (flash), <=65% (eeprom) </li></ul><ul><li>Large arrays </li></ul><ul><li> 60~80% (flash), 83~98% (eeprom) </li></ul>
    17. 17. Experimental Results <ul><li>< cost of explicit transaction > </li></ul><ul><li>Atomicity causes significant overhead </li></ul><ul><li>in EEPROM </li></ul><ul><li> Caused by the need to write old values to log </li></ul><ul><li> TinyStore slightly better </li></ul>
    18. 18. Conclusion <ul><li>T INY S TORE </li></ul><ul><ul><li>novel approach for storing a Java heap on NOR flash memory </li></ul></ul><ul><ul><li>the first attempt to implement a memory manager for Java Cards for flash </li></ul></ul><ul><ul><li>GC in systems that have very little RAM </li></ul></ul><ul><ul><li>NOR flash is used for marking objects and for storing the mark-stack </li></ul></ul><ul><ul><li>improved performance (estimated times) and endurance </li></ul></ul><ul><ul><li>by efficient atomicity and transaction mechanism </li></ul></ul><ul><ul><li>higher storage overhead </li></ul></ul><ul><ul><li>performance strongly influenced by </li></ul></ul><ul><ul><li>large flash erase units, small RAM size, and the need to manage small data </li></ul></ul><ul><ul><li>objects </li></ul></ul>