Deserialization method and apparatus, and computing device
AssigneeHuawei Cloud Computing Technologies Co., Ltd.
InventorsWeihua Shan, Xuliang Li
Life of this patent
Estimating the term…
Abstract
This application discloses a deserialization method. A first object shell of a first object is created in memory space of a process, where the first object shell includes a first object header and a first object body; a serialization result of the first object is obtained; the serialization result of the first object is deserialized based on the first object shell, to obtain the first object; and after the first object is used by the process, the first object shell is released, where the first object shell may be used to deserialize a subsequently received serialization result. Deserialization efficiency is improved by reusing an object shell.
Claims13
A method for performing deserialization by a computing device, comprising:
- starting a process and sending an initialization instruction to a deserialization module of the computing device, wherein the initialization instruction comprises information about a class to which a first object belongs which is subsequently used by the process,
- sending, by the deserialization module, a creation instruction to an object pool management module based on the initialization instruction, wherein the creation instruction comprises a) the information about the class to which the first object belongs which is subsequently used by the process and b) a quantity or proportion of each object obtained by instantiating the class, wherein the quantity or proportion of each object obtained by instantiating the class is based on an estimated frequency that an object obtained by instantiating the class is invoked, so that the object pool management module determines classes corresponding to to-be-created object pools and a quantity of object shells in each object pool;
- creating the object pools and object pool status information in memory space of the process based on the creation instruction, wherein one of the object pools comprises a first object shell of the first object, wherein the first object shell is created in old generation memory space of the process, wherein the first object shell comprises a first object header and a first object body, the first object header comprises a type pointer of the first object, and space is reserved in the first object body for an element of the first object, and wherein the object pool status information records which object shell is idle and which object shell is being borrowed in each object pool;
- obtaining a serialization result of the first object;
- obtaining the first object shell;
- and
- deserializing the serialization result of the first object based on the first object shell, to obtain the first object.
A computing device, comprising a processor and a memory storing instructions, wherein
- when the instructions are executed by the processor, the processor is configured to:
- start a process and send an initialization instruction to a deserialization module of the computing device, wherein the initialization instruction comprises information about a class to which a first object belongs which is subsequently used by the process,
- send, by the deserialization module, a creation instruction to an object pool management module of the computing device based on the initialization instruction, wherein the creation instruction comprises a) the information about the class to which the first object belongs which is subsequently used by the process and b) a quantity or proportion of each object obtained by instantiating the class, wherein the quantity or proportion of each object obtained by instantiating the class is based on an estimated frequency that an object obtained by instantiating the class is invoked, so that the object pool management module determines classes corresponding to to-be-created object pools and a quantity of object shells in each object pool;
- create the object pools and object pool status information in memory space of the process based on the creation instruction, wherein one of the object pools comprises a first object shell of the first object, wherein the first object shell is created in old generation memory space of the process, wherein the first object shell comprises a first object header and a first object body, the first object header comprises a type pointer of the first object, and space is reserved in the first object body for an element of the first object, and wherein the object pool status information records which object shell is idle and which object shell is being borrowed in each object pool;
- obtain a serialization result of the first object;
- obtain the first object shell;
- and
- deserialize the serialization result of the first object based on the first object shell, to obtain the first object.
A non-transitory computer-readable storage medium storing instructions, which when executed by a computing device, cause the computing device to perform the following method:
- starting a process and sending an initialization instruction to a deserialization module of the computing device, wherein the initialization instruction comprises information about a class to which a first object belongs which is subsequently used by the process,
- sending, by the deserialization module, a creation instruction to an object pool management module based on the initialization instruction, wherein the creation instruction comprises a) the information about the class to which the first object belongs which is subsequently used by the process and b) a quantity or proportion of each object obtained by instantiating the class, wherein the quantity or proportion of each object obtained by instantiating the class is based on an estimated frequency that an object obtained by instantiating the class is invoked, so that the object pool management module determines classes corresponding to to-be-created object pools and a quantity of object shells in each object pool;
- creating the object pools and object pool status information in memory space of the process based on the creation instruction, wherein one of the object pools comprises a first object shell of the first object, wherein the first object shell is created in old generation memory space of the process, wherein the first object shell comprises a first object header and a first object body, the first object header comprises a type pointer of the first object, and space is reserved in the first object body for an element of the first object, and wherein the object pool status information records which object shell is idle and which object shell is being borrowed in each object pool;
- obtaining a serialization result of the first object;
- obtaining the first object shell;
- and
- deserializing the serialization result of the first object based on the first object shell, to obtain the first object.
Dependencies are inferred from the claim text.