CN110908771A - Memory management method of intelligent contract based on JAVA - Google Patents

Memory management method of intelligent contract based on JAVA Download PDF

Info

Publication number
CN110908771A
CN110908771A CN201911110938.8A CN201911110938A CN110908771A CN 110908771 A CN110908771 A CN 110908771A CN 201911110938 A CN201911110938 A CN 201911110938A CN 110908771 A CN110908771 A CN 110908771A
Authority
CN
China
Prior art keywords
contract
classes
java
user
virtual machine
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201911110938.8A
Other languages
Chinese (zh)
Inventor
邱炜伟
尹可挺
李伟
宋宇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Qulian Technology Co Ltd
Original Assignee
Hangzhou Qulian Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Qulian Technology Co Ltd filed Critical Hangzhou Qulian Technology Co Ltd
Priority to CN201911110938.8A priority Critical patent/CN110908771A/en
Publication of CN110908771A publication Critical patent/CN110908771A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45583Memory management, e.g. access or allocation

Abstract

The invention discloses a memory management method of intelligent contracts based on JAVA, which caches contract classes of users in a memory by modifying a JAVA virtual machine, realizes the function of repeatedly analyzing contract byte codes when the users send requests each time, and simultaneously realizes the management of the life cycle of the contract classes and controls the recovery mechanism of the contract classes by modifying a garbage recoverer mechanism of the JAVA virtual machine. The invention modifies the memory model and the garbage recycling mechanism of the JAVA virtual machine, so that the virtual machine is more efficient in processing JAVA contract class codes, and the processing efficiency of the virtual machine is improved.

Description

Memory management method of intelligent contract based on JAVA
Technical Field
The invention relates to a block chain technology, in particular to a memory management method of an intelligent contract based on JAVA.
Background
An intelligent contract is an assembly language programmed on a blockchain, the term being proposed by a cross-domain legal student in nike-Sabo, whose definition on an intelligent contract is "an intelligent contract is a set of numerically defined commitments including protocols on which the contracts participants can execute, in other words, an intelligent contract is a contract that can be automatically executed on a computer system when certain conditions are met. Usually one does not write the bytecode itself, but it is compiled from a higher level language, e.g. a proprietary language like JAVA.
The existing memory management method of the intelligent contract using JAVA has certain defects, and a user needs to perform deserialization and class loading processes on contract classes each time the contract is called, so that the calling time of the contract is reduced, and the time delay is increased. Further, in a block chain application scenario, a garbage recycling mechanism of the JAVA virtual machine has certain defects, and the JAVA virtual machine on the market can recycle the system class and the user contract class under the condition of insufficient memory. However, the execution efficiency is seriously affected by loading and recycling the class frequently in the block chain scene.
Disclosure of Invention
Aiming at the defects of the prior art, the invention provides an intelligent contract memory management method based on JAVA, which manages the memory in the processes of JAVA contract deployment, calling and upgrading and improves the execution efficiency of JAVA contracts, and the specific technical scheme is as follows:
a memory management method of intelligent contract based on JAVA, the memory management includes caching user contract class and carrying out different garbage recovery mechanism to different classes, wherein,
for caching user contract classes, when a JAVA virtual machine receives a request for analyzing the user contract classes, acquiring a contract deployment address and the contract classes of a user, and storing the contract classes of the user into a cache set in a memory, wherein the index of the cache set is the contract deployment address, when the user calls the contract classes at the contract deployment address next time, the contract classes are taken out of the memory, modifiable fields of the contract classes are reset and then returned to the user, and the contract classes are ensured to be consistent when returned to the user each time;
the mechanism for performing different garbage recycling on different classes specifically includes the following three conditions:
(1) for the system classes in JAVA, the virtual machine does not carry out garbage collection on the system classes, and all the system classes are distributed in one area in the memory;
(2) when the size of data in the cache exceeds a certain limit, the virtual machine automatically clears some user contract classes by using a page replacement algorithm so as to achieve the purpose of controlling the size of the memory;
(3) for each class instance, the virtual machine cleans it up with the garbage collection algorithm of JAVA.
Further, for system classes in JAVA, the virtual machine initializes them at startup.
Further, the modifiable field of the contract class is a static field.
Further, the page replacement algorithm is specifically a least recently used algorithm.
Furthermore, the system class, the contract class and the instances of each class are respectively stored in three different memory addresses, and are not overlapped with each other.
The invention has the beneficial effects that:
the invention is applied to a block chain platform, provides a set of brand-new intelligent contract memory management, realizes the caching of contract classes, does not need to be loaded every time of calling, and improves the code execution efficiency; a cache elimination mechanism is carried out on the cache while caching, so that the overflow of the memory is avoided; modifying a JAVA garbage recycling mechanism to enable JAVA garbage recycling to be more efficient; when the virtual machine is started, the system class is initialized, and the execution speed of the JAVA code is accelerated.
Drawings
FIG. 1 is a diagram of cache deposits of the present invention;
FIG. 2 is a flow diagram of reading a cache;
FIG. 3 is a schematic diagram of an LRU cache eviction algorithm.
Detailed Description
The present invention will be described in detail below with reference to the drawings and specific embodiments, and the objects and effects of the present invention will become more apparent.
The intelligent contract life cycle management method based on JAVA of the invention comprises two convenience of caching user contract classes and carrying out different garbage recycling mechanisms on different classes, wherein,
for caching user contract classes, when a JAVA virtual machine receives a request for analyzing the user contract classes, acquiring a contract deployment address and the contract classes of a user, and storing the contract classes of the user into a cache set in a memory, wherein an index of the cache set is the contract deployment address, when the user calls the contract classes at the contract deployment address next time, the contract classes are taken out of the memory, and a static field of the contract classes is reset and then returned to the user, so that the contract classes are consistent when being returned to the user each time; the specific cache storage manner is shown in fig. 1, and the flow of reading the cache is shown in fig. 2.
The mechanism for performing different garbage recycling on different classes specifically includes the following three conditions:
(1) for the system class in JAVA, the virtual machine does not carry out garbage collection on the system class, and all the system classes are distributed in a region in the memory.
(2) For the contract class of the user, the virtual machine automatically manages the memory, the virtual machine maintains a cache set in the memory, when the virtual machine caches the user class, the virtual machine inserts the class into the cache set, meanwhile, the virtual machine carries out a cache elimination strategy on the cache set, and when the size of the cache set exceeds a certain limit, the virtual machine manually eliminates some user classes by using a page replacement algorithm LRU so as to achieve the purpose of controlling the size of the memory. The algorithm keeps the most recently used contract class and eliminates the contract class which is too long in time of last use. The principle of the specific LRU algorithm is shown in fig. 3. That is, the cache set in the virtual machine uniformly maintains the survival time of the user class, which is not determined by the garbage collection mechanism.
(3) For each class instance, the virtual machine cleans it up with the garbage collection algorithm of JAVA.
For the system class in JAVA, the virtual machine initializes the system class when being started, thereby reducing the overhead of initializing the system class when running and improving the execution speed of the program.
Preferably, the modifiable field of the contract class is a static field. The page replacement algorithm is specifically the least recently used algorithm. The system class, the contract class and the instances of each class are respectively stored in three different memory addresses and are not overlapped with each other.

Claims (5)

1. A memory management method of intelligent contract based on JAVA is characterized in that the memory management comprises caching user contract classes and carrying out different garbage recycling mechanisms on different classes, wherein,
for caching user contract classes, when a JAVA virtual machine receives a request for analyzing the user contract classes, acquiring a contract deployment address and the contract classes of a user, and storing the contract classes of the user into a cache set in a memory, wherein the index of the cache set is the contract deployment address, when the user calls the contract classes at the contract deployment address next time, the contract classes are taken out of the memory, modifiable fields of the contract classes are reset and then returned to the user, and the contract classes are guaranteed to be consistent when returned to the user each time.
The mechanism for performing different garbage recycling on different classes specifically includes the following three conditions:
(1) for the system classes in JAVA, the virtual machine does not carry out garbage collection on the system classes, and all the system classes are distributed in one area in the memory;
(2) when the size of data in the cache exceeds a certain limit, the virtual machine automatically clears some user contract classes by using a page replacement algorithm so as to achieve the purpose of controlling the size of the memory;
(3) for each class instance, the virtual machine cleans it up with the garbage collection algorithm of JAVA.
2. A method for memory management in a JAVA based smart contract as claimed in claim 1, wherein the virtual machine initializes the system classes in JAVA at start-up.
3. A method for memory management in a JAVA based smart contract as claimed in claim 1, wherein the modifiable field of the contract class is a static field.
4. A method for memory management in a JAVA based smart contract as claimed in claim 1, wherein said page permutation algorithm is specifically a least recently used algorithm.
5. A memory management method for a JAVA based smart contract as claimed in claim 1, wherein the system class, the contract class and the instance of each class are stored in three different memory addresses respectively, and do not coincide with each other.
CN201911110938.8A 2019-11-14 2019-11-14 Memory management method of intelligent contract based on JAVA Pending CN110908771A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911110938.8A CN110908771A (en) 2019-11-14 2019-11-14 Memory management method of intelligent contract based on JAVA

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911110938.8A CN110908771A (en) 2019-11-14 2019-11-14 Memory management method of intelligent contract based on JAVA

Publications (1)

Publication Number Publication Date
CN110908771A true CN110908771A (en) 2020-03-24

Family

ID=69817373

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911110938.8A Pending CN110908771A (en) 2019-11-14 2019-11-14 Memory management method of intelligent contract based on JAVA

Country Status (1)

Country Link
CN (1) CN110908771A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114371852A (en) * 2022-01-13 2022-04-19 北京字节跳动网络技术有限公司 Compiling method and device

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101484876A (en) * 2006-07-14 2009-07-15 英特尔公司 Heap organization for a multitasking virtual machine
CN106843756A (en) * 2017-01-13 2017-06-13 中国科学院信息工程研究所 Memory pages recovery method and system based on page classifications
CN108052388A (en) * 2017-11-24 2018-05-18 武汉斗鱼网络科技有限公司 Method for recovering internal storage and device in a kind of Android
US20190034402A1 (en) * 2017-07-28 2019-01-31 International Business Machines Corporation Cognitive mediator for generating blockchain smart contracts
CN109949156A (en) * 2019-02-28 2019-06-28 矩阵元技术(深圳)有限公司 A kind of data processing method and server of block chain contract
CN110175075A (en) * 2019-05-21 2019-08-27 深圳市君和睿通科技股份有限公司 Android system Memory Optimize Method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101484876A (en) * 2006-07-14 2009-07-15 英特尔公司 Heap organization for a multitasking virtual machine
CN106843756A (en) * 2017-01-13 2017-06-13 中国科学院信息工程研究所 Memory pages recovery method and system based on page classifications
US20190034402A1 (en) * 2017-07-28 2019-01-31 International Business Machines Corporation Cognitive mediator for generating blockchain smart contracts
CN108052388A (en) * 2017-11-24 2018-05-18 武汉斗鱼网络科技有限公司 Method for recovering internal storage and device in a kind of Android
CN109949156A (en) * 2019-02-28 2019-06-28 矩阵元技术(深圳)有限公司 A kind of data processing method and server of block chain contract
CN110175075A (en) * 2019-05-21 2019-08-27 深圳市君和睿通科技股份有限公司 Android system Memory Optimize Method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114371852A (en) * 2022-01-13 2022-04-19 北京字节跳动网络技术有限公司 Compiling method and device
CN114371852B (en) * 2022-01-13 2023-10-24 抖音视界有限公司 Compiling method and device

Similar Documents

Publication Publication Date Title
CN100365577C (en) Persistent cache apparatus and methods
US7103723B2 (en) Priority-based code cache management
US6701520B1 (en) Preventing garbage collection of objects in object oriented computer programming languages
US20070150881A1 (en) Method and system for run-time cache logging
US8707282B2 (en) Meta-data based data prefetching
US20110302594A1 (en) Accelerated class check
US10261918B2 (en) Process running method and apparatus
CN100447744C (en) Method and system for managing stack
KR20040076048A (en) System and method for shortening time in compiling of byte code in java program
CN1829977B (en) Method and apparatus for improving the performance of garbage collection using stack trace cache
CN113688062B (en) Method for storing data and related product
CN113297098B (en) High-performance adaptive prefetching intelligent cache replacement strategy
CN102109980B (en) The method and apparatus of adaptive prefetching operation is performed in trustship runtime environment
US8966212B2 (en) Memory management method, computer system and computer readable medium
CN112579259B (en) GC self-adaptive adjustment method and device for big data processing framework
CN110908771A (en) Memory management method of intelligent contract based on JAVA
KR100985239B1 (en) Reducing cache trashing of certain pieces
CN103092618A (en) Dalvik virtual machine just-in-time compilation (JIT) acceleration method based on software Cache
US7240341B2 (en) Global constant pool to allow deletion of constant pool entries
CN112860381B (en) Virtual machine memory capacity expansion method and system based on Shenwei processor
CN114416031A (en) Operating system for supporting RISC-V processor facing AIoT scene
CN112035253B (en) Linux system page cache recovery method and related device
US20080034022A1 (en) System and method for updating references when incrementally compacting a heap
CN113360274A (en) Garbage recycling method and device and computing equipment
CN116719609A (en) Performance optimization method of JavaScript engine

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20200324