File sharing method and apparatus, electronic device, and storage medium

By acquiring and mapping the information set of the target application, the problem of excessive memory resource consumption caused by multiple applications loading the same file is solved, resource sharing in the shared physical space is realized, improving running speed and reducing resource consumption.

CN115934662BActive Publication Date: 2026-02-06SHENZHEN TENCENT COMP SYST CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110921370.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-11
Publication Date
2026-02-06
Estimated Expiration
2041-08-11

AI Technical Summary

Technical Problem

When multiple applications load the same file, it leads to excessive memory consumption, and existing technologies have not been able to effectively solve the resource consumption problem.

Method used

By acquiring the information set of the target application, memory mapping is performed based on the target virtual mapping space. Access requests are responded to and data in the shared physical space is retrieved upon success, or the virtual space is converted into the shared physical space to load data.

Benefits of technology

This allows multiple applications to share files in the same shared physical space, reducing resource consumption and improving application performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115934662B_ABST
    Figure CN115934662B_ABST
Patent Text Reader

Abstract

The application discloses a file sharing method and device, electronic equipment and a storage medium; when a target application program is detected to be started, a target information set is acquired; a target shared file is memory mapped based on a target virtual mapping space, and a mapping relationship is obtained; in response to an access request of the target application program accessing target data, a shared physical space corresponding to the target virtual mapping space is accessed based on the mapping relationship; when the shared physical space corresponding to the target virtual mapping space is successfully accessed, target data in the target shared file in the shared physical space is acquired; when the shared physical space corresponding to the target virtual mapping space fails to be accessed, the target virtual space is converted into a shared physical space in memory, data in the target shared file is loaded into the shared physical space, and the target data in the target shared file in the shared physical space is acquired. The scheme can reduce resource consumption.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a file sharing method and device, electronic equipment and storage medium. BACKGROUND

[0002] An application program refers to a computer program developed and run on an operating system to complete one or more specific tasks. The application program running on the operating system can correspond to a process, and the process is a running activity of the application program on a certain data set; the process can apply for and own system resources, such as an independent virtual address space.

[0003] At present, when multiple application programs load the same file, a large amount of memory resources will be occupied. SUMMARY

[0004] The present application provides a file sharing method, device, electronic equipment and storage medium, which can reduce resource consumption.

[0005] The present application provides a file sharing method, comprising:

[0006] When it is detected that a target application program is started, a target information set is acquired, the target information set is a set of information corresponding to resources of the target application program, and the target information set includes information of a target shared file;

[0007] Memory mapping is performed on the target shared file based on a target virtual mapping space, a mapping relationship is obtained, and the target virtual mapping space is determined according to the information of the target shared file;

[0008] In response to an access request of the target application program to access target data, a shared physical space corresponding to the target virtual mapping space is accessed based on the mapping relationship;

[0009] When the access to the shared physical space corresponding to the target virtual mapping space is successful, target data in the target shared file in the shared physical space is acquired;

[0010] When the access to the shared physical space corresponding to the target virtual mapping space fails, the target virtual space is converted into a shared physical space in memory, data in the target shared file is loaded into the shared physical space, and target data in the target shared file in the shared physical space is acquired.

[0011] The present application also provides a file sharing device, comprising:

[0012] An acquisition unit is configured to acquire a target information set when it is detected that a target application program is started, the target information set is a set of information corresponding to resources of the target application program, and the target information set includes information of a target shared file and a target virtual mapping address.

[0013] map the target shared file based on a target virtual mapping space to obtain a mapping relationship, the target virtual mapping space being determined according to information of the target shared file and a target virtual mapping address;

[0014] In response to an access request of the target application program to the target data, the response unit accesses the shared physical space corresponding to the target virtual mapping space based on the mapping relationship; when the access to the shared physical space corresponding to the target virtual mapping space succeeds, the target data in the target shared file in the shared physical space is obtained; when the access to the shared physical space corresponding to the target virtual mapping space fails, the target virtual space is converted into the shared physical space in the memory, and the data in the target shared file is loaded into the shared physical space, so that the target data in the target shared file in the shared physical space is obtained.

[0015] In some embodiments, the file sharing apparatus is further configured to:

[0016] obtain information of running data accessed by a plurality of application programs during running, the plurality of application programs including the target application program;

[0017] determine a set of information corresponding to shared resources according to the information of the running data accessed by the application programs during running;

[0018] obtain the target information set, including:

[0019] obtain a resource path of the target application program;

[0020] determine the target information set according to the resource path of the target application program and the set of information corresponding to the shared resources.

[0021] In some embodiments, the information of the running data of the application program includes a dependency relationship between the running data and a file set to which the running data belongs, and the set of information corresponding to the shared resources includes a shared node set, and the file sharing apparatus is specifically configured to:

[0022] convert the file set to which the running data belongs into a node corresponding to the application program;

[0023] determine the shared node set based on the dependency relationship between the running data and the node corresponding to the application program.

[0024] In some embodiments, the file sharing apparatus is specifically configured to:

[0025] determine a dependency relationship between the nodes corresponding to the application programs according to the dependency relationship between the running data;

[0026] Sort the nodes corresponding to the application programs according to the dependency relationship between the nodes corresponding to the application programs, to obtain a node set corresponding to the application programs;

[0027] Based on the node set corresponding to the application programs, determine a shared node set.

[0028] In some embodiments, the file sharing device is specifically used for:

[0029] The nodes shared by all the application programs in the node set corresponding to the multiple application programs are taken as basic shared nodes; and / or,

[0030] The nodes shared by at least one application program in the node set corresponding to the multiple application programs are taken as local shared nodes; and / or,

[0031] The nodes in the node set corresponding to the multiple application programs, except the basic shared nodes and the local shared nodes, are taken as common nodes;

[0032] Determine a shared node set, the shared node set including at least one of the basic shared nodes, the local shared nodes and the common nodes.

[0033] In some embodiments, the file sharing device is specifically used for:

[0034] According to the dependency relationship between the shared nodes in the shared node set, generate node index information;

[0035] Based on the running data corresponding to the basic shared nodes, generate shared files corresponding to the basic shared nodes and information of the shared files; and / or,

[0036] Based on the node index information and the running data corresponding to the local shared nodes, generate shared files corresponding to the local shared nodes and information of the shared files; and / or,

[0037] According to the node index information and the running data corresponding to the common nodes, generate shared files corresponding to the common nodes and information of the shared files;

[0038] Based on the information of the shared files corresponding to the basic shared nodes and / or the information of the shared files corresponding to the local shared nodes and / or the information of the shared files corresponding to the common nodes, update the node index information.

[0039] In some embodiments, the file sharing device is specifically used for:

[0040] According to the node index information, determine the basic shared nodes on which the local shared nodes depend;

[0041] Based on the shared files of the basic shared nodes on which the local shared nodes depend and the running data corresponding to the local shared nodes, generate shared files corresponding to the local shared nodes.

[0042] In some embodiments, the file sharing device is specifically used for:

[0043] determining a virtual mapping address corresponding to the base shared node;

[0044] updating the node index information according to the virtual mapping address corresponding to the base shared node;

[0045] generating a shared file corresponding to the local shared node based on the node index information and the running data of the local shared node, and the file sharing device further comprises:

[0046] obtaining the virtual mapping address corresponding to the base shared node and the virtual mapping address of the local shared node of the generated shared file from the node index information;

[0047] calculating the virtual mapping address of the current local shared node according to the virtual mapping address corresponding to the base shared node and the virtual mapping address of the local shared node of the generated shared file;

[0048] updating the node index information based on the virtual mapping address of the current local shared node.

[0049] In some embodiments, the file sharing device is specifically used for:

[0050] determining a file set containing the same data type from the file set to which the running data belongs;

[0051] regarding the file set containing the same data type as a node.

[0052] In some embodiments, the target information set includes a data type set in the target shared file, and the file sharing device is further used for:

[0053] updating the preset global data type set according to the data type set in the target shared file;

[0054] obtaining target data in the target shared file in the shared physical space, comprising:

[0055] finding a data type corresponding to the target data in the global data type set;

[0056] obtaining the target data from the shared physical space according to the data type corresponding to the target data.

[0057] In some embodiments, the file sharing device is further used for:

[0058] when the memory mapping fails, determining a new virtual mapping address in a virtual address space, and the virtual address space is a virtual address space corresponding to the running of the target application program;

[0059] The target shared file is remapped in memory based on the new virtual mapping space, and the new virtual mapping space corresponds to a new virtual mapping address.

[0060] When the memory remapping is successful, the target virtual mapping address in the target information set is updated to the new virtual mapping address.

[0061] In some embodiments, the target shared file is a shared file corresponding to the target shared node, and the file sharing apparatus is further configured to:

[0062] Obtain node index information;

[0063] Based on the node index information, determine a node relied on by the target shared node;

[0064] Map in memory a shared file corresponding to the node relied on by the target shared node.

[0065] The application further provides an electronic device including a memory and a processor, the memory storing a plurality of instructions; the processor loads the instructions from the memory to perform the steps in any of the file sharing methods provided by the application.

[0066] The application further provides a computer-readable storage medium storing a plurality of instructions, the instructions being adapted to be loaded by a processor to perform the steps in any of the file sharing methods provided by the application.

[0067] In the application, the shared files of a plurality of application programs and corresponding virtual mapping spaces are generated by obtaining information of running data accessed by the plurality of application programs when running; when a target application program is started, the shared files are mapped based on the virtual mapping spaces, so that the shared files correspond to the virtual mapping spaces; then, in response to an access request of the target application program for accessing target data, the target data in the shared files is accessed; if the shared files have been loaded by an application program before the target application program loads the shared files, a shared physical space corresponding to the virtual mapping space exists in the memory, so that the data in the shared files in the shared physical space can be accessed; if no application program loads the shared files into the memory before the target application program loads the shared files, the virtual mapping address needs to be converted into a shared physical space, and the shared files need to be loaded into the shared physical space. Thus, the plurality of application programs can share the shared files in the same shared physical space, and resource consumption is reduced. BRIEF DESCRIPTION OF DRAWINGS

[0068] In order to more clearly illustrate the technical solutions in the present application, the drawings needed in the embodiments will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and all other drawings obtained by those skilled in the art without creative effort based on the drawings belong to the protection scope of the present application.

[0069] Figure 1a is a flowchart of a file sharing method provided by the present application;

[0070] Figure 1b is a schematic diagram of a file set dependency relationship provided by the present application;

[0071] Figure 1c is a schematic diagram of a node index table provided by the present application;

[0072] Figure 2a is a schematic diagram of a jar package corresponding to a big data platform provided by the present application;

[0073] Figure 2b is a schematic diagram of a class path corresponding to a plurality of application programs provided by the present application;

[0074] Figure 2c is a flowchart of another file sharing method provided by the present application;

[0075] Figure 2d is a schematic diagram of converting a class path into a node set provided by the present application;

[0076] Figure 3 is a schematic diagram of a structure of a file sharing device provided by the present application;

[0077] Figure 4 is a schematic diagram of a structure of an electronic device provided by the present application. DETAILED DESCRIPTION

[0078] The technical solutions in the present application will be described clearly and completely in the present application with reference to the drawings. Obviously, the described embodiments are only some embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative effort belong to the protection scope of the present application.

[0079] The present application provides a file sharing method, device, electronic device and storage medium.

[0080] The file sharing apparatus can be integrated in an electronic device, which can be a terminal, a server, or the like. The terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a notebook computer, a personal computer (PC), or the like. The server can be a single server or a server cluster composed of multiple servers. In some embodiments, the server can also be implemented in the form of a terminal.

[0081] In some embodiments, the file sharing apparatus can also be integrated in multiple electronic devices, for example, the file sharing apparatus can be integrated in multiple servers to implement the file sharing method of the present application.

[0082] For example, the file sharing apparatus can be integrated in an electronic device, which is equipped with an operating system, which can be a Windows operating system, a Linux operating system, or the like, or a mobile operating system (such as Android, iOS, or the like). The electronic device is also installed with multiple application programs, which can run on the operating system. When the electronic device detects the start of a target application program, it acquires a target information set, which is a set of information corresponding to resources of the target application program, and includes information of a target shared file. The target shared file is subjected to memory mapping based on a target virtual mapping space, which is determined according to the information of the target shared file, to obtain a mapping relationship. In response to an access request of the target application program to access target data, the shared physical space corresponding to the target virtual mapping space is accessed based on the mapping relationship. When the access to the shared physical space corresponding to the target virtual mapping space is successful, the target data in the target shared file in the shared physical space is acquired. When the access to the shared physical space corresponding to the target virtual mapping space fails, the target virtual space is converted into a shared physical space in memory, and the data in the target shared file is loaded into the shared physical space to acquire the target data in the target shared file in the shared physical space.

[0083] In this solution, the data accessed by multiple application programs is generated into a shared file, and a set of information corresponding to resources is stored in the electronic device. When a target application program is started, the shared file is corresponded to a virtual mapping space according to the set of information corresponding to resources of the target application program. When the target application program needs to access target data, the shared file is loaded into a shared physical space. When the next application program needs to access the target data, the shared physical space corresponding to the target application program can be reused to access the data in the shared file in the shared physical space. Thus, multiple application programs can share the shared file in the same shared physical space, and resource consumption is reduced.

[0084] The following are described in detail respectively. It should be noted that the serial numbers of the following embodiments are not intended to limit the preferred order of the embodiments.

[0085] In this embodiment, a file sharing method is provided, as shown in the figure, the specific process of the file sharing method can be as follows: Figure 1a

[0086] 101, when it is detected that the target application program is started, a target information set is acquired.

[0087] The target application program is any one of the plurality of application programs installed on the electronic device, the application program is a computer program running on the operating system, and can be developed using different programming languages, for example, Java, c++, etc.

[0088] The resources of the target application program can be stored in the storage device (such as a hard disk) of the electronic device in the form of a file; for example, the resources of the target application program can be a plurality of shared files corresponding to the target application program, and the computer program can be stored in the file. The acquisition method of the target information set is not limited.

[0089] The target information set is a set of information corresponding to the resources of the target application program, and includes information of the target shared file, node information of the target shared node, etc.

[0090] In some embodiments, the electronic device can acquire the resource path of the target application program after the target application program is started; the resource path can refer to the path accessed by the system, and all files under the path can be read by the application program, for example, it can be a class path (class path), and the specific form can be {rt.jar: a.jar: b.jar: c.jar: d.jar: e.jar}.

[0091] Further, the electronic device determines the target information set according to the resource path of the target application program and the set of information corresponding to the shared resources; the shared resources can represent the resources of the plurality of application programs; the set of information corresponding to the shared resources can represent the set of information corresponding to the resources of the plurality of application programs, and can include but not limited to the shared node set and the node index information of the shared node set.

[0092] The specific implementation of acquiring the set of information corresponding to the shared resources is not limited.

[0093] ​I. The electronic device obtains information of running data accessed by a plurality of application programs at runtime; wherein the running data can be data accessed by the application programs at runtime; for example, the running data can be computer programs accessed by the application programs at runtime, and the computer programs can be basic data types and reference data types, specifically, classes, interfaces, enumerations, annotations, etc.; it should be noted that when the running data is a class corresponding to a computer program, accessing the running data can also be referred to as loading the class. The information of the running data of the application program can include but is not limited to the dependency relationship between the running data, the file set to which the running data belongs, the class name of the running data, etc. Taking the running data as a plurality of classes loaded by the application program at runtime as an example, the information of the running data can include but is not limited to: 1) the class name of each class; 2) the file set (the source of the class) to which each class belongs, for example, the file set can be a jar / module set (referred to as a jar package), such as rt.jar shown in Table 1; 3) the dependency relationship of each class, for example, it can include the information of the interface and parent class (the information of the dependent class) that the class depends on, and the information of the dependent class can include the class name and the file set to which it belongs; taking an application program as an example, Table 1 can represent the dependency relationship of the classes loaded by the application program; 4) the information of all file sets under the class path corresponding to the application program.

[0094] Table 1 Dependency relationship of classes loaded by an application program

[0095]

[0096] II. The electronic device determines a set of information corresponding to a shared resource according to the information of the running data accessed by the application program at runtime.

[0097] (1) Convert the file set to which the running data belongs into a node corresponding to the application program.

[0098] The node can include but is not limited to the following node information: 1) a node identifier, which can distinguish between different nodes; 2) a list of file sets; 3) information of dependent nodes; 4) a data type set, for example, a class list, specifically, a list formed by the class names of the classes stored in the file set corresponding to the node, or a list formed by the class names of the classes in the running data corresponding to the node; 5) information of a shared file, such as a virtual mapping address, a file size of the shared file, and a storage address of the shared file, etc., wherein the virtual mapping address can be a starting address when the shared file is memory mapped.

[0099] In some embodiments, a file set containing the same data type is determined from the file set to which the running data belongs; and the file set containing the same data type is taken as a node. Where the same data type indicates that the data type name of the data and the namespace of the data type are consistent; taking the jar package as an example, it is determined whether there is a same class (the class name and the namespace of the class are consistent) in each jar package, and the jar package containing the same class is taken as a node. The jar packages in the node can be sorted according to the order of the class path of the application program, to ensure that the loading order of the same class is not changed. As shown in Table 1, b.jar and c.jar contain the same class, and b.jar, c.jar are taken as a node; then the node corresponding to the application program can have node 1: rt.jar, node 2: a.jar, node 3: b.jar, c.jar, node 4: d.jar, and node 5: d.jar. Optionally, when the jar package containing the same class is taken as a node, the data type (such as the type) of the running data corresponding to the jar package is formed into a data type set (such as a class list).

[0100] In some embodiments, all file sets under the class path of the application program can also be directly converted into the node corresponding to the application program according to the class path of the application program.

[0101] (2) A shared node set is determined based on the dependency relationship between the running data and the node corresponding to the application program.

[0102] i. The dependency relationship between the nodes corresponding to the application program is determined according to the dependency relationship between the running data. In some embodiments, the dependency tree capable of indicating the dependency relationship can be generated from the file set according to the dependency relationship between the running data, for example, as shown in Table 1, the dependency relationship of the classes loaded by the application program is processed, and the dependency relationship between the file sets can be obtained; the dependency relationship between the nodes can be obtained according to the dependency relationship between the file sets; for example, it can be obtained that node 4: d.jar depends on node 2: a.jar and node 3: b.jar, c.jar. Figure 1b

[0103] ii. The node corresponding to the application program is sorted according to the dependency relationship between the nodes corresponding to the application program, to obtain the node set corresponding to the application program. In some embodiments, the node on which the node depends can be referred to as a dependent node, and the dependent node of the node is arranged before the node. For example, the node set corresponding to the application program shown in Table 1 is {node 1: rt.jar, node 2: a.jar, node 3: b.jar, c.jar, node 4: d.jar, node 5: d.jar}. In some embodiments, if there is no dependency relationship between the nodes, the nodes can be sorted according to the order of the class path.

[0104] ​iii. Determine the shared node set based on the node set corresponding to the application.

[0105] In some embodiments, nodes common to all applications in a set of nodes corresponding to multiple applications are designated as basic shared nodes; and / or, nodes common to at least one application in a set of nodes corresponding to multiple applications are designated as local shared nodes; and / or, nodes other than basic shared nodes and local shared nodes in a set of nodes corresponding to multiple applications are designated as ordinary nodes; a set of shared nodes is determined, which includes at least one of basic shared nodes, local shared nodes, and ordinary nodes.

[0106] Taking Java applications as an example: Basic shared nodes: These nodes do not depend on other nodes and consist of the core libraries of the Java Development Kit (JDK) and the common parts of the classpaths of all applications. If none of the classpaths contain all the elements simultaneously, the basic shared node consists only of the JDK core libraries. Local shared nodes: These are the common parts of the classpaths of two or more applications and can depend on the basic shared nodes and other local shared nodes. Ordinary nodes: These are nodes specific to each application and can depend on both basic shared nodes and local shared nodes.

[0107] In some embodiments, the shared node set is sorted in the order of basic shared nodes, local shared nodes, and ordinary nodes; wherein, the basic shared nodes are sorted according to their dependencies, and the local shared nodes are also sorted according to their dependencies.

[0108] In some embodiments, node index information is generated based on the dependencies between shared nodes in the shared node set; wherein, the node index information can be represented in the form of a list, such as... Figure 1c The diagram illustrates a node index table, representing the node index information generated by one basic shared node, two local shared nodes, and two ordinary nodes. The node index table can store node information, identifiers of dependent nodes, and information about the shared files corresponding to the nodes.

[0109] generating the shared file and the information of the shared file corresponding to the basic shared node based on the running data corresponding to the basic shared node; and / or, generating the shared file and the information of the shared file corresponding to the local shared node based on the node index information and the running data corresponding to the local shared node; and / or, generating the shared file and the information of the shared file corresponding to the ordinary node according to the node index information and the running data corresponding to the ordinary node; updating the node index information based on the information of the shared file corresponding to the basic shared node and / or the information of the shared file corresponding to the local shared node and / or the information of the shared file corresponding to the ordinary node.

[0110] The shared file can include, but is not limited to, 1) the node identifier of the node corresponding to the shared file; 2) entry information, for example, the entry information (class path entry) can include the class path, the node identifier of the dependent node, the virtual mapping address of the dependent node, the storage path and file size of the shared file of the dependent node, and the timestamp of generating the shared file; 3) a set of data types, specifically, a list (class list) formed by the class names of the classes in the file set corresponding to the node; 4) a virtual mapping address; and 5) a shared archive file, such as a Java shared archive file (JSA), which stores classes in a predetermined format.

[0111] The generating of the shared file and the information of the shared file corresponding to the local shared node based on the node index information and the running data corresponding to the local shared node can include the following steps: determining the basic shared node relied on by the local shared node according to the node index information; loading the shared file according to the information of the shared file in the node index information; and generating the shared file corresponding to the local shared node based on the shared file of the basic shared node relied on by the local shared node and the running data corresponding to the local shared node.

[0112] The generating of the shared file and the information of the shared file corresponding to the ordinary node based on the node index information and the running data corresponding to the ordinary node can include the following steps: determining the dependent node of the ordinary node, such as the local shared node relied on by the local shared node, according to the node index information; loading the shared file corresponding to the dependent node according to the information of the shared file in the node index information; and generating the shared file corresponding to the local shared node based on the shared file of the dependent node and the running data corresponding to the local shared node.

[0113] In some embodiments, the shared file can be generated according to the files in the file set under the resource path.

[0114] In some embodiments, when generating the shared file corresponding to the basic shared node, the virtual mapping address corresponding to the basic shared node can be determined, such as the starting address of the shared file generated by the file generation stage (dump); and the node index information is updated according to the virtual mapping address corresponding to the basic shared node.

[0115] When generating the shared file corresponding to the local shared node based on the node index information and the running data of the local shared node, the virtual mapping address corresponding to the basic shared node and the virtual mapping address of the local shared node of the generated shared file are obtained from the node index information. The virtual mapping address of the current local shared node is calculated according to the virtual mapping address corresponding to the basic shared node and the virtual mapping address of the local shared node of the generated shared file; and the node index information is updated based on the virtual mapping address of the current local shared node.

[0116] When generating the shared file corresponding to the ordinary node based on the node index information and the running data of the ordinary node, the virtual mapping address corresponding to the basic shared node and the virtual mapping address of the local shared node and the virtual mapping address of the ordinary node of the generated shared file are obtained from the node index information; then the virtual mapping address of the current ordinary node is calculated according to the obtained virtual address; and the node index information is updated based on the virtual mapping address of the current ordinary node. That is, a virtual mapping address not occupied by each node corresponding to the shared file is selected, so that the shared files of different nodes are mapped in different addresses.

[0117] In some embodiments, the set of information corresponding to the shared resource can be generated through the dependency relationship of the file set records corresponding to the resource paths of the plurality of application programs.

[0118] In some embodiments, when determining the set of information corresponding to the shared resource, the set of information corresponding to the resource corresponding to each application program can be determined according to the set of information corresponding to the shared resource.

[0119] In some embodiments, after obtaining the set of information corresponding to the shared resource, the node corresponding to the target application program can be determined according to the file set corresponding to the resource path and the shared node set; the information of the corresponding shared file is obtained according to the node index information, so as to obtain the target information set.

[0120] 102. Memory mapping the target shared file based on the target virtual mapping space, to obtain a mapping relationship, the target virtual mapping space being determined according to the information of the target shared file.

[0121] The mapping relationship can represent the relationship between the target virtual mapping space and the target shared file. In some embodiments, the mapping relationship can be a pointer.

[0122] The target virtual mapping space is a part of the virtual address space of the target application runtime. In some embodiments, when the target virtual mapping space is accessed based on a pointer, the shared physical space corresponding to the target virtual mapping space is actually accessed; the target virtual mapping space can be converted into the shared physical space, for example, the conversion from the target virtual mapping space to the shared physical space can be performed by using an MMU (Memory Management Unit).

[0123] In some embodiments, the information of the target shared file includes a target virtual mapping address, a file size of the target shared file, and a storage address of the target shared file, etc. The target virtual mapping space is determined according to the target virtual mapping address and the file size of the target shared file.

[0124] The target shared file is memory mapped based on the target virtual mapping space, when the memory mapping fails, a new virtual mapping address is determined in the virtual address space, which is the virtual address space corresponding to the target application runtime; the target shared file is memory remapped based on the new virtual mapping space, the new virtual mapping space corresponds to the new virtual mapping address; when the memory remapping succeeds, the target virtual mapping address in the target information set is updated to the new virtual mapping address.

[0125] For example, the specific manner of the memory mapping can be to call the mmap function, to correspond the target shared file to the virtual mapping space from the start address, to return a pointer to the process corresponding to the application after the memory mapping succeeds, and to set to a shareable mode, that is, the shared physical space corresponding to the virtual mapping space can be shared with the processes of other applications. When the memory mapping fails, a sufficient free memory in the virtual address space is selected as a new virtual mapping space, and the memory remapping is performed. After the remapping succeeds, the internal pointer needs to be updated (relocation), and it is marked that the virtual mapping address of the target shared node has changed, and the new virtual mapping address is recorded; when the memory remapping is performed, it is set to an unshareable mode, and the shared physical space corresponding to the new virtual mapping space cannot be shared with the processes corresponding to other applications.

[0126] In some embodiments, if the memory remapping still fails, the target shared file is no longer used, and the class corresponding to the target shared node is read from the original file set by the process corresponding to the application; meanwhile, it is marked that the node is invalid, and when the shared file corresponding to a subsequent node is loaded, if the subsequent node depends on the node, the subsequent node is directly abandoned. If the target shared node has a dependent node, and the virtual mapping address of the dependent node has changed, the pointer in the node needs to be updated (relocation).

[0127] In some embodiments, the target shared file is a shared file corresponding to the target shared node, and the electronic device further performs the following steps before loading the target shared file: obtaining node index information; determining a node (a dependent node) relied on by the target shared node based on the node index information; and performing memory mapping on a shared file corresponding to the node relied on by the target shared node.

[0128] In some embodiments, the electronic device can load the corresponding shared file according to the order of the shared nodes in the target information set.

[0129] 103、In response to an access request of the target application program to access the target data, the shared physical space corresponding to the target virtual mapping space is accessed based on the mapping relationship; when the access to the shared physical space corresponding to the target virtual mapping space succeeds, the target data in the target shared file in the shared physical space is obtained; when the access to the shared physical space corresponding to the target virtual mapping space fails, the target virtual space is converted into a shared physical space in the memory, and the data in the target shared file is loaded into the shared physical space, and the target data in the target shared file in the shared physical space is obtained.

[0130] The access request can be a request generated by a process of the application program in response to a user operation on a user interface of the application program, or can be a request automatically generated by the process of the application program when the application program is running.

[0131] The target data can be any data stored in the shared file, for example, the target data can be a class.

[0132] In some embodiments, when the access request of the target application program to access the target data is received, the virtual mapping space is accessed according to the pointer obtained when the memory mapping is performed; if the target application program is accessing the virtual mapping space for the first time, at this time, the shared physical space corresponding to the target virtual mapping space does not exist in the memory, therefore, the virtual space is converted into a shared physical space in the memory, and the data in the target shared file is loaded into the shared physical space, and then the shared file in the shared physical space can be operated by using the pointer. If the shared physical space exists in the memory before the target application program accesses the virtual mapping space, it is possible that the target shared file has been loaded into the shared physical space by other application programs, and the target application program can reuse the shared physical space and share the shared file in the shared physical space with other application programs. Therefore, the file can be quickly loaded, and the running speed of the application program is improved; and when multiple application programs load the same file, a memory physical space is not opened for each application program to load the shared file, memory resources are saved, and resource consumption is reduced.

[0133] In some embodiments, the target information set includes a data type set corresponding to the target shared file. The preset global data type set is updated according to the data type set in the target shared file; when the electronic device acquires target data in the target shared file in the shared physical space, the data type corresponding to the target data can be searched in the global data type set; and the target data is acquired from the shared physical space according to the data type corresponding to the target data. In some embodiments, when the electronic device accesses the target data in the target shared file in the shared physical space, the data type corresponding to the target data can be directly searched from the data type set in the target shared file. The data type can be a class name.

[0134] As can be seen from the above, the present application takes a single file or a plurality of file sets as a granularity, divides the file set corresponding to the resource path into a plurality of shared nodes, each shared node generates a corresponding shared file, and an application program can access data from a plurality of shared files, which is very flexible. Moreover, a corresponding virtual mapping space is determined; when a shared file is loaded by a target application program before the shared file is loaded by an application program, the shared physical space corresponding to the virtual mapping space exists in the memory, and data in the shared file in the shared physical space can be accessed; if no application program loads the shared file into the memory before the target application program loads the shared file, the virtual mapping address needs to be converted into the shared physical space, and the shared file needs to be loaded into the shared physical space; thus, the present application can improve the running speed of the application program and reduce resource consumption.

[0135] According to the method described in the above embodiments, the following will be further described in detail.

[0136] The file sharing scheme provided by the present application can be applied in big data platforms, serverless, and the like. In the file sharing scheme, the following is provided.

[0137] Different application programs in a serverless scenario are deployed on the same electronic device, different application programs are constructed by the same basic jar package and independent business jar packages, and the file sharing scheme can further save resource consumption of business on the cloud.

[0138] In a big data platform scenario, for example, a big data processing center based on Hadoop. Hadoop itself is a distributed basic framework, including HDFS (Hadoop Distribute File System), YARN (Yet Another Resource Negotiator), and MapReduce (Map and Reduce), three main parts. HDFS is responsible for storage, YARN is responsible for resource scheduling, and MapReduce is responsible for the actual calculation part. MapReduce contains several calculation processes. In actual use, the Map task and the Reduce task use the same Java application, which performs different calculations according to different calls, and a large number of repeated occurrences. In the actual production environment, the class path of these Java processes has partial consistency, but different tasks use different jar packages; at the same time, the use of different versions also leads to the use of different jar packages. Taking Hibench (a big data benchmarking tool) as an example, different tasks use jar packages, as shown in Figure 2a The file sharing scheme proposed by the scheme can improve the running efficiency of the big data platform and save system resources.

[0139] In this embodiment, the Java application will be taken as an example to illustrate the method of the present application in detail. It is assumed that four application programs are installed on the electronic device, and the application programs are all developed by using the Java programming language and development platform, and each application program corresponds to a process when running. Each application program corresponds to a JVM (Java Virtual Machine) instance, which is JVM instance 1, JVM instance 2, JVM instance 3, and JVM instance 4, respectively. As shown in Figure 2b The schematic diagram of the class path corresponding to the multiple application programs is shown in

[0140] As shown in Figure 2c The specific process of the file sharing method is as follows:

[0141] 201, collect the information of the running data accessed by the application program when running.

[0142] The information of the running data includes: class names of classes loaded by each application during running; jar packages to which each class belongs; dependency relationships of each class, i.e., information of classes depended by each class, the information of classes depended by each class can include interface and parent class information, the information includes class names and information of the belonging jar packages; information of all jar packages of the class path corresponding to the current application. In some embodiments, the information of the running data of all applications of the electronic device during running is collected.

[0143] 202. Determine the shared node set according to the information of the running data accessed by the application during running.

[0144] 1) Convert the jar package to which the class belongs into the node corresponding to the application;

[0145] 2) Generate the dependency tree corresponding to the node according to the dependency relationship of the class loaded by the application during running.

[0146] 3) Determine whether there is a class with the same name between the jar packages corresponding to any two nodes according to the class name and namespace of the loaded class, if there is, merge the two nodes into one node. As shown in the following table, it is assumed that a.jar and c.jar have the same class name, and a.jar and c.jar are taken as one node. The shared node includes node information, and the node information can be specifically: node unique identifier; jar package list; node information of dependent nodes; corresponding class list; information of shared files: start address of memory mapping, file size. Figure 2b

[0147] 4) Generate the corresponding node set according to the dependency tree between the nodes, if there is no dependency relationship between the nodes, sort according to the preset order, and the preset order is determined according to the class path.

[0148] In some embodiments, the node sets corresponding to four applications are generated according to the above steps.

[0149] ​The shared nodes {rt.jar, b.jar, a.jar, c.jar} common to all applications in the node set corresponding to the plurality of applications are taken as the basic shared nodes, the shared nodes {d.jar}, {e.jar} common to at least one application in the node set corresponding to the plurality of applications are taken as the local shared nodes, and the shared nodes {f1.jar}, {f2.jar}, {f3.jar}, {f4.jar} other than the basic shared nodes and the local shared nodes in the node set corresponding to the plurality of applications are taken as the common nodes; all the nodes together form a shared node set. The order of the nodes in the shared set is arranged according to the node dependency relationship, and if there is no dependency relationship, the original class path order is arranged.

[0150] 203. Generating node index information according to the node information of the nodes in the shared node set.

[0151] The dependency relationship between the nodes is determined according to the dependency relationship of the classes corresponding to the nodes. The node index information is generated based on the node information of the nodes and the dependency relationship between the nodes.

[0152] 204. Generating a shared file for each shared node in the shared node set according to the node index information and the shared node set.

[0153] The shared file (Enhanced Java Shared Archive, EJSA) can include but is not limited to: 1) the node identifier of the node corresponding to the shared file; 2) the entry information of the class path, the node identifier of the dependent node, the virtual mapping address of the dependent node, the storage path and file size of the shared file of the dependent node, and the timestamp of generating the shared file; 3) the class list, the list formed by the class name of the class in the file set corresponding to the node; 4) the virtual mapping address; 5) the Java shared archive file.

[0154] i. Generating a shared file for the basic shared node, the dump process is the same as the standard JSA generation process; after the dump is completed, the starting address (virtual mapping address) of the dump and the information of the shared file are recorded, and the node information of the basic shared node in the node index information is updated;

[0155] ii. Generating a shared file for the local shared node and the common node:

[0156] a) According to the node identifier of the dependent node in the node information, the information of the shared file corresponding to the node of the generated shared file is obtained from the node index information, and the corresponding shared file is loaded according to the information of the shared file.

[0157] b) Calculating the starting address of the current node dump:

[0158] According to the node information of the base shared node and the generated local shared node, the starting address of the current local shared node is calculated; the purpose is to allow different local shared nodes to perform memory mapping at different addresses;

[0159] For a normal node, according to the base node and the node information of the dependent local shared node, the starting address of the current normal node is calculated;

[0160] c) According to the class list corresponding to the node, the corresponding class is loaded; during the loading process, non-class list classes are not allowed to be loaded, such as directly throwing an exception and skipping the current class loading process; after all the class loading is completed, a new shared file is generated;

[0161] d) After the dump is completed, the node index information is updated according to the node information.

[0162] 205、When it is detected that the target application program is started, a target information set is obtained, the target information set including information of a target shared file, the information of the target shared file including a virtual mapping address and a file size of the target shared file.

[0163] The class path corresponding to the target application program is converted into a node set composed of nodes according to the shared node set. There are two conversion methods: a) The class path is pre-processed before the target application program is started; b) The class path is dynamically converted after the target application program is started. The converted class path becomes: the form of the base shared node, the local shared node, and the normal node, as shown in the following table: Figure 2d The target shared node is any node in the node set corresponding to the target application program.

[0164] After the target application program is started, the node information of each node in the node set corresponding to the target application program is loaded into the memory.

[0165] In some embodiments, a global class loading list is initialized.

[0166] 206, based on the target virtual mapping space, the target shared file is memory mapped to obtain a mapping relationship, the target virtual mapping space is determined according to the information of the target shared file.

[0167] In some embodiments, the corresponding shared file can be loaded according to the order of the nodes in the node set corresponding to the target application program:

[0168] The target shared node corresponds to a target shared file. The electronic device can call the mmap function to correspond the target shared file to a virtual mapping space starting from a start address, return a pointer to the process corresponding to the application after successful memory mapping, and set the shared physical space corresponding to the virtual mapping space to a sharable mode.

[0169] When the memory mapping fails, a sufficient free memory in the virtual address space is selected as a new virtual mapping space for memory remapping. After successful remapping, the internal pointer needs to be updated (relocation), and the virtual mapping address of the target shared node is marked as changed, and the new virtual mapping address is recorded. When the memory is remapped, it is set to an unshareable mode, and the shared physical space corresponding to the new virtual mapping space cannot be shared with the processes corresponding to other applications.

[0170] If the memory remapping still fails, the target shared file is no longer used, and the process corresponding to the application reads the class corresponding to the target shared node from the original jar package; at the same time, the node is marked as invalid, and when loading the shared file corresponding to the subsequent node, if the subsequent node depends on the node, the subsequent node is directly abandoned.

[0171] If the target shared node has a dependent node, and the virtual mapping address of the dependent node changes, the pointer in the dependent node needs to be updated (relocation) to point to the new virtual mapping address.

[0172] When loading the shared file corresponding to the node, the class list corresponding to the node can be updated to the global class list.

[0173] 207、In response to an access request of a target application to access target data, a shared physical space corresponding to a target virtual mapping space is accessed based on a mapping relationship; when the shared physical space corresponding to the target virtual mapping space is accessed successfully, the target data in the target shared file in the shared physical space is obtained; when the shared physical space corresponding to the target virtual mapping space fails to be accessed, the target virtual space is converted into a shared physical space in memory, and data in the target shared file is loaded into the shared physical space, and the target data in the target shared file in the shared physical space is obtained.

[0174] In some embodiments, the target information set includes a class list corresponding to the target shared file. The preset global class loading list is updated according to the class list in the target shared file. When the electronic device acquires a target class in the target shared file in the shared physical space, the electronic device can search for a class name corresponding to the target class in the global class loading list. The class corresponding to the class name is acquired from the shared physical space. In some embodiments, when the electronic device accesses the target class in the target shared file in the shared physical space, the electronic device can directly search for a class name corresponding to the target class from the class list in the target shared file.

[0175] In some embodiments, when the electronic device accesses the class in the shared physical space, the electronic device can search for the class in the global class list. A corresponding class object is created in the shared physical space according to the class.

[0176] As can be seen from the above, the present application divides the class path corresponding to the jar package into a plurality of shared nodes with a single jar package or a plurality of jar packages as a granularity. Each shared node generates a corresponding shared file. The application program can load the class from the plurality of shared files, which is very flexible. Moreover, a corresponding virtual mapping space is determined for each shared file. When the target application program loads the shared file, the shared file has been loaded by an application program. The shared physical space corresponding to the virtual mapping space exists in the memory, so that the class in the shared file in the shared physical space can be accessed. If no application program loads the shared file into the memory before the target application program loads the shared file, the virtual mapping address needs to be converted into the shared physical space, and the shared file needs to be loaded into the shared physical space. Thus, the present application can improve the running speed of the application program. Moreover, a plurality of application programs can share the shared file in the same shared physical space, thereby reducing resource consumption.

[0177] In order to better implement the above method, the present application further provides a file sharing device. The file sharing device can be integrated in an electronic device, which can be a terminal, a server, or the like. The terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a notebook computer, a personal computer, or the like. The server can be a single server or a server cluster composed of a plurality of servers.

[0178] For example, in the present embodiment, the file sharing device is integrated in an electronic device, and the method of the present application is described in detail.

[0179] For example, as shown in FIG. 3, the file sharing device can include an acquisition unit 301, a mapping unit 302, and a response unit 303. Figure 3

[0180] (I) The acquisition unit 301:

[0181] ​The acquisition unit 301 is used to acquire a target information set when the target application is detected to start. The target information set is a set of information corresponding to the resources of the target application, and the target information set includes information about the target shared file.

[0182] (ii) Mapping unit 302:

[0183] The mapping unit 302 is used to perform memory mapping on the target shared file based on the target virtual mapping space to obtain the mapping relationship. The target virtual mapping space is determined based on the information of the target shared file.

[0184] (III) Response Unit 303:

[0185] The response unit 303 is used to respond to the access request of the target application to access the target data, and access the shared physical space corresponding to the target virtual mapping space based on the mapping relationship. When the access to the shared physical space corresponding to the target virtual mapping space is successful, the target data in the target shared file in the shared physical space is obtained; when the access to the shared physical space corresponding to the target virtual mapping space fails, the target virtual space is converted into a shared physical space in memory, and the data in the target shared file is loaded into the shared physical space, and the target data in the target shared file in the shared physical space is obtained.

[0186] In some embodiments, the file-sharing device is further configured to:

[0187] Obtain information about runtime data accessed by multiple applications at runtime, including the target application;

[0188] The set of information corresponding to shared resources is determined based on the runtime data accessed by the application at runtime.

[0189] Obtain the target information set, including:

[0190] Obtain the resource path of the target application;

[0191] The target information set is determined based on the resource paths of the target application and the set of information corresponding to the shared resources.

[0192] In some embodiments, the information of the application's runtime data includes the dependencies between runtime data and the set of files to which the runtime data belongs. The set of information corresponding to the shared resources includes a set of shared nodes. The file sharing device is specifically used for:

[0193] Convert the set of files containing the runtime data into nodes corresponding to the application;

[0194] The set of shared nodes is determined based on the dependencies between runtime data and the nodes corresponding to the application.

[0195] In some embodiments, the file sharing device is specifically configured to:

[0196] determine the dependency relationship between the nodes corresponding to the application programs according to the dependency relationship between the running data;

[0197] sort the nodes corresponding to the application programs according to the dependency relationship between the nodes corresponding to the application programs, to obtain a node set corresponding to the application programs;

[0198] determine a shared node set based on the node set corresponding to the application programs.

[0199] In some embodiments, the file sharing device is specifically configured to:

[0200] take the nodes common to all the application programs in the node sets corresponding to the multiple application programs as basic shared nodes; and / or,

[0201] take the nodes common to at least one of the application programs in the node sets corresponding to the multiple application programs as local shared nodes; and / or,

[0202] take the nodes other than the basic shared nodes and the local shared nodes in the node sets corresponding to the multiple application programs as common nodes;

[0203] determine a shared node set, the shared node set including at least one of the basic shared nodes, the local shared nodes and the common nodes.

[0204] In some embodiments, the file sharing device is specifically configured to:

[0205] generate node index information according to the dependency relationship between the shared nodes in the shared node set;

[0206] generate shared files corresponding to the basic shared nodes and information of the shared files based on the running data corresponding to the basic shared nodes; and / or,

[0207] generate shared files corresponding to the local shared nodes and information of the shared files based on the node index information and the running data corresponding to the local shared nodes; and / or,

[0208] generate shared files corresponding to the common nodes and information of the shared files according to the node index information and the running data corresponding to the common nodes;

[0209] update the node index information based on the information of the shared files corresponding to the basic shared nodes and / or the information of the shared files corresponding to the local shared nodes and / or the information of the shared files corresponding to the common nodes.

[0210] In some embodiments, the file sharing device is specifically configured to:

[0211] determine the base shared node relied by the local shared node according to the node index information;

[0212] generate the shared file corresponding to the local shared node based on the shared file of the base shared node relied by the local shared node and the running data corresponding to the local shared node.

[0213] In some embodiments, the file sharing device is specifically used for:

[0214] determine the virtual mapping address corresponding to the base shared node;

[0215] update the node index information according to the virtual mapping address corresponding to the base shared node;

[0216] generate the shared file corresponding to the local shared node based on the node index information and the running data corresponding to the local shared node, and further comprising:

[0217] obtain the virtual mapping address corresponding to the base shared node and the virtual mapping address of the local shared node of the generated shared file from the node index information;

[0218] calculate the virtual mapping address of the current local shared node according to the virtual mapping address corresponding to the base shared node and the virtual mapping address of the local shared node of the generated shared file;

[0219] update the node index information based on the virtual mapping address of the current local shared node.

[0220] In some embodiments, the file sharing device is specifically used for:

[0221] determine the file set containing the same data type from the file set to which the running data belongs;

[0222] regard the file set containing the same data type as a node.

[0223] In some embodiments, the target information set includes a data type set in the target shared file, and the file sharing device is further used for:

[0224] update the preset global data type set according to the data type set in the target shared file;

[0225] obtain target data in the target shared file in the shared physical space, comprising:

[0226] find the data type corresponding to the target data in the global data type set;

[0227] obtain the target data from the shared physical space according to the data type corresponding to the target data.

[0228] In some embodiments, the file sharing device is further used for:

[0229] When the memory mapping fails, a new virtual mapping address is determined in a virtual address space corresponding to a runtime of the target application;

[0230] Based on the new virtual mapping space, the target shared file is subjected to memory remapping, and the new virtual mapping space corresponds to the new virtual mapping address;

[0231] When the memory remapping succeeds, the target virtual mapping address in the target information set is updated to the new virtual mapping address.

[0232] In some embodiments, the target shared file is a shared file corresponding to the target shared node, and the file sharing apparatus is further configured to:

[0233] Obtain node index information;

[0234] Based on the node index information, determine a node relied on by the target shared node;

[0235] Map a shared file corresponding to the node relied on by the target shared node.

[0236] In implementation, the above various units can be implemented as independent entities, or can be combined as the same or several entities, and the specific implementation of the above various units can be referred to the method embodiments above, which will not be described here.

[0237] As can be seen from the above, the file sharing apparatus of the present embodiment can generate shared files of multiple application programs and determine corresponding virtual mapping spaces by obtaining information of running data accessed by the multiple application programs when running. When a target application program is started, the shared files are mapped based on the virtual mapping spaces, so that the shared files correspond to the virtual mapping spaces. Then, in response to an access request of the target application program for accessing target data, the target data in the shared files is accessed. If the shared files have been loaded by an application program before the target application program loads the shared files, a shared physical space corresponding to the virtual mapping space exists in the memory, so that the data in the shared files in the shared physical space can be accessed. If no application program loads the shared files into the memory before the target application program loads the shared files, the virtual mapping address needs to be converted into a shared physical space, and the shared files need to be loaded into the shared physical space. Thus, multiple application programs can share the shared files in the same shared physical space, and resource consumption is reduced.

[0238] The application also provides an electronic device, which can be a terminal, a server, etc. The terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a notebook computer, a personal computer, etc. The server can be a single server or a server cluster composed of multiple servers, etc.

[0239] In some embodiments, the file sharing device can also be integrated in multiple electronic devices, for example, the file sharing device can be integrated in multiple servers to implement the file sharing method of the application.

[0240] In this embodiment, the electronic device of this embodiment will be taken as an example for detailed description, for example, as shown in Figure 4 The electronic device of the application is shown in the structure diagram, specifically:

[0241] The electronic device can include a processor 401 with one or more processing cores, a memory 402 with one or more computer readable storage media, a power supply 403, an input module 404, a communication module 405, etc. Those skilled in the art can understand that Figure 4 The structure of the electronic device shown in the figure does not constitute a limitation on the electronic device, and can include more or fewer components than the figure, or combine certain components, or different component arrangements. Among them:

[0242] The processor 401 is the control center of the electronic device, which connects all parts of the electronic device through various interfaces and lines, executes the software programs and / or modules stored in the memory 402 and calls the data stored in the memory 402, executes various functions of the electronic device and processes data, and thus overall detects the electronic device. In some embodiments, the processor 401 can include one or more processing cores; in some embodiments, the processor 401 can integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface and application program, etc., and the modem processor mainly processes wireless communication. It can be understood that the above-mentioned modem processor can also not be integrated into the processor 401.

[0243] The memory 402 can be used to store software programs and modules, and the processor 401 can execute various function applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, application programs required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; and the data storage area can store data created according to the use of the electronic device, etc. In addition, the memory 402 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state memory device. Accordingly, the memory 402 can also include a memory controller to provide the processor 401 with access to the memory 402.

[0244] The electronic device also includes a power supply 403 for powering the various components, and in some embodiments, the power supply 403 can be logically connected to the processor 401 through a power management system, so that the power management system can be used to manage charging, discharging, and power consumption management, etc. The power supply 403 can also include one or more direct current or alternating current power supplies, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and the like.

[0245] The electronic device can also include an input module 404, which can be used to receive input digital or character information, and to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.

[0246] The electronic device can also include a communication module 405, which in some embodiments can include a wireless module, and the electronic device can use the wireless module of the communication module 405 for short-range wireless transmission, thereby providing the user with wireless broadband Internet access. For example, the communication module 405 can be used to help the user send and receive emails, browse web pages, and access streaming media, etc.

[0247] Although not shown, the electronic device can also include a display unit, etc., which will not be described here. In particular, in the present embodiment, the processor 401 in the electronic device will load one or more executable files corresponding to the processes of the application programs into the memory 402 according to the following instructions, and the processor 401 will run the application programs stored in the memory 402, thereby implementing various functions, as follows:

[0248] When it is detected that the target application program is started, a target information set is obtained, the target information set being a set of information corresponding to resources of the target application program, and the target information set including information of a target shared file;

[0249] mapping relationship is obtained by mapping the target shared file based on a target virtual mapping space, the target virtual mapping space being determined according to information of the target shared file;

[0250] In response to an access request of the target application program to access the target data, the shared physical space corresponding to the target virtual mapping space is accessed based on the mapping relationship;

[0251] When the access to the shared physical space corresponding to the target virtual mapping space succeeds, the target data in the target shared file in the shared physical space is obtained.

[0252] When the access to the shared physical space corresponding to the target virtual mapping space fails, the target virtual space is converted into the shared physical space in the memory, and the data in the target shared file is loaded into the shared physical space, so that the target data in the target shared file in the shared physical space is obtained.

[0253] The specific implementation of each operation can be referred to the foregoing embodiments, which will not be described here.

[0254] As can be seen from the above, the electronic device can generate shared files of multiple application programs and determine corresponding virtual mapping spaces by obtaining information of running data accessed by the multiple application programs when running. When a target application program is started, the shared files are mapped based on the virtual mapping spaces, so that the shared files correspond to the virtual mapping spaces. Then, in response to an access request of the target application program to access target data, the target data in the shared files is accessed. If the shared files have been loaded by an application program before the target application program loads the shared files, the shared physical space corresponding to the virtual mapping space exists in the memory, so that the data in the shared files in the shared physical space can be accessed. If no application program loads the shared files into the memory before the target application program loads the shared files, the virtual mapping address needs to be converted into the shared physical space, and the shared files need to be loaded into the shared physical space. Thus, multiple application programs can share the shared files in the same shared physical space, and resource consumption is reduced.

[0255] Those skilled in the art can understand that all or part of the steps in the various methods of the foregoing embodiments can be completed by instructions, or by instructions controlling related hardware, the instructions can be stored in a computer readable storage medium and loaded and executed by a processor.

[0256] Therefore, the present application provides a computer readable storage medium, which stores a plurality of instructions capable of being loaded by a processor to execute steps in any file sharing method provided by the present application. For example, the instructions can execute the following steps:

[0257] When it is detected that the target application is started, a target information set is acquired, the target information set being a set of information corresponding to resources of the target application, and the target information set including information of the target shared file;

[0258] The target shared file is memory mapped based on a target virtual mapping space, to obtain a mapping relationship, the target virtual mapping space being determined according to the information of the target shared file;

[0259] In response to an access request of the target application to the target data, the shared physical space corresponding to the target virtual mapping space is accessed based on the mapping relationship;

[0260] When the access to the shared physical space corresponding to the target virtual mapping space succeeds, the target data in the target shared file in the shared physical space is acquired;

[0261] When the access to the shared physical space corresponding to the target virtual mapping space fails, the target virtual space is converted into a shared physical space in memory, and the data in the target shared file is loaded into the shared physical space, to acquire the target data in the target shared file in the shared physical space.

[0262] The storage medium can include a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0263] According to an aspect of the present application, a computer program product or computer program is provided, which includes computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method provided in any of the various optional implementation manners of the big data platform aspect or the micro-service aspect provided in the above embodiments.

[0264] Due to the instructions stored in the storage medium, the steps in any of the file sharing methods provided in the present application can be executed, and thus the beneficial effects of any of the file sharing methods provided in the present application can be achieved. Details are described in the above embodiments, and thus will not be described here again.

[0265] The above describes in detail the file sharing method, device, electronic equipment and computer readable storage medium provided by the present application. The principles and implementation modes of the present application are described by applying specific examples. The above example is only used to help understand the method and core idea of the present application. Meanwhile, for those skilled in the art, the specific implementation modes and application ranges will be changed according to the idea of the present application. In conclusion, the content of the specification should not be understood as a limitation of the present application.

Claims

1. A file sharing method characterized by, The method comprises the following steps: when a target application is detected to be started, a target information set is acquired, the target information set being a set of information corresponding to resources of the target application, and the target information set including information of a target shared file; a memory mapping is performed on the target shared file based on a target virtual mapping space, to obtain a mapping relationship, the target virtual mapping space being determined according to the information of the target shared file; in response to an access request of the target application for accessing target data, a shared physical space corresponding to the target virtual mapping space is accessed based on the mapping relationship; when the access to the shared physical space corresponding to the target virtual mapping space is successful, target data in the target shared file in the shared physical space is acquired; when the access to the shared physical space corresponding to the target virtual mapping space fails, the target virtual mapping space is converted into a shared physical space in memory, data in the target shared file is loaded into the shared physical space, and target data in the target shared file in the shared physical space is acquired.

2. The file sharing method of claim 1, wherein, Before the step of acquiring the target information set, the method further comprises the following steps: information of running data accessed by a plurality of applications in a running state is acquired, the plurality of applications including a target application; a set of information corresponding to shared resources is determined according to the information of the running data accessed by the applications in the running state; the step of acquiring the target information set comprises the following steps: a resource path of the target application is acquired; the target information set is determined according to the resource path of the target application and the set of information corresponding to the shared resources.

3. The file sharing method of claim 2, wherein, The information of the running data of the applications includes dependency relationships between the running data and a file set to which the running data belong, the set of information corresponding to the shared resources includes a shared node set, and the step of determining the set of information corresponding to the shared resources according to the information of the running data accessed by the applications in the running state comprises the following steps: the file set to which the running data belong is converted into nodes corresponding to the applications; the shared node set is determined based on the dependency relationships between the running data and the nodes corresponding to the applications.

4. The file sharing method of claim 3, wherein, The step of determining the shared node set based on the dependency relationships between the running data and the nodes corresponding to the applications comprises the following steps: dependency relationships between the nodes corresponding to the applications are determined according to the dependency relationships between the running data; the nodes corresponding to the applications are sorted according to the dependency relationships between the nodes corresponding to the applications, to obtain a node set corresponding to the applications; the shared node set is determined based on the node set corresponding to the applications.

5. The file sharing method of claim 4, wherein, The step of determining the shared node set based on the node set corresponding to the applications comprises the following steps: nodes common to all the applications in the node set corresponding to the plurality of applications are taken as basic shared nodes; and / or, nodes common to at least one application in the node set corresponding to the plurality of applications are taken as local shared nodes; and / or, The nodes in the node set corresponding to the plurality of application programs, except the basic shared node and the local shared node, are regarded as common nodes; The shared node set is determined, and the shared node set includes at least one of the basic shared node, the local shared node and the common node.

6. The file sharing method of claim 5, wherein, The node index information of the shared node set is included in the information set corresponding to the shared resource, and the method further includes: The node index information is generated according to the dependency relationship between the shared nodes in the shared node set; The shared file corresponding to the basic shared node and the information of the shared file are generated based on the running data corresponding to the basic shared node; and / or, The shared file corresponding to the local shared node and the information of the shared file are generated based on the node index information and the running data corresponding to the local shared node; and / or, The shared file corresponding to the common node and the information of the shared file are generated according to the node index information and the running data corresponding to the common node; The node index information is updated based on the information of the shared file corresponding to the basic shared node and / or the information of the shared file corresponding to the local shared node and / or the information of the shared file corresponding to the common node.

7. The file sharing method of claim 6, wherein, The shared file corresponding to the local shared node is generated based on the node index information and the running data corresponding to the local shared node, and includes: The basic shared node depended on by the local shared node is determined according to the node index information; The shared file corresponding to the local shared node is generated based on the shared file of the basic shared node depended on by the local shared node and the running data corresponding to the local shared node.

8. The file sharing method of claim 6, wherein, The shared file corresponding to the basic shared node is generated based on the running data corresponding to the basic shared node, and further includes: The virtual mapping address corresponding to the basic shared node is determined; The node index information is updated according to the virtual mapping address corresponding to the basic shared node. The shared file corresponding to the local shared node is generated based on the node index information and the running data corresponding to the local shared node, and further includes: The virtual mapping address corresponding to the basic shared node and the virtual mapping address of the local shared node of the generated shared file are obtained from the node index information; The virtual mapping address of the current local shared node is calculated according to the virtual mapping address corresponding to the basic shared node and the virtual mapping address of the local shared node of the generated shared file; The node index information is updated based on the virtual mapping address of the current local shared node.

9. The file sharing method of claim 3, wherein, The file set to which the running data belongs is converted into the node corresponding to the application program, and includes: A file set containing the same data type is determined from the file set to which the running data belongs; The file set containing the same data type is regarded as a node.

10. The file sharing method of any one of claims 1-8, wherein, The data type set in the target shared file is included in the target information set, and the data in the target shared file is loaded into the shared physical space, and further includes: The preset global data type set is updated according to the data type set in the target shared file; The data type set in the target shared file is included in the target information set, and the data in the target shared file is loaded into the shared physical space, and further includes: The preset global data type set is updated according to the data type set in the target shared file; The obtaining of the target data in the target shared file in the shared physical space comprises: searching for a data type corresponding to the target data in the global data type set; obtaining the target data from the shared physical space according to the data type corresponding to the target data.

11. The file sharing method of any one of claims 1-8, wherein, The information of the target shared file comprises a target virtual mapping address, and after the memory mapping of the target shared file based on the target virtual mapping space, the target shared file further comprises: when the memory mapping fails, determining a new virtual mapping address in a virtual address space corresponding to the target application program when running; based on a new virtual mapping space, performing memory remapping on the target shared file, the new virtual mapping space corresponding to the new virtual mapping address; when the memory remapping succeeds, updating the target virtual mapping address in the target information set to the new virtual mapping address.

12. The file sharing method of any one of claims 1-8, wherein, The target shared file is a shared file corresponding to a target shared node, and before the memory mapping of the target shared file based on the target virtual mapping space, the method further comprises: obtaining node index information; based on the node index information, determining nodes relied on by the target shared node; performing memory mapping on shared files corresponding to the nodes relied on by the target shared node.

13. A file sharing apparatus characterized by comprising: Comprise: an acquisition unit, configured to acquire a target information set when detecting that a target application program is started, the target information set being a set of information corresponding to resources of the target application program, the target information set comprising information of a target shared file and a target virtual mapping address; a mapping unit, configured to perform memory mapping on the target shared file based on a target virtual mapping space to obtain a mapping relationship, the target virtual mapping space being determined according to the information of the target shared file and the target virtual mapping address; a response unit, configured to, in response to an access request of the target application program accessing target data, access a shared physical space corresponding to the target virtual mapping space based on the mapping relationship; when accessing the shared physical space corresponding to the target virtual mapping space succeeds, obtain the target data in the target shared file in the shared physical space; when accessing the shared physical space corresponding to the target virtual mapping space fails, convert the target virtual mapping space into a shared physical space in memory, load data in the target shared file into the shared physical space, and obtain the target data in the target shared file in the shared physical space.

14. An electronic device, comprising: comprise a processor and a memory, the memory storing a plurality of instructions; the processor loads the instructions from the memory to perform the steps in the file sharing method of any one of claims 1-12.

15. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a plurality of instructions, the instructions being adapted to be loaded by a processor to perform the steps in the file sharing method of any one of claims 1-12.

16. A computer program product, characterised in that, The computer program product comprises computer instructions stored in a computer readable storage medium; a processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes the steps in the file sharing method in any one of claims 1-12.

Citation Information

Patent Citations

  • File access method, device and storage system

    CN105579977A

  • File access method and apparatus, and storage system

    CN105580010A