CN108170489A - A kind of method and device of quick loading resource - Google Patents

A kind of method and device of quick loading resource Download PDF

Info

Publication number
CN108170489A
CN108170489A CN201611115565.XA CN201611115565A CN108170489A CN 108170489 A CN108170489 A CN 108170489A CN 201611115565 A CN201611115565 A CN 201611115565A CN 108170489 A CN108170489 A CN 108170489A
Authority
CN
China
Prior art keywords
resource
data
storage region
loaded
chained list
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201611115565.XA
Other languages
Chinese (zh)
Inventor
张悦
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shanghai Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201611115565.XA priority Critical patent/CN108170489A/en
Publication of CN108170489A publication Critical patent/CN108170489A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading

Abstract

The present invention discloses a kind of method and device of quick loading resource, the method in advance parses scheduled each resource, and each resource data that gained will be parsed, and the correspondence between each resource data and the index information of corresponding resource is stored to the first storage region, on this basis, when carrying out resource loading, by the index information for obtaining resource to be loaded, and whether include the corresponding resource data of resource to be loaded using the index information as according to determining first storage region, comprising when directly read the resource data and be written into resource loading process predistribution the second storage region, resource loading can be realized.The present invention program, for can the first storage region hit completed parsing resource data, directly it is copied to the region of resource loading process predistribution, the reading and parsing of vast resources file are carried out when avoiding loading resource every time, resource loading cost is reduced, improves resource loading velocity.

Description

A kind of method and device of quick loading resource
Technical field
The invention belongs to resource loading technique field more particularly to a kind of method and devices of quick loading resource.
Background technology
When an application need to be used so as to start it, need to start resource loading process first to load the application Resource data, in the prior art, resource loading process first by specified directory read in resource file (be usually with binary shape Formula is directly read), memory is then pre-allocated, finally performs analytical function, the resource data in file is resolved in distribution In depositing, and the resource data in memory is managed by the respective data structures of construction.
For large size is applied, a large amount of resource data need to be loaded when starting application, by taking massively multiplayer game as an example, by More in its game function, the various resource datas such as map resource, resource of skills so as to load are also compared with horn of plenty, this is undoubtedly The cost that resource file is read and parsed in resource loading procedure can be caused higher, if desired for the more magnetic disc i/o of consumption (Input/Output, input/output) and CPU (Central Processing Unit, central processing unit) resource etc., together When also so that resource loading procedure takes longer, the startup time for eventually leading to application is longer, this is to outer net operation or inside All it is very unfavorable for exploitation.
Invention content
In view of this, the embodiment of the present invention is designed to provide a kind of method and device of quick loading resource, so that The above problem of the existing technology is solved less, is reduced resource loading cost, is promoted resource loading velocity.
What the scheme of the embodiment of the present invention was realized in:
A kind of method of quick loading resource of the embodiment of the present invention, the method includes:
Obtain the corresponding index information of resource to be loaded;
According to the index information of the resource to be loaded, whether determine in the first storage region comprising the resource to be loaded Corresponding resource data;Wherein, it is previously stored in first storage region obtained by being parsed to scheduled each resource Correspondence between each resource data and each resource data and the index information of corresponding resource;
If including the corresponding resource data of the resource to be loaded in the first storage region, the resource to be loaded is read Corresponding resource data, and the second storage region is written into the resource data of reading;Second storage region is resource The region of loading process predistribution.
A kind of device of quick loading resource of the embodiment of the present invention, described device include:
Acquiring unit, for obtaining the corresponding index information of resource to be loaded;
Determination unit, for according to the corresponding index information of the resource to be loaded, determine in the first storage region whether Include the corresponding resource data of the resource to be loaded;Wherein, it is previously stored in first storage region to scheduled each Resource parsed obtained by each resource data and each resource data and the index information of corresponding resource between it is corresponding pass System;
First writes processing unit, for including the corresponding resource data of the resource to be loaded in the first storage region When, the corresponding resource data of the resource to be loaded is read, and the second storage region, institute is written into the resource data of reading State the region that the second storage region loads process predistribution for resource.
By above scheme it is found that using the embodiment of the present invention, due to being parsed in advance to scheduled each resource, and will solution The correspondence between each resource data of gained and each resource data and the index information of corresponding resource is analysed to store to the One storage region, can be by obtaining the corresponding index information of resource to be loaded, and with the index so as to when carrying out resource loading Information be according to determining whether comprising the corresponding resource data of resource to be loaded in the first storage region, comprising when, directly reading It takes the resource data and is written into the second storage region of resource loading process predistribution, realize that resource loads with this.This The scheme of inventive embodiments in resource loading procedure is carried out, parses the completion that can be hit in the first storage region Resource data, the region for being directly copied to resource loading process predistribution can be completed the loading of the part resource, keep away The reading and parsing of progress vast resources file during each loading resource are exempted from, have reduced resource loading cost, improve resource Loading velocity.
Description of the drawings
In order to illustrate more clearly about the embodiment of the present invention or technical scheme of the prior art, to embodiment or will show below There is attached drawing needed in technology description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this The embodiment of invention, for those of ordinary skill in the art, without creative efforts, can also basis The attached drawing of offer obtains other attached drawings.
Fig. 1 is the method flow schematic diagram of quick loading resource that the embodiment of the present invention one provides;
Fig. 2 is the method flow schematic diagram of quick loading resource provided by Embodiment 2 of the present invention;
Fig. 3 is the node structure signal of the resource chained list and resource chained list in shared drive provided by Embodiment 2 of the present invention Figure;
Fig. 4 is the storage condition schematic diagram of each resources member in chained list node provided by Embodiment 2 of the present invention;
Fig. 5 is a realization process schematic of quick loading resource provided by Embodiment 2 of the present invention;
Fig. 6 is the apparatus structure schematic diagram of quick loading resource that the embodiment of the present invention three provides;
Fig. 7 is the realization Organization Chart of multiple process shared drives in the same physical machine that the embodiment of the present invention four provides;
Fig. 8 is the realization Organization Chart of multiple process shared drives in the more physical machines that the embodiment of the present invention four provides.
Specific embodiment
For the sake of quoting and understanding, the technical term that hereinafter uses is write a Chinese character in simplified form or summary of abridging is explained as follows:
Shared drive:It in operating system management memory, opens up one plot of shared address field and is resided for data, and can be into It is shared between journey.
Lru Cache:Least recently used Cache are that one kind eliminates data by least recently used mode Cache way.
Below in conjunction with the attached drawing in the embodiment of the present invention, the technical solution in the embodiment of the present invention is carried out clear, complete Site preparation describes, it is clear that described embodiment is only part of the embodiment of the present invention, instead of all the embodiments.It is based on Embodiment in the present invention, those of ordinary skill in the art are obtained every other without making creative work Embodiment shall fall within the protection scope of the present invention.
The embodiment of the present invention provides a kind of method and device of quick loading resource, below by way of each embodiment to this hair Bright scheme illustrates.
Embodiment one
A kind of method of quick loading resource of the embodiment of the present invention, this method can be real in a resource loading process Existing, the resource loading process can be that a certain application, such as massively multiplayer game are started first using when being started For loading the process of the resource data of the application, the resource loading process can be server processes or client process. With reference to figure 1, Fig. 1 shows a kind of method flow diagram of quick loading resource of the embodiment of the present invention, the method may include:
Step 101 obtains the corresponding index information of resource to be loaded.
Herein, the corresponding index information of resource to be loaded is obtained, is specifically included:Using preset algorithm, generation is described to be added Carry the corresponding index information of resource.
Wherein, the resource to be loaded is according to scheduled resource dividing mode, has complete logical meaning to be loaded Justice resource integrally divided obtained by each resource unit, in practical applications, for an application to be launched, The resource to be loaded can correspond to provide one by one included in the whole resource of the application that need to be loaded when starting the application Source file, by taking massively multiplayer game as an example, the resource to be loaded can be some ground in map class resource to be loaded Some resource of skills file in image resource file or skill type resource etc..
Herein, the resource dividing mode can be determined by technical staff based on related consideration, and be not limited to use Certain specific dividing mode.
Step 102, according to the corresponding index information of the resource to be loaded, whether determine in the first storage region comprising institute State the corresponding resource data of resource to be loaded;Wherein, be previously stored in first storage region to scheduled each resource into Correspondence between each resource data of row parsing gained and each resource data and the index information of corresponding resource.
Herein, the resource data in first storage region is stored by chained list mode, each resource data and every One resource data is stored in the correspondence between index information in corresponding chained list node.
That is, for it is above-mentioned using respective resources dividing mode it is whole to the resource with complete logical meaning into For row divides each resource unit of gained, it is read out in advance, is parsed, and will be to each resource unit parsing gained Each resource data is stored in the storage region opened up for it by index relative, i.e., in described first storage region.Described In the storage of one region, the present embodiment is preferably by chain sheet form to each resource data and resource data of parsing gained Correspondence between its index information is stored, wherein, by the resource data and its phase of each resource unit parsing gained Corresponding index information is stored in the corresponding node of chained list, that is, each chained list node in resource chained list and the resource Each resource unit in entirety corresponds.
It is described according to the corresponding index information of the resource to be loaded, determine whether treated in the first storage region comprising described The corresponding first resource data of resource are loaded, are specifically included:It determines to whether there is in the resource chained list of first storage region The chained list node to match with the index information of the resource to be loaded.
If including the corresponding resource data of the resource to be loaded in step 103, the first storage region, treated described in reading The corresponding resource data of resource is loaded, and the second storage region, second memory block is written into the resource data of reading Domain loads the region of process predistribution for resource.
Herein, it is described to read the first resource data, and the first resource data write-in second of reading is stored Region specifically includes:Resource data in the chained list node to match described in reading, and will be described in the resource data write-in of reading Second storage region of resource loading process predistribution, so as to complete the loading procedure of this part resource to be loaded.According to this The resource data of each resource unit that the resource that inventive method need to load successively to the write-in of the second storage region is integrally included Afterwards, you can complete the loading tasks of the resource entirety.
In one embodiment of the embodiment of the present invention, the method further includes:If do not include in first storage region The corresponding resource data of the resource to be loaded, then read and parse the resource to be loaded, and by the resource of gained after parsing Second storage region is written in data.
In one embodiment of the embodiment of the present invention, the method further includes:The resource obtained by resource to be loaded will be parsed Correspondence between data and the resource data and the index information of the resource to be loaded, write-in first storage Region.
In one embodiment of the embodiment of the present invention, the method further includes:By the chained list node to match from Current location residing for the resource chained list is updated to the first end of the resource chained list.
In one embodiment of the embodiment of the present invention, resource data obtained by parsing resource to be loaded and described Correspondence between resource data and the index information of the resource to be loaded is written first storage region, further wraps It includes:New chained list node is added in the first end of the resource chained list, and will parse resource data obtained by resource to be loaded, with And the correspondence between the resource data and the index information of the resource to be loaded, it is written in the new chained list node.
In one embodiment of the embodiment of the present invention, the method further includes:When first storage region meet it is predetermined Data when eliminating condition, determine to need superseded resource data in first storage region, and delete the money that need to be superseded Source data.
It is described to determine to need superseded number of resources in first storage region in one embodiment of the embodiment of the present invention According to, and the resource data that need to be superseded is deleted, further comprise:According to the superseded side for eliminating least recently used data Formula deletes the chained list node of the second end of the resource chained list.
In one embodiment of the embodiment of the present invention, the method further includes:To first storage region into line number Before access, according to the access type of the data access, corresponding lock is performed to the data of first storage region Operation.
In one embodiment of the embodiment of the present invention, the access type according to the data access, to described first The data of storage region perform corresponding locking operation, further comprise:If the access type to read data, to described the The data of one storage region add shared lock, so that other resources loading process can read the number of first storage region According to;If the access type is modification data, exclusive lock is added to the data of first storage region, so that other resources Loading process cannot access the data of first storage region.
By above scheme it is found that using the embodiment of the present invention, due to being parsed in advance to scheduled each resource, and will solution The correspondence between each resource data of gained and each resource data and the index information of corresponding resource is analysed to store to the One storage region, can be by obtaining the corresponding index information of resource to be loaded, and with the index so as to when carrying out resource loading Information be according to determining whether comprising the corresponding resource data of resource to be loaded in the first storage region, comprising when, directly reading It takes the resource data and is written into the second storage region of resource loading process predistribution, realize that resource loads with this.This The scheme of inventive embodiments in resource loading procedure is carried out, parses the completion that can be hit in the first storage region Resource data, the region for being directly copied to resource loading process predistribution can be completed the loading of the part resource, keep away The reading and parsing of progress vast resources file during each loading resource are exempted from, have reduced resource loading cost, improve resource Loading velocity.
Divide multiple embodiments that the present invention program is described in detail below.
Embodiment two
As shown in Fig. 2, the method for the quick loading resource, can realize, the method in a resource loading process Including:
Step 201, using preset algorithm, the corresponding index information of the generation resource to be loaded.
The present embodiment is specifically calculated using MD5 (Message-Digest Algorithm 5, Message Digest Algorithm 5) Method handles the resource (such as current some resource file to be loaded) to be loaded, obtains the MD5 values of the resource, And using the MD5 values of the resource to be loaded as index information.Here, as long as the preset algorithm can be by resource process Reason generates the index information of resource, is not limited to the MD5 algorithms of the present embodiment use.
Step 202 determines to whether there is in the resource chained list of the first storage region and the index of the resource to be loaded is believed The matched chained list node of manner of breathing.Wherein, it is previously stored in first storage region and parsing institute is carried out to scheduled each resource Correspondence between each resource data and each resource data and the index information of corresponding resource that obtain;Described first deposits Resource data in storage area domain is stored by chained list mode, between each resource data and each resource data and index information Correspondence is stored in corresponding chained list node.
One resource with corresponding complete logical meaning is integrally drawn using respective resources dividing mode for above-mentioned For each resource unit obtained by point, the embodiment of the present invention is in advance read out it, parses, and will be to each resource unit solution Each resource data of analysis gained is stored in the storage region opened up for it by index relative, i.e., in described first storage region.
First storage region can be specifically the shared drive region of one piece of pre- first to file.
In practical application, it is whole that the resource with corresponding complete logical meaning can be loaded for the first time in server or client During body, if server or client start a certain application and when loading the application resource of the application first for the first time, first to operation One piece of memory pool of system application (memory pool big neglect the data volume that need to load resource depending on) is and common at this as shared drive It enjoys memory and opens up one piece of spatial cache (cache), to be configured to manage the data structure that the shared drive stores data, one As for, which need to safeguard the data directory of a shared drive, to facilitate data by index organization shared In memory.For shared drive carries out data storage using chained list mode, the data directory may include resource file Index information between the address of the chained list node corresponding to the resource file (can be specifically the first address of node) it is corresponding Relationship.
A large amount of resource text need to be generally loaded when resource loading process loads resource when server starts for the first time Part, the corresponding parsing header file in file is first read out before loading resource file, the parsing header file can identify resource Some description informations, such as by taking map resource as an example, which can identify map and specifically be divided into how many region, Mei Gequ The level in domain how etc., then resource loading process will continue to according to this parsing header file resource description information application institute The memory needed, later, is successively read resource file, is usually directly read in the form of binary, calculate read resource The MD5 values of file, and the resource file is parsed, as soon as a resource file has often been parsed, using the MD5 values of this document as index, with The memory overhead of the data obtained is memory usage amount after resource resolution, right to the memory space needed for one piece of shared drive application In the resource data and its corresponding resource file that gained for shared drive storage data, will be parsed using chained list mode MD5 values correspondence is filled into a corresponding chained list node, the knot in the resource chained list and resource chained list that are stored in shared drive Point structure is specifically referred to shown in Fig. 3.
Wherein, it is follow-up for convenience the data in chained list node to be recombinated when reading chained list node, to chained list knot When point inserts data, need to corresponding address offset amount be set by the EMS memory occupation situation of each member in the parsing data of resource file (offset such as on the basis of the first address of the node), the storage condition of the parsing data of resource file in chained list node can Refering to what is shown in Fig. 4, the storage condition of each resources member in a chained list node has been shown in particular in Fig. 4, wherein, resources member a is One character type variable, b are an integer variables, occupy the memory headroom of 1 byte, 4 bytes respectively, and p_b is directed to the pointer of b, p_b Middle storage be b phases should node first address offset, as 5.
On the basis of above pretreatment, by holding, there are one fixed, energy when following resource loading process loads resource The shm_key (shared drive key) of the shm_id (shared drive id) of the memory pool is enough mapped to find this block memory, is convenient for Process shared data from the memory pool.
In this step, the resource loading process is mapped to shared drive by a shm_key, that is, is mapped to described first Storage region, and know to whether there is in shared drive based on the data structure and match with the index information of resource to be loaded Chained list node, here, be compared to using the prior art, when loading resource, the present invention is not required to read and parse to be loaded Resource does not need to such as to read, parses resource file one by one, only need to be with the index information of resource to be loaded, i.e., money to be loaded The MD5 values of source file are key, by inquiring the index information table safeguarded in the data structure, to the number in shared drive According to being hit.
If there is the index information phase with the resource to be loaded in the resource chained list of step 203, the first storage region The chained list node matched, then read described in resource data in the chained list node that matches, and by the resource data write-in of reading the Two storage regions, second storage region load the region of process predistribution for the resource.
If there is the chain to match with the index information of the resource to be loaded in the resource chained list of the first storage region In the case that table node namely memory are hit, server or client read hit chain by the first loading process Resource data in table node, and make after accordingly converting (as done ground to data based on new storage region for data streams read Location is converted, and is allowed to available), the second storage region that resource data write-in the first loading process of reading is pre-allocated, so as to complete The loading procedure of resource to be loaded that can be hit into this part in Sharing Memory Realization.In method according to the present invention successively to After the resource data of each resource unit that the resource that the write-in of two storage regions need to load integrally is included, you can complete the money The loading tasks of source entirety.
Second storage region can be the first loading process pre-allocated when loading resource except described shared Other one piece of region of memory except memory.
In one embodiment of the embodiment of the present invention, the method further includes:If do not include in first storage region The corresponding resource data of the resource to be loaded, then read and parse the resource to be loaded, and by the resource of gained after parsing Second storage region is written in data.
That is, if there is no the index informations with the resource to be loaded in the resource chained list of the first storage region It is in the case of the chained list node to match, i.e. memory miss, then to be added to the part by the resource load mode of the prior art Resource, such as current some map file to be loaded are carried, is read out and parses, and by gained after resolving resource file Second storage region is written in resource data, and the resource data so as to the part be completed to fail hit in shared drive adds It carries.
Wherein, processing procedure during above-mentioned memory miss mainly for the situation that resource changes, such as is developed Resource change or user of service (game player etc.) are based on it caused by personnel change the resource data progress additions and deletions of application Using resource change caused by the process of application etc., when resource file changes (such as the money of gained after newly-increased or modification Source file), MD5 values can accordingly change, and cannot be hit so as to cause in shared drive.
In one embodiment of the embodiment of the present invention, the method further includes:By the chained list node to match from Current location residing for the resource chained list is updated to the first end of the resource chained list.
It is managed for ease of the resource chained list to shared drive, the present embodiment uses the way to manage of Lru Cache, will The chained list node of each newest operation is updated to the first end of resource chained list, and the Lru Cache are a kind of by least making recently The cache way of data is eliminated with mode.For example, for hit by memory in determined resource chained list with money to be loaded The node can be updated to the gauge outfit of resource chained list by the corresponding chained list node in source from its current location in resource chained list.
In one embodiment of the embodiment of the present invention, the method further includes:The resource obtained by resource to be loaded will be parsed Correspondence between data and the resource data and the index information of the resource to be loaded, write-in first storage Region.
Herein, the resource data by obtained by the parsing resource to be loaded and the resource data are treated with described The correspondence between the index information of resource is loaded, first storage region is written, specifically includes:In the resource chained list First end adds new chained list node, and will parse resource data obtained by resource to be loaded and the resource data and institute The correspondence between the index information of resource to be loaded is stated, is written in the new chained list node.
That is, under memory miss situation, in addition to the processing mode according to the prior art, by resolving resource file The second storage region of the resource loading process predistribution is written in the resource data of gained, completes the part miss data Loading, the present embodiment also calculate the index information of the resource of the miss, and the resource obtained by by its index information and parsing Data are added in the resource chained list of shared drive, wherein, it, specifically can be in resource chained list based on the way to manage of Lru Cache First end, as resource chained list gauge outfit for this miss data (the i.e. newest data used) add chained list node, and general Resource data and its corresponding index information after miss resource resolution insert the newly added table of shared drive resource chained list In head node, while in the data structure maintained in cache, the relative index item information of the node is added, to facilitate later again During secondary loading resource, the resource added in shared drive resource chained list is hit.Based on this, complete the quick of resource and add The realization process of load is specifically referred to shown in Fig. 5.
In one embodiment of the embodiment of the present invention, the method further includes:When first storage region meet it is predetermined Data when eliminating condition, determine to need superseded resource data in first storage region, and delete the money that need to be superseded Source data.
Herein, it is described to determine to need superseded resource data in first storage region, and delete the money that be superseded Source data specifically includes:According to the superseded mode for eliminating least recently used data, the second end of the resource chained list is deleted Chained list node.
Since in the case of shared drive miss, the parsing data and its index information of miss resource can be added Into the resource chained list of shared drive, so as to which to prevent shared drive data from overflowing, the present embodiment uses corresponding data cradle System, when the first storage region, that is, shared drive meets scheduled data and eliminates condition, eliminates a part of number therein According to.Specifically, the data condition of eliminating can be formulated based on certain redundancy strategy, and the redundancy for such as setting shared drive is empty Between capacity threshold, so as to, shared drive remaining space be less than the threshold value when, you can judge that it meets data and eliminates condition, The partial data of shared drive need to be eliminated.
The present embodiment is based on used Lru Cache way to manages, that is, eliminates eliminating for least recently used data Mode, it is specific to delete the chained list node that chained list second end is in chained list, such as the table caudal knot point of resource chained list is deleted, so as to real Now least recently used linked list data is purged, while updates the data structure maintained in cache, makes itself and resource chain Table dynamic is corresponding.
Said program provided in an embodiment of the present invention is suitable in same physical machine, (single based on one process access mode Process accesses shared drive), carry out the scene of repeated loading same asset, such as in same server or client, by multiple Start same process and carry out a certain application of repeated loading.Being compared to the prior art needs in the application money for loading the application every time Repeated resolution resource during source takes longer, waste so as to cause disk I/O and cpu resource that waste machine occur and loading The problems such as time, the scheme of the embodiment of the present invention only need to carry out first resource parsing simultaneously in physical machine loading resource for the first time Application shared drive stores it, in loading resource every time later, only by being hit to shared drive, and copies The resource data of shared drive can be realized resource loading, save machine disk I/O and cpu resource, save resource loading Time.
For the present invention program is caused to be equally applicable to start simultaneously the scene of the same shared drive of multi-process access, i.e., same One physical machine starts multiple resources loading processes to access shared drive simultaneously across physical machine so that can in same physical machine or The resource loading procedure of multiple processes is completed across physical machine, in one embodiment of the embodiment of the present invention, the method is also wrapped It includes:Before data access is carried out to first storage region, according to the access type of the data access, to described first The data of storage region perform corresponding locking operation.
In this implementation, it is described across physical machine specifically refer to multiple physical machines be respectively started one or more resources load into Journey simultaneously carries out resource loading by the resource data in the shared shared drive.
The access type according to the data access performs corresponding lock to the data of first storage region Operation, is realized especially by procedure below:If the access type adds to read data to the data of first storage region Upper shared lock, so that other resources loading process can read the data of first storage region;If the access type To change data, exclusive lock is added to the data of first storage region, so that other resources loading process cannot access The data of first storage region.
In the present embodiment, the access type for reading data specifically includes the number for referring to inquiry and/or reading shared drive According to;It is described modification data access type, specifically include to shared drive write-in data, delete shared drive data and/or Change the data of shared drive.
The embodiment of the present invention solves multi-process (same physical machine or multiple resources loading across physical machine using file lock Process) while the resource competing problem involved during one piece of shared drive is accessed, wherein, inquiring and/or reading shared drive Using shared lock during data, when data are written, deletes data and/or changes data, using exclusive lock.When a certain resource process When adding shared lock to the data of shared drive, other processes can be still realized by adding shared lock to shared drive to shared interior Deposit data is inquired and/or is read, and cannot add exclusive lock to shared drive again, until the shared lock of each process discharges;When Data from a certain process to shared drive add exclusive lock when, other processes cannot add any lock to shared drive again, until should The exclusive lock release of process realizes that striding course is locked, so as to ensureing the write-in of the exclusiveness of resource between process and share and access with this (inquiry/reading).
In practical applications, striding course lock can also use letter other than file lock used in the embodiment of the present invention The mechanism of the striding courses such as number amount, thread lock communication is used as process lock, and in addition above is used for described in resource-sharing For first storage region, memory database can also be used come shared drive and Lru Cache used by substituting the present embodiment, Not invention is not construed as limiting it.
Embodiment three
A kind of device of quick loading resource of the embodiment of the present invention can be realized in a resource loading process, described Resource loading process can be to application, such as massively multiplayer game application is when being started, start first for loading this The process of the resource data of application, the resource loading process can be server processes or client process.
Refering to what is shown in Fig. 6, the device of the quick loading resource includes:Acquiring unit 61, for obtaining resource to be loaded Corresponding index information;Determination unit 62, for according to the corresponding index information of the resource to be loaded, determining the first memory block Whether the to be loaded resource corresponding resource data is included in domain;Wherein, it is previously stored in first storage region pair Scheduled each resource parsed obtained by each resource data and each resource data and the index information of corresponding resource between Correspondence;First writes processing unit 63, for including the corresponding resource of the resource to be loaded in the first storage region During data, the corresponding resource data of the resource to be loaded is read, and the second memory block is written into the resource data of reading Domain, second storage region load the region of process predistribution for the resource.
In one embodiment of the embodiment of the present invention, the determination unit is further used for:Determine first memory block It whether there is the chained list node to match with the index information of the resource to be loaded in the resource chained list in domain.
In one embodiment of the embodiment of the present invention, further include:Position adjustment unit, for by the chained list to match Node is from the first end that the resource chained list is updated in the current location residing for the resource chained list.
In one embodiment of the embodiment of the present invention, described device further includes:Second writes processing unit, for being deposited first When not including the corresponding resource data of the resource to be loaded in storage area domain, read and parse the resource to be loaded, and will solution Second storage region is written in the resource data of gained after analysis.
In one embodiment of the embodiment of the present invention, described device further includes:Third writes processing unit, for that will parse institute It states between resource data obtained by resource to be loaded and the resource data index information corresponding with the resource to be loaded First storage region is written in correspondence.
In one embodiment of the embodiment of the present invention, the third writes processing unit, is further used for:In the resource chain The first end of table adds new chained list node, and will parse resource data and the resource obtained by the resource to be loaded Correspondence between data index information corresponding with the resource to be loaded, is written in the new chained list node.
In one embodiment of the embodiment of the present invention, described device further includes:Unit is deleted, in the described first storage Region meets scheduled data when eliminating condition, determines to need superseded resource data, and delete institute in first storage region State the resource data that need to be eliminated.
In one embodiment of the embodiment of the present invention, the deletion unit is further used for:At least make recently according to eliminating The superseded mode of data deletes the chained list node of the second end of the resource chained list.
In one embodiment of the embodiment of the present invention, described device further includes:Unit is locked, for being deposited to described first Before storage area domain carries out data access, according to the access type of the data access, the data of first storage region are held The corresponding locking operation of row.
In one embodiment of the embodiment of the present invention, the locking unit is further used for:In the access type to read Access according to when, to first storage region data plus shared lock so that other resources loading process can read institute State the data of the first storage region;When the access type is modification data, added to the data of first storage region Exclusive lock, so that other resources loading process cannot access the data of first storage region.
Herein, it should be noted that the description of the device of quick loading resource that the present embodiment is related to, with method above Description is similar, and is described with the advantageous effect of method, for the quick device for loading resource of the invention in the present embodiment The technical detail not disclosed, please refers to the explanation of the method for the present invention embodiment, and the present embodiment does not remake this and repeats.
Example IV
The scheme of the quick loading resource of the embodiment of the present invention, in addition to being suitable for being visited based on one process in same physical machine It asks that mode (one process access shared drive) carrys out the scene of repeated loading same asset, applies also in same physical machine or across object Reason machine starts the scene that multiple processes access Sharing Memory Realization loading same asset simultaneously.
Next, using same physical machine or across physical machine start multiple processes simultaneously access the scene of shared drive as Example is described below the embodiment of the present invention:
For starting the scene of multi-process access shared drive, the quick visit with reference to shown in figure 7 simultaneously in same physical machine Ask the Organization Chart of resource, multiple processes in same physical machine, the same developing engine that such as multiple developers share is (wherein described Developing engine corresponds to multiple terminals, respectively by multiple developer's uses) in multiple processes:Process1、 Process2......, realize that striding course is locked by file lock Flock, so as to ensure the exclusiveness of resource between process write-in and altogether Enjoy access (inquiry/reading).
Wherein, when inquiring and/or reading shared drive data using shared lock, write-in data, delete data and/or When changing data, using exclusive lock.When a certain resource process, as process Process1 to the data of shared drive adds shared lock When, other processes can still be realized and shared drive data are inquired and/or read by adding shared lock to shared drive, and Cannot exclusive lock be added to shared drive again, until the shared lock of each process discharges;When a certain process as process Process2 to When the data of shared drive add exclusive lock, other processes cannot add any lock to shared drive again, until the row of Process2 He locks release.
For starting the scene of multi-process access shared drive simultaneously across physical machine, by taking server as an example, across physical machine When, multiple servers (abbreviation server zone) of same nature generally require to load identical resource, then based on of the invention real It applies the scheme of example a server therein loading is only needed to go over resource and (resolving resource and apply for memory space during loading resource Realize sharing for the resource data parsed), other servers can share the resource data for having completed parsing, realize resource Loading, it is very convenient.
It specifically, can be with Shen for loading the server of the resource in this group when server zone loading resource for the first time Please a memory physical machine, which can be served as by any server in the server zone, and use memory number The parsing data of resource file are stored according to library, a proxy server is added between server and memory physical machine Proxy, proxy server Proxy utilize respective protocol such as TCP (Transmission Control Protocol, transmission control Agreement processed) data forwarding across physical machine is completed, and be responsible for the work such as the management of file lock, the control of access limit, more physics The Technical Architecture figure that machine quickly loads resource is specifically referred to shown in Fig. 8, and more physical machine frameworks based on Fig. 8 work as server zone In a server loading go over resource, realize will load resource when the resource data obtained by resolving resource will be shared to interior After depositing physical machine, other servers in the server zone can be realized by the resource data in shared drive physical machine Quick resource loading.
It should be noted that each embodiment in this specification is described by the way of progressive, each embodiment weight Point explanation is all difference from other examples, and just to refer each other for identical similar part between each embodiment.
For convenience of description, it describes to be divided into various modules when system above or device with function or unit describes respectively. Certainly, the function of each unit is realized can in the same or multiple software and or hardware when implementing the application.
As seen through the above description of the embodiments, those skilled in the art can be understood that the application can It is realized by the mode of software plus required general hardware platform.Based on such understanding, the technical solution essence of the application On the part that the prior art contributes can be embodied in the form of software product in other words, the computer software product It can be stored in storage medium, such as ROM/RAM, magnetic disc, CD, be used including some instructions so that a computer equipment (can be personal computer, server either network equipment etc.) performs the certain of each embodiment of the application or embodiment Method described in part.
Finally, it is to be noted that, herein, the relational terms of such as first, second, third and fourth or the like It is used merely to distinguish one entity or operation from another entity or operation, without necessarily requiring or implying these There are any actual relationship or orders between entity or operation.Moreover, term " comprising ", "comprising" or its is any Other variants are intended to non-exclusive inclusion, so that process, method, article or equipment including a series of elements Not only include those elements, but also including other elements that are not explicitly listed or further include as this process, side Method, article or the intrinsic element of equipment.In the absence of more restrictions, limited by sentence "including a ..." Element, it is not excluded that also there are other identical elements in the process, method, article or apparatus that includes the element.
The above is only the preferred embodiment of the present invention, it is noted that for the ordinary skill people of the art For member, various improvements and modifications may be made without departing from the principle of the present invention, these improvements and modifications also should It is considered as protection scope of the present invention.

Claims (22)

  1. A kind of 1. method of quick loading resource, which is characterized in that the method includes:
    Obtain the corresponding index information of resource to be loaded;
    According to the index information of the resource to be loaded, determine whether corresponded in the first storage region comprising the resource to be loaded Resource data;Wherein, each money obtained by being parsed to scheduled each resource is previously stored in first storage region Correspondence between source data and each resource data and the index information of corresponding resource;
    If including the corresponding resource data of the resource to be loaded in the first storage region, read the resource to be loaded and correspond to Resource data, and the second storage region is written into the resource data of reading;Second storage region is loaded for resource The region of process predistribution.
  2. 2. it according to the method described in claim 1, it is characterized in that, further includes:
    If not including the corresponding resource data of the resource to be loaded in the first storage region, read and parse described to be loaded Resource, and second storage region is written into the resource data of gained after parsing.
  3. 3. it according to the method described in claim 2, it is characterized in that, further includes:
    Resource data obtained by resource to be loaded and the resource data and the index information of the resource to be loaded will be parsed Between correspondence, first storage region is written.
  4. 4. it according to the method described in claim 3, it is characterized in that, further includes:
    When first storage region, which meets scheduled data, eliminates condition, determine to need in first storage region superseded Resource data, and delete the resource data that need to be superseded.
  5. 5. it according to the method described in claim 1, it is characterized in that, further includes:
    Before data access is carried out to first storage region, according to the access type of the data access, to described the The data of one storage region perform corresponding locking operation.
  6. 6. according to the method described in claim 5, it is characterized in that, the access type according to the data access, to institute The corresponding locking operation of data execution for stating the first storage region includes:
    If the access type adds shared lock, so that other resources to read data to the data of first storage region Loading process can read the data of first storage region;
    If the access type is modification data, add exclusive lock to the data of first storage region, so that other resources Loading process cannot access the data of first storage region.
  7. 7. according to the method described in claim 1, it is characterized in that, described obtain the corresponding index information of resource to be loaded, packet It includes:
    Using preset algorithm, the corresponding index information of the resource to be loaded is generated.
  8. 8. according to the method described in claim 4, it is characterized in that, the resource data in first storage region presses chained list side Formula stores, and each resource data and each resource data are stored in corresponding chained list knot with the correspondence between index information In point, then whether the index information according to the resource to be loaded, determine in the first storage region comprising described to be loaded The corresponding resource data of resource, including:
    It determines to whether there is in the resource chained list of first storage region and match with the index information of the resource to be loaded Chained list node.
  9. 9. according to the method described in claim 8, it is characterized in that, described read the corresponding number of resources of the resource to be loaded According to, including:
    Resource data in the chained list node to match described in reading.
  10. 10. it according to the method described in claim 8, it is characterized in that, further includes:
    The chained list node to match is updated to the resource chained list from the current location residing for the resource chained list First end.
  11. 11. the according to the method described in claim 10, it is characterized in that, number of resources that gained after resource to be loaded will be parsed According to and correspondence between the resource data and the index information of the resource to be loaded, first memory block is written Domain, including:
    New chained list node is added in the first end of the resource chained list, and will parse resource data obtained by resource to be loaded, And the correspondence between the resource data and the index information of the resource to be loaded, the new chained list node is written In.
  12. 12. according to the method for claim 11, which is characterized in that needed in determining first storage region superseded Resource data, and the resource data that need to be superseded is deleted, including:
    According to the superseded mode for eliminating least recently used data, the chained list node of the second end of the resource chained list is deleted.
  13. 13. a kind of device of quick loading resource, which is characterized in that described device includes:
    Acquiring unit, for obtaining the corresponding index information of resource to be loaded;
    Determination unit, for according to the corresponding index information of the resource to be loaded, determining whether included in the first storage region The corresponding resource data of the resource to be loaded;Wherein, it is previously stored in first storage region to scheduled each resource The correspondence between each resource data and each resource data and the index information of corresponding resource obtained by being parsed;
    First writes processing unit, for during resource data corresponding comprising the resource to be loaded, being read in the first storage region It takes the corresponding resource data of the resource to be loaded, and the resource data of reading is written into the second storage region, described the Two storage regions load the region of process predistribution for resource.
  14. 14. device according to claim 13, which is characterized in that further include:
    Second writes processing unit, during for not including the corresponding resource data of the resource to be loaded in the first storage region, It reads and parses the resource to be loaded, and second storage region is written into the resource data of gained after parsing.
  15. 15. device according to claim 14, which is characterized in that further include:
    Third writes processing unit, for that will parse the resource data of gained and the resource data and institute after resource to be loaded The correspondence between the corresponding index information of resource to be loaded is stated, first storage region is written.
  16. 16. device according to claim 15, which is characterized in that further include:
    Unit is deleted, for when first storage region meets scheduled data and eliminates condition, determining first storage Superseded resource data is needed in region, and deletes the resource data that need to be superseded.
  17. 17. device according to claim 13, which is characterized in that further include:
    Lock unit, for first storage region carry out data access before, the access according to the data access Type performs corresponding locking operation to the data of first storage region.
  18. 18. device according to claim 17, which is characterized in that the locking unit is further used for:
    When the access type is reads data, shared lock is added to the data of first storage region, so that other Resource loading process can read the data of first storage region;
    When the access type is modification data, exclusive lock is added to the data of first storage region, so that other Resource loading process cannot access the data of first storage region.
  19. 19. device according to claim 13, which is characterized in that the resource data in first storage region presses chained list Mode stores, and each resource data and each resource data are stored in corresponding chained list with the correspondence between index information In node, then the determination unit, is further used for:
    It determines to whether there is in the resource chained list of first storage region and match with the index information of the resource to be loaded Chained list node.
  20. 20. device according to claim 19, which is characterized in that further include:
    Position adjustment unit, for the chained list node to match to be updated from the current location residing for the resource chained list To the first end of the resource chained list.
  21. 21. device according to claim 20, which is characterized in that the third writes processing unit, is further used for:
    New chained list node is added in the first end of the resource chained list, and will parse resource data obtained by resource to be loaded, And the correspondence between the resource data and the index information of the resource to be loaded, the new chained list node is written In.
  22. 22. device according to claim 21, which is characterized in that the deletion unit is further used for:
    According to the superseded mode for eliminating least recently used data, the chained list node of the second end of the resource chained list is deleted.
CN201611115565.XA 2016-12-07 2016-12-07 A kind of method and device of quick loading resource Pending CN108170489A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611115565.XA CN108170489A (en) 2016-12-07 2016-12-07 A kind of method and device of quick loading resource

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611115565.XA CN108170489A (en) 2016-12-07 2016-12-07 A kind of method and device of quick loading resource

Publications (1)

Publication Number Publication Date
CN108170489A true CN108170489A (en) 2018-06-15

Family

ID=62526152

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611115565.XA Pending CN108170489A (en) 2016-12-07 2016-12-07 A kind of method and device of quick loading resource

Country Status (1)

Country Link
CN (1) CN108170489A (en)

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109144692A (en) * 2018-07-16 2019-01-04 北京奇虎科技有限公司 A kind of method, apparatus and terminal for the process of distributing
CN109582726A (en) * 2018-12-18 2019-04-05 网易(杭州)网络有限公司 The treating method and apparatus of tables of data
CN109767827A (en) * 2019-01-14 2019-05-17 云南大学 The sharing method and shared system of DICOM original image data in memory
CN110399235A (en) * 2019-07-16 2019-11-01 阿里巴巴集团控股有限公司 Multi-thread data transmission method and device in TEE system
CN110413346A (en) * 2019-07-30 2019-11-05 中国工商银行股份有限公司 A kind of parameter updating method and device
CN110442462A (en) * 2019-07-16 2019-11-12 阿里巴巴集团控股有限公司 Multi-thread data transmission method and device in TEE system
CN111352762A (en) * 2020-03-04 2020-06-30 恒生电子股份有限公司 Process access determining method and related device
CN111767153A (en) * 2020-06-05 2020-10-13 维沃移动通信有限公司 Resource access method and device and electronic equipment
CN112667315A (en) * 2020-12-23 2021-04-16 上海米哈游天命科技有限公司 Game engine editor starting method and device, electronic equipment and storage medium
CN112667310A (en) * 2020-12-23 2021-04-16 上海米哈游天命科技有限公司 Game engine editor starting method and device, electronic equipment and storage medium
US11042642B2 (en) 2019-07-16 2021-06-22 Advanced New Technologies Co., Ltd. Method and apparatus for data transmission in a TEE system
CN114201233A (en) * 2021-11-18 2022-03-18 成都网思科平科技有限公司 Method for reducing process module loading data storage based on snapshot reference
CN111767153B (en) * 2020-06-05 2024-04-30 维沃移动通信有限公司 Resource access method and device and electronic equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103001964A (en) * 2012-12-04 2013-03-27 杭州顺网科技股份有限公司 Cache acceleration method under local area network environment
CN103888321A (en) * 2014-04-14 2014-06-25 中国人民解放军信息工程大学 Dataflow detecting method and multi-core processing device
CN104980454A (en) * 2014-04-02 2015-10-14 腾讯科技(深圳)有限公司 Method, server and system for sharing resource data

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103001964A (en) * 2012-12-04 2013-03-27 杭州顺网科技股份有限公司 Cache acceleration method under local area network environment
CN104980454A (en) * 2014-04-02 2015-10-14 腾讯科技(深圳)有限公司 Method, server and system for sharing resource data
CN103888321A (en) * 2014-04-14 2014-06-25 中国人民解放军信息工程大学 Dataflow detecting method and multi-core processing device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
王飞飞等: "《MySQL数据库应用从入门到精通 第2版》", 30 April 2014 *

Cited By (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109144692A (en) * 2018-07-16 2019-01-04 北京奇虎科技有限公司 A kind of method, apparatus and terminal for the process of distributing
CN109582726A (en) * 2018-12-18 2019-04-05 网易(杭州)网络有限公司 The treating method and apparatus of tables of data
CN109767827A (en) * 2019-01-14 2019-05-17 云南大学 The sharing method and shared system of DICOM original image data in memory
US10896075B1 (en) 2019-07-16 2021-01-19 Advanced New Technologies Co., Ltd. Method and apparatus for multithreaded data transmission in a TEE system
CN110399235A (en) * 2019-07-16 2019-11-01 阿里巴巴集团控股有限公司 Multi-thread data transmission method and device in TEE system
CN110442462A (en) * 2019-07-16 2019-11-12 阿里巴巴集团控股有限公司 Multi-thread data transmission method and device in TEE system
US11042642B2 (en) 2019-07-16 2021-06-22 Advanced New Technologies Co., Ltd. Method and apparatus for data transmission in a TEE system
US10943006B2 (en) 2019-07-16 2021-03-09 Advanced New Technologies Co., Ltd. Method and apparatus for multithreaded data transmission in a TEE system
US10884830B1 (en) 2019-07-16 2021-01-05 Advanced New Technologies Co., Ltd. Method and apparatus for multithreaded data transmission in a tee system
CN110413346A (en) * 2019-07-30 2019-11-05 中国工商银行股份有限公司 A kind of parameter updating method and device
CN110413346B (en) * 2019-07-30 2022-09-20 中国工商银行股份有限公司 Parameter updating method and device
CN111352762A (en) * 2020-03-04 2020-06-30 恒生电子股份有限公司 Process access determining method and related device
CN111767153A (en) * 2020-06-05 2020-10-13 维沃移动通信有限公司 Resource access method and device and electronic equipment
CN111767153B (en) * 2020-06-05 2024-04-30 维沃移动通信有限公司 Resource access method and device and electronic equipment
CN112667315A (en) * 2020-12-23 2021-04-16 上海米哈游天命科技有限公司 Game engine editor starting method and device, electronic equipment and storage medium
CN112667310A (en) * 2020-12-23 2021-04-16 上海米哈游天命科技有限公司 Game engine editor starting method and device, electronic equipment and storage medium
CN114201233A (en) * 2021-11-18 2022-03-18 成都网思科平科技有限公司 Method for reducing process module loading data storage based on snapshot reference

Similar Documents

Publication Publication Date Title
CN108170489A (en) A kind of method and device of quick loading resource
US11269839B2 (en) Authenticated key-value stores supporting partial state
CN107045530B (en) A method of object storage system is embodied as local file system
US10528537B2 (en) System and method for fetching the latest versions of stored data objects
CN108369507A (en) For using the method and apparatus for handling process instruction in memory
TW400494B (en) Determining how changes to underlying data affect cached objects
CN110062925A (en) Snapshot metadata arrangement for converging
CN105701156B (en) A kind of distributed file system management method and device
Winter et al. Autonomous, independent management of dynamic graphs on GPUs
US20100325363A1 (en) Hierarchical object caching based on object version
CN109697016A (en) Method and apparatus for improving the storage performance of container
Bansal et al. Randomized competitive algorithms for generalized caching
CN107257957A (en) Application cache to secondary application is replicated
Venkataramani et al. Bandwidth constrained placement in a WAN
JP2021510222A (en) Data processing methods, equipment, and computing devices
CN108089816A (en) A kind of query formulation data de-duplication method and device based on load balancing
Kostamis et al. Exploring ethereum's data stores: A cost and performance comparison
CN105468541B (en) A kind of buffer memory management method towards lucidification disposal intelligent terminal
CN113609167B (en) Data processing method, device and equipment based on block chain and readable storage medium
CN114003562B (en) Directory traversal method, device and equipment and readable storage medium
US20040117437A1 (en) Method for efficient storing of sparse files in a distributed cache
Chou et al. Bc-store: A scalable design for blockchain storage
CN108021339A (en) A kind of method of disk read-write, equipment and computer-readable recording medium
CN110502472A (en) A kind of the cloud storage optimization method and its system of large amount of small documents
Ohashi et al. Token-based sharing control for IPFS

Legal Events

Date Code Title Description
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right

Effective date of registration: 20210128

Address after: 201200 5th floor, area C, 1801 Hongmei Road, Minhang District, Shanghai

Applicant after: Tencent Technology (Shanghai) Co.,Ltd.

Address before: 518000 Tencent Building, No. 1 High-tech Zone, Nanshan District, Shenzhen City, Guangdong Province, 35 Floors

Applicant before: TENCENT TECHNOLOGY (SHENZHEN) Co.,Ltd.

TA01 Transfer of patent application right