Storage space management method, device, equipment and storage medium

By dividing the storage space into multiple storage areas and determining the legal application area based on the number of requests, the problem of space fragmentation in segmented storage management is solved, and the utilization rate of storage space is improved.

CN117806983BActive Publication Date: 2025-03-14MOORE THREADS TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311830690.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-27
Publication Date
2025-03-14
Estimated Expiration
2043-12-27

AI Technical Summary

Technical Problem

Segmented storage management easily leads to space fragmentation when allocating storage space, reducing the utilization rate of storage space.

Method used

By dividing the storage space into multiple storage areas, each storage area has a different range of request volume. After receiving the space allocation request from the thread, a legal application area is determined and a continuous storage domain segment that meets the request volume is found in the area for allocation.

Benefits of technology

It effectively reduces the fragmentation of storage space, improves the utilization rate of storage space, and can flexibly allocate space according to different storage needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117806983B_ABST
    Figure CN117806983B_ABST
Patent Text Reader

Abstract

An embodiment of the present application discloses a storage space management method, apparatus, device and storage medium, wherein the storage space includes at least two storage areas, and each storage area can respond to a different range of space request amounts. The method includes: receiving a space allocation request sent by a thread, and determining the space request amount of the space allocation request for the storage space; based on the space request amount and the request amount range corresponding to each storage area, determining a legal application area in the storage space; the legal application area includes at least one storage area; determining a target storage domain segment in the legal application area, and allocating the target storage domain segment to the thread.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to but is not limited to the field of resource allocation technology, and in particular to a storage space management method, device, equipment and storage medium. Background Art

[0002] As one of the most common storage management methods, segmented storage management has the advantages of low management resource overhead and simple address calculation, and is widely used. Its basic principle is to allocate a continuous space to the memory each time according to the size of the space requested in each space allocation request. The size of this continuous space is equal to the size of the space requested in the space allocation request. In the actual working process, the memory is allocated with several segments of continuous space of different sizes. Due to the wide variety of threads requesting storage space, different threads use different lengths of time and space for this type of storage. In the process of allocating storage space, related technologies often cause space fragmentation, low storage space utilization, and waste of precious memory resources. Summary of the invention

[0003] In view of this, embodiments of the present application at least provide a storage space management method, apparatus, device, and storage medium.

[0004] The technical solution of the embodiment of the present application is implemented as follows:

[0005] On the one hand, an embodiment of the present application provides a storage space management method, wherein the storage space includes at least two storage areas, and each storage area can respond to a different range of space request amounts. The method includes: receiving a space allocation request sent by a thread, and determining the space request amount of the space allocation request for the storage space; based on the space request amount and the request amount range corresponding to each storage area, determining a legitimate application area in the storage space; the legitimate application area includes at least one storage area; determining a target storage domain segment in the legitimate application area, and allocating the target storage domain segment to the thread.

[0006] In some embodiments, the address order of each storage area in the storage space is related to the size order of the request amount range of each storage area.

[0007] In some embodiments, determining the legal application area in the storage space based on the space request amount and the request amount range corresponding to each storage area includes:

[0008] Based on the space request amount and the request amount range corresponding to each of the storage areas, the legal application area is determined in the at least two storage areas; the request amount range of the storage area in the legal application area is greater than or equal to the space request amount.

[0009] In some embodiments, determining the legal application area in the at least two storage areas based on the space request amount and the request amount range corresponding to each storage area includes:

[0010] All storage areas whose request amount range is greater than or equal to the space request amount are regarded as legal application areas.

[0011] In some embodiments, determining a target storage domain segment in the legal application area and allocating the target storage domain segment to the thread includes:

[0012] Searching for a continuous storage domain segment in the legal application area based on the space request amount;

[0013] When a continuous storage domain segment that satisfies the space request amount is found, the continuous storage domain segment is allocated to the thread as a target storage domain segment.

[0014] In some embodiments, searching for a continuous storage domain segment in the legal application area based on the space request amount includes:

[0015] Based on the order of addresses from low to high, continuous storage domain segments are obtained from the legal application area in sequence, and it is determined whether the corresponding continuous storage domain segments meet the space request amount.

[0016] In some embodiments, the method further comprises:

[0017] In the case that no continuous storage domain segment that satisfies the space request amount can be found, recording the space request amount and the area range of the legal application area, and monitoring space release events;

[0018] In response to monitoring the space release event, a continuous storage domain segment is searched in the legal application area based on the space request amount until the continuous storage domain segment that meets the space request amount is found.

[0019] In some embodiments, the method comprises:

[0020] In response to receiving an initialization instruction for the storage space, acquiring area configuration information corresponding to the current storage scenario; the area configuration information includes an area size corresponding to each of the storage areas and a request amount range corresponding to each of the storage areas;

[0021] The storage space is divided into the at least two storage areas based on the area size corresponding to each of the storage areas, so as to complete the initialization of the storage space.

[0022] In some embodiments, obtaining the area configuration information corresponding to the current storage scenario includes:

[0023] Acquire the scene type of the current storage scene and the space size of the storage space;

[0024] The space size is input into the trained space division model corresponding to the scene type to obtain the area configuration information.

[0025] In some embodiments, the storage space includes a plurality of storage units; and the method includes:

[0026] In response to completing the initialization instruction for the storage space, the state flag of the storage unit in each of the storage areas is set to an unoccupied state.

[0027] In some embodiments, the method further comprises:

[0028] In response to allocating the target storage domain segment to the thread, a state flag of a storage unit in the target storage domain segment is set to an occupied state.

[0029] On the other hand, an embodiment of the present application provides a storage space management device, wherein the storage space includes at least two storage areas, and each storage area can respond to a different range of space request amounts, and the device includes:

[0030] A receiving module, configured to receive a space allocation request sent by a thread, and determine a space request amount for storage space by the space allocation request;

[0031] A determination module, configured to determine a legal application area in the storage space based on the space request amount and the request amount range corresponding to each storage area; the legal application area includes at least one storage area;

[0032] The allocation module is used to determine a target storage domain segment in the legal application area and allocate the target storage domain segment to the thread.

[0033] On the other hand, an embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be executed on the processor, and when the processor executes the program, some or all of the steps in the above method are implemented.

[0034] On the other hand, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which implements part or all of the steps in the above method when executed by a processor.

[0035] In an embodiment of the present application, since the current storage space is divided into at least two storage areas, each of the storage areas can respond to a different range of space request amounts. In this way, the legal application area related to the space request amount can be determined in the at least two storage areas based on the space request amount of the current space allocation request. Therefore, the embodiment of the present application can flexibly allocate according to different storage requirements, and space allocation requests with similar space request amounts correspond to the same legal application area. In this way, space allocation requests with similar space request amounts can be allocated as much as possible in similar areas of the storage space, thereby reducing the fragmentation of the storage space and improving space utilization.

[0036] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and are not intended to limit the technical solutions of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.

[0038] Figure 1 A schematic diagram of an implementation flow of a storage space management method provided in an embodiment of the present application;

[0039] Figure 2 A schematic diagram of an implementation flow of a storage space management method provided in an embodiment of the present application;

[0040] Figure 3 A schematic diagram of an implementation flow of a storage space management method provided in an embodiment of the present application;

[0041] Figure 4 A schematic diagram of an implementation flow of a storage space management method provided in an embodiment of the present application;

[0042] Figure 5 A schematic diagram of an implementation flow of a storage space management method provided in an embodiment of the present application;

[0043] Figure 6 A schematic diagram of the regional division of a storage space in an initial state provided by an embodiment of the present application;

[0044] Figure 7 A schematic diagram of a storage space area division situation after responding to a space allocation request provided in an embodiment of the present application;

[0045] Figure 8 A schematic diagram of the allocation of various areas in a storage space after several allocation and releases provided in an embodiment of the present application;

[0046] Fig.9AA schematic diagram of allocation of various areas in a storage space in response to a release event provided in an embodiment of the present application;

[0047] Fig. 9B A schematic diagram of the state of a storage space in a scenario where space is reallocated after waiting for allocation provided by an embodiment of the present application;

[0048] Fig.10 A schematic diagram of the structure of a storage space management device provided in an embodiment of the present application;

[0049] Fig.11 A hardware entity diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0050] In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions of the present application are further elaborated in detail below in conjunction with the drawings and embodiments. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0051] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict. The terms "first / second / third" involved are merely used to distinguish similar objects and do not represent a specific order for the objects. It is understood that "first / second / third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0052] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing this application and are not intended to limit this application.

[0053] The present application embodiment provides a storage space management method, which can be executed by a processor of a computer device. The computer device may refer to a server, a laptop, a tablet computer, a desktop computer, a smart TV, a set-top box, a mobile device (such as a mobile phone, a portable video player, a personal digital assistant, a dedicated messaging device, a portable gaming device), or other device with data processing capabilities.

[0054] Figure 1 A schematic diagram of the implementation process of a storage space management method provided in an embodiment of the present application is shown in FIG. Figure 1As shown, the method includes the following steps S101 to S103:

[0055] Step S101: receiving a space allocation request sent by a thread, and determining a space request amount of the space allocation request for storage space.

[0056] The storage space includes at least two storage areas, and each storage area can respond to a different range of space request amounts.

[0057] In some embodiments, the space allocation request is a request sent by a thread, which is used to request that a certain storage resource be allocated to the thread in the storage space. The space request amount is the amount of storage resources requested by the thread. In some embodiments, the space request amount can be directly set to the size of the required storage resources, such as 8kb, 32kb, etc.; the space request amount can also be a value after quantifying the resource amount based on the minimum resource unit. For example, when the minimum resource unit is 4kb, if the space allocation request requires 8kb of storage resources, the corresponding space request amount is 2, and if the space allocation request requires 32kb of storage resources, the corresponding space request amount is 8. In subsequent embodiments, the minimum resource unit is also called a storage unit, and the size of the storage unit can also be set to 2kb, 8kb, 16kb, 32kb, etc.

[0058] In some embodiments, the storage space has been divided into at least two storage areas, wherein the area sizes of each storage area in the at least two storage areas may be the same or different.

[0059] Exemplarily, taking the address range of the storage space as [0, 255] as an example, if the storage space needs to be divided into two storage areas, the result after equal division can be obtained: the first storage area is [0, 127], and the second storage area is [128, 255]. The result after unequal division can also be obtained: the first storage area is [0, 50], and the second storage area is [51, 255]. If the storage space needs to be divided into four storage areas, the result after equal division can be obtained: the first storage area is [0, 63], the second storage area is [64, 127], the third storage area is [128, 191], and the fourth storage area is [192, 255]. The result after unequal division can also be obtained: the first storage area is [0, 61], the second storage area is [62, 135], the third storage area is [136, 190], and the fourth storage area is [191, 255].

[0060] In some embodiments, the request amount range of the space request amount that the storage area can respond to represents the upper and lower limits of the space request amount that the storage area can respond to. If the space request amount corresponding to a space allocation request is within the upper and lower limits of the request amount range of the current storage area, it means that the current storage area can respond to the space allocation request.

[0061] In some embodiments, different storage areas can respond to space requests with different request amount ranges. Exemplarily, if the storage space is divided into N storage areas, N is greater than or equal to 2. Among them, the upper and lower limits of the space request amount of the space allocation request that the nth storage area can respond to are (An, Bn], and the upper and lower limits of the space request amount of the space allocation request that the n+1 storage area can respond to are (An+1, Bn+1], wherein the n+1th storage area is connected to the nth storage area, and at the same time, (An, Bn] does not overlap with (An+1, Bn+1]. In some implementation scenarios, Bn=An+1, so that no matter how large the request space of the space allocation request is, it can fall within the request amount range of any storage area.

[0062] Step S102: determining a legal application area in the storage space based on the space request amount and the request amount range corresponding to each storage area; the legal application area includes at least one storage area.

[0063] In some embodiments, the legal application area at least includes a storage area corresponding to the request amount range that the space request amount falls within. The legal application area is an area where storage resources can be allocated to the thread. It is understandable that for other areas in the storage space that are not the legal application area, storage resources cannot be allocated to the thread.

[0064] In some embodiments, the storage area corresponding to the request amount range within which the space request amount falls can be used as the legal application area.

[0065] Step S103: determining a target storage domain segment in the legal application area, and allocating the target storage domain segment to the thread.

[0066] In the embodiment of the present application, the target storage domain segment is a continuous memory segment located within the legal application area, and the target storage domain segment is in an unoccupied state.

[0067] In some embodiments, it is possible to obtain the free storage areas in the legal application area that are not occupied, and determine whether the area size of each free storage area meets the space request amount, determine the free storage area corresponding to the space request amount, and divide the space storage area into sub-areas with an area size of at least the space request amount as the target storage domain segment. After determining the free storage area corresponding to the space request amount, the low address boundary of the free storage area can be used as the low address boundary of the target storage domain segment, and the target storage domain segment is determined based on the space request amount and the low address boundary of the target storage domain segment. After determining the free storage area corresponding to the space request amount, the high address boundary of the free storage area can also be used as the high address boundary of the target storage domain segment, and the target storage domain segment is determined based on the space request amount and the high address boundary of the target storage domain segment.

[0068] In some embodiments, the low address boundary of the target storage domain segment can be directly sent to the thread, and the thread can find the starting address of the target storage domain segment in the storage space based on the low address boundary of the target storage domain segment, thereby completing the data storage process. In other embodiments, both the low address boundary and the high address boundary of the target storage domain segment can be sent to the thread, so that the thread can clearly understand the address range available in the storage space during the data storage process.

[0069] Based on the above embodiment, since the current storage space is divided into at least two storage areas, each storage area can respond to a different range of space request amounts. In this way, the legal application area related to the space request amount can be determined in the at least two storage areas based on the space request amount of the current space allocation request. Therefore, the embodiment of the present application can be flexibly allocated according to different storage requirements, and space allocation requests with similar space request amounts correspond to the same legal application area. In this way, space allocation requests with similar space request amounts can be allocated as much as possible in similar areas of the storage space, thereby reducing the fragmentation of the storage space and improving space utilization.

[0070] Figure 2 1 is a schematic diagram of an implementation flow of a storage space management method provided in an embodiment of the present application, and the method can be executed by a processor of a computer device. Figure 1 , the address sequence of each storage area in the storage space is related to the size sequence of the request amount range of each storage area; Figure 1 The S102 in can be updated to S201, which will be combined with Figure 2 The steps shown are explained.

[0071] Step S201, based on the space request amount and the request amount range corresponding to each of the storage areas, determine the legal application area in the at least two storage areas; the request amount range of the storage area in the legal application area is greater than the space request amount.

[0072] Among them, the above-mentioned legal application area includes a storage area corresponding to the request quantity range within which the space request quantity falls.

[0073] Exemplarily, when the request amount range corresponding to storage area 1 is [1, 12], the request amount range corresponding to storage area 2 is [13, 24], the request amount range corresponding to storage area 3 is [25, 37], the request amount range corresponding to storage area 4 is [38, 50], and the space request amount for the storage space in the current space allocation request is 26, the above-mentioned legal application area includes storage area 3.

[0074] Among them, the above-mentioned legal application area also includes the storage area where the space request amount does not fall into the request amount range, and the request amount range is larger than the storage area corresponding to the space request amount. In an embodiment of the present application, the address order of each of the storage areas in the storage space is related to the size order of the request amount range of each of the storage areas. Among them, the address order of each of the storage areas in the storage space is the same as the size order of the request amount range of each of the storage areas, or, the address order of each of the storage areas in the storage space is opposite to the size order of the request amount range of each of the storage areas.

[0075] Exemplarily, based on the above-mentioned example of storage area 1 to storage area 4, since the size order of the request amount range between storage area 1 and storage area 4 is: storage area 1 < storage area 2 < storage area 3 < storage area 4, therefore, the address order of each storage area in the storage space is: storage area 1 < storage area 2 < storage area 3 < storage area 4, or storage area 1 > storage area 2 > storage area 3 > storage area 4.

[0076] Exemplarily, based on the above-mentioned examples of storage areas 1 to 4, the storage area corresponding to the request amount range within which the space request amount falls is storage area 2, and the continuous area formed by storage area 2 and storage area 3 can be used as a legal application area; the continuous area formed by storage area 2, storage area 3 and storage area 4 can also be used as a legal application area.

[0077] Based on the above embodiment, due to the size order of the request amount range of each storage area, at least one continuous storage area that meets the above space request amount is searched in the storage space as the legal application area. In this way, space allocation requests with similar space request amounts can be allocated as much as possible in similar areas of the storage space, reducing the fragmentation of the storage space and improving space utilization.

[0078] In some embodiments, step S2011 can be used to implement the above-mentioned determination of the legal application area in the at least two storage areas based on the space request amount and the request amount range corresponding to each storage area.

[0079] Step S2011: All storage areas whose request amount range is greater than or equal to the space request amount are regarded as legal application areas.

[0080] In some embodiments, since the address order of each storage area in the storage space is related to the size order of the request amount range of each storage area, all storage areas with a request amount range greater than or equal to the space request amount must be continuously distributed, and then the continuous area formed by all storage areas with a request amount range greater than or equal to the space request amount can be used as the legal application area.

[0081] In some embodiments, after determining the storage area corresponding to the request amount range within which the space request amount falls, the low address boundary of the storage area within which the space request amount falls can be obtained, and the high address boundary corresponding to the storage space can be obtained; the area between the low address boundary and the high address boundary corresponding to the storage space is used as the legal application area.

[0082] Exemplarily, there are the following storage area allocation situations: the request amount range corresponding to storage area 1 is [1, 12], the request amount range corresponding to storage area 2 is [13, 24], the request amount range corresponding to storage area 3 is [25, 37], and the request amount range corresponding to storage area 4 is [38, 50]; the area range corresponding to storage area 1 is [1, 1000], the area range corresponding to storage area 2 is [1001, 2000], the area range corresponding to storage area 3 is [2001, 3000], and the area range corresponding to storage area 4 is [3001, 4000]. In the case that the storage area corresponding to the request amount range into which the space request amount falls is storage area 2, the low address boundary "1001" of the storage area can be obtained, and the high address boundary "4000" corresponding to the storage space can be obtained, and then the legal application area can be obtained as [1001, 4000]. It can be seen that the current legal application area includes storage area 2 to storage area 4.

[0083] Based on the above embodiment, since all storage areas with a request amount range greater than or equal to the space request amount are directly regarded as legal application areas, there is no need to perform other complex calculations and judgments. This can reduce the complexity of storage space management and improve the efficiency and accuracy of storage allocation.

[0084] Figure 3 1 is a schematic diagram of an implementation flow of a storage space management method provided in an embodiment of the present application, and the method can be executed by a processor of a computer device. Figure 1 , Figure 1 S103 in can be updated to S301 to S303, which will be combined Figure 3 The steps shown are explained.

[0085] Step S301: searching for continuous storage domain segments in the legal application area based on the space request amount.

[0086] The above step S301 is to search for a continuous storage space from the legal application area, that is, the continuous storage domain segment, and the size of the continuous storage domain segment needs to meet the space request amount.

[0087] In some embodiments, in order to find a suitable continuous storage domain segment within the legal application area, the above-mentioned search for continuous storage domain segments in the legal application area based on the space request amount can be implemented in the following way: traverse the status identifiers of each storage unit in the legal application area, and search for storage units in the legal application area whose status identifiers are all non-occupied; based on the storage units whose status identifiers are all non-occupied, count and obtain continuous storage domain segments with an area size greater than or equal to the space request amount.

[0088] In some embodiments, the above-mentioned search for continuous storage domain segments in the legal application area based on the space request amount can be implemented through step S3011.

[0089] Step S3011, based on the order of addresses from low to high, obtain continuous storage domain segments from the legal application area in sequence, and determine whether the corresponding continuous storage domain segments meet the space request amount.

[0090] Here, for each address in the legal application area, in order from low to high, the current address is used as the low address boundary, and the continuous storage domain segment corresponding to the low address boundary is determined, wherein the status identifiers of each storage unit in the continuous storage domain segment are all in a non-occupied state; the size relationship between the continuous storage domain segment and the space request amount is judged, and when the size of the continuous storage domain segment is greater than or equal to the space request amount, it is determined that it satisfies the space request amount.

[0091] Step S302: when a continuous storage domain segment that satisfies the space request amount is found, the continuous storage domain segment is allocated to the thread as a target storage domain segment.

[0092] In the above embodiment, the target storage domain segment is selected as the storage segment allocated to the thread when a continuous storage domain segment that satisfies the space request amount is found.

[0093] Based on the above embodiment, by searching for the target storage domain segment based on the space request amount in the legal application area, the search range of the storage space can be reduced and the efficiency of searching for the target storage domain segment can be improved. At the same time, the target storage domain segment found will not be distributed in the storage area whose request amount range is smaller than the space request amount. To a certain extent, the storage resource allocation amounts in each storage area in the storage space are closer, reducing the problem of storage space fragmentation.

[0094] In some embodiments, the method further includes steps S303 to S304.

[0095] Step S303: When no continuous storage domain segment that satisfies the space request amount is found, the space request amount and the area range of the legal application area are recorded, and space release events are monitored.

[0096] In the embodiment of the present application, if the continuous storage domain segment that meets the space request amount cannot be found, it means that the current storage space does not have the resource conditions to allocate the target storage domain segment for the space allocation request. At this time, it is necessary to record the space request amount corresponding to the current space allocation request and the area range of the legal application area, so as to re-execute step S301 later.

[0097] In some embodiments, there are target storage domain segments in the storage space that are not allocated by other threads (other space allocation requests), and in response to other threads releasing the corresponding target storage domain segments, the space release event is generated.

[0098] Step S304: In response to detecting the space release event, searching for a continuous storage domain segment in the legal application area based on the space request amount until the continuous storage domain segment that meets the space request amount is found.

[0099] In the embodiment of the present application, the space release event is a space release event for the legal application area, that is, the space release event for the legal application area updates the status identifier of the storage unit in the legal application area.

[0100] It can be understood that the space release event for the legal application area is to update at least one storage unit in the legal application area from an occupied state to an unoccupied state. At this time, the search for continuous storage domain segments in the legal application area based on the space request amount is re-executed, that is, the above step S301 is re-executed.

[0101] In some embodiments, if the target storage domain segment has not been found, the space release event is continuously monitored, that is, steps S303 to S304 are re-executed.

[0102] Based on the above embodiment, by recording the space request amount corresponding to the current space allocation request and the area range of the legal application area, when there is a subsequent space release event, the step of searching for the target storage domain segment in the legal application area can be restarted in time, thereby improving the response speed to the space allocation request.

[0103] Figure 4 1 is a schematic diagram of an implementation flow of a storage space management method provided in an embodiment of the present application, and the method can be executed by a processor of a computer device. Figure 1 The method may further include S401 to S402, combining Figure 4 The steps shown are explained.

[0104] Step S401, in response to receiving an initialization instruction for the storage space, obtaining area configuration information corresponding to the current storage scenario; the area configuration information includes an area size corresponding to each of the storage areas and a request amount range corresponding to each of the storage areas.

[0105] In some embodiments, before the storage space is initialized, the storage space does not include the above storage areas, that is, before initialization, the storage space can be regarded as a continuous area. In order to facilitate the subsequent reasonable allocation of the storage space and minimize storage fragmentation, it is necessary to initialize the storage space, that is, divide the storage space into at least two storage areas, and perform subsequent segment management.

[0106] In the embodiment of the present application, the area configuration information includes the area size corresponding to each of the storage areas and the request amount range corresponding to each of the storage areas. The area size can be the proportion information of each storage area relative to the storage space, or the ratio information between each storage area, or the actual area size information of each storage area, which is not limited in the embodiment of the present application. The request amount range corresponding to the storage area is the range of space request amounts corresponding to the space allocation request that can be responded to.

[0107] In the embodiment of the present application, for different storage scenarios, the area configuration information for the storage space is also different. The area configuration information corresponding to the current storage scenario is related to the distribution of the space request amount of the space allocation request in the current storage scenario.

[0108] In some embodiments, when the space request amounts corresponding to each space allocation request in a storage scenario are relatively dispersed, the number of storage areas in the storage scenario is relatively large; the range of request amounts corresponding to each storage area in the storage scenario is relatively large; the range of request amounts corresponding to each storage area in the storage scenario is roughly the same; and the area sizes corresponding to each storage area in the storage scenario are roughly the same.

[0109] In some embodiments, when the space request amounts corresponding to each space allocation request in a storage scenario are relatively concentrated, the number of storage areas in the storage scenario is relatively small; the request amount range corresponding to each storage area in the storage scenario is relatively small; among the storage areas in the storage scenario, the request amount range is smaller where the space request amounts are relatively concentrated, and the request amount range is larger where the space request amounts are relatively dispersed; among the storage areas in the storage scenario, the area size is larger where the space request amounts are relatively concentrated, and the area size is smaller where the space request amounts are relatively dispersed.

[0110] Based on the above embodiments, the embodiments of the present application set different area configuration information for different storage scenarios. Furthermore, after receiving the initialization for the storage space, the area configuration information corresponding to the current storage scenario can be obtained from the area configuration information corresponding to the preset multiple storage scenarios.

[0111] In some embodiments, the above-mentioned obtaining the area configuration information corresponding to the current storage scene includes: obtaining the scene type of the current storage scene and the space size of the storage space; inputting the space size into the trained space division model corresponding to the scene type to obtain the area configuration information.

[0112] Among them, the scenario type of the current storage scenario is used to characterize that the space requirements corresponding to the space allocation request of the current storage scenario are different. Exemplarily, there are the following two storage scenarios: in the first storage scenario, the space requirements of the received space allocation request are evenly distributed between 1 and 50 storage units, for example, 25% of the space requirements are between 1 and 12 storage units, 25% of the space requirements are between 13 and 24 storage units, 25% of the space requirements are between 25 and 37 storage units, and 25% of the space requirements are between 38 and 50 storage units. In the second storage scenario, the space requirements of the received space allocation request are more concentrated between 13 and 24 storage units, for example, 5% of the space requirements are between 1 and 12 storage units, 55% of the space requirements are between 13 and 24 storage units, 25% of the space requirements are between 25 and 37 storage units, and 15% of the space requirements are between 38 and 50 storage units.

[0113] In some embodiments, different space division models can be pre-trained for different scene types. The training process includes: for each scene type, a large number of data samples are collected, the data samples include the space requirement and the size of the storage space (and may also include the distribution status of the storage units in the storage space); a corresponding label is generated for each data sample, indicating the optimal space division scheme corresponding to the sample data; feature extraction is performed on the data samples (space requirement and the size of the storage space) as the input of the model; and a machine learning algorithm (such as a neural network, a decision tree, etc.) is used to train the space division model for each scene type. In this way, the space division model for different scene types can be obtained, and then the space requirement and division relationship for different scenes can be determined.

[0114] In this way, by inputting the space size into the trained space division model corresponding to the scene type, the region configuration information that meets the division standard can be obtained.

[0115] Step S402: Divide the storage space into the at least two storage areas based on the area size corresponding to each of the storage areas, so as to complete initialization of the storage space.

[0116] In some embodiments, the storage space may be divided into the at least two storage areas based on the proportion information of each storage area. After the area division is completed, the area range corresponding to each storage area may be obtained, and the area range is determined by the low address boundary and the high address boundary of the storage area.

[0117] For example, if the address range of the storage space is [0, 255], and the storage space needs to be divided into four storage areas, the first storage area is [0, 63], the second storage area is [64, 127], the third storage area is [128, 191], and the fourth storage area is [192, 255]. It can be seen that the area range of each storage area is determined by the low address boundary and the high address boundary.

[0118] In some embodiments, the storage area includes a plurality of storage cells, that is, the storage area is composed of storage cells.

[0119] In order to facilitate understanding of the scheme of initializing with different area configuration information for different storage scenarios in the embodiment of the present application, the scheme of the present application will be described below with two storage scenarios (not limiting the scope of application of the present application). The storage space includes 4000 storage units, and the maximum space requirement of the space allocation request in these two storage scenarios is 50 storage units, and the minimum space requirement is 1 storage unit.

[0120] In the first storage scenario, the space requirements of the received space allocation requests are evenly distributed between 1 and 50 storage units. For example, 25% of the space requirements are between 1 and 12 storage units, 25% of the space requirements are between 13 and 24 storage units, 25% of the space requirements are between 25 and 37 storage units, and 25% of the space requirements are between 38 and 50 storage units. In the first storage scenario, the corresponding area configuration information includes: it needs to be divided into 4 storage areas (storage area 1, storage area 2, storage area 3, storage area 4), storage areas 1 to 4 each occupy 25% of the storage space, the request range corresponding to storage area 1 is [1, 12], the request range corresponding to storage area 2 is [13, 24], the request range corresponding to storage area 3 is [25, 37], and the request range corresponding to storage area 4 is [38, 50]. After dividing the storage space based on the area configuration information, it can be obtained that the area range corresponding to storage area 1 is [1, 1000], the area range corresponding to storage area 2 is [1001, 2000], the area range corresponding to storage area 3 is [2001, 3000], and the area range corresponding to storage area 4 is [3001, 4000].

[0121] In the second storage scenario, the space requirements of the received space allocation requests are concentrated between 13 and 24 storage units. For example, 5% of the space requirements are between 1 and 12 storage units, 55% of the space requirements are between 13 and 24 storage units, 25% of the space requirements are between 25 and 37 storage units, and 15% of the space requirements are between 38 and 50 storage units. In the second storage scenario, the corresponding area configuration information includes: it needs to be divided into 4 storage areas (storage area 1, storage area 2, storage area 3, storage area 4), the area size corresponding to storage area 1 is 5% of the storage space, the area size corresponding to storage area 2 is 55% of the storage space, the area size corresponding to storage area 3 is 25% of the storage space, and the area size corresponding to storage area 4 is 15% of the storage space; the request amount range corresponding to storage area 1 is [1, 12], the request amount range corresponding to storage area 2 is [13, 24], the request amount range corresponding to storage area 3 is [25, 37], and the request amount range corresponding to storage area 4 is [38, 50]. After the storage space is divided based on the area configuration information, it can be obtained that the area range corresponding to storage area 1 is [1, 200], the area range corresponding to storage area 2 is [201, 2400], the area range corresponding to storage area 3 is [2401, 3000], and the area range corresponding to storage area 4 is [3001, 4000].

[0122] Based on the above embodiment, by obtaining the area configuration information corresponding to the current storage scenario and completing the division of at least two storage areas based on the area configuration information, the storage area can be dynamically configured according to actual needs to adapt to different storage scenarios. The dynamic configuration scheme can improve the flexibility and adaptability of the system; at the same time, since the area configuration information includes the area size and request amount range of each storage area, the capacity of each storage area and the range of request amounts that can be responded to can be clarified, thereby improving initialization efficiency and storage efficiency.

[0123] In some embodiments, in order to facilitate identification of the storage status of each storage unit in the storage area, the embodiments of the present application set a corresponding status identifier for each storage unit to determine whether the storage unit is in an occupied state or an unoccupied state.

[0124] Based on this, in some embodiments, the method may further include step S403.

[0125] Step S403: In response to completing the initialization instruction for the storage space, setting the state flag of the storage unit in each storage area to an unoccupied state.

[0126] In an embodiment of the present application, after the initialization instruction for the storage space is completed, a state flag representing an unoccupied state is added to all storage units in the storage space. In some embodiments, the state flag representing the unoccupied state can be represented by a first value, and illustratively, the first value can be set to 0.

[0127] It can be understood that, from the perspective of the storage area, after the initialization instruction for the storage space is completed, the status flags of all storage units in the storage area are also configured to be unoccupied.

[0128] Based on the above embodiments, by initializing the storage space and setting the storage unit status identifier, the occupancy of the storage area can be quickly determined; at the same time, by setting the storage unit status identifier, the usage of the storage unit can be conveniently tracked and managed. In this way, the storage space can be better organized and allocated, simplifying the workflow of storage resource management.

[0129] In some embodiments, the method may further include step S404.

[0130] Step S404: In response to allocating the target storage domain segment to the thread, setting the state flag of the storage unit in the target storage domain segment to an occupied state.

[0131] In an embodiment of the present application, after the target storage domain segment is assigned to the thread, the state identifiers of all storage units in the target storage domain segment are switched from a non-occupied state to an occupied state. In some embodiments, the state identifier characterizing the occupied state can be represented by a second value, and illustratively, the second value can be set to 1.

[0132] Based on the above embodiment, since the state flag of the storage unit is switched to the occupied state after the target storage domain segment is allocated to the thread, conflicts and data corruption can be effectively prevented, thereby improving stability and data security.

[0133] The following describes the application of the storage space management method provided in the embodiment of the present application in actual scenarios.

[0134] The specific working process of the existing technical solution is: when a thread starts or after the thread starts, the thread will send a space allocation request to the memory management module. When the memory management module receives the space allocation request, it will find and allocate a space equal to the requested space according to the current space allocation and usage status in the memory. This space is physically or logically continuous on the memory for use by the thread within its life cycle; before or when the thread ends, a release request for this space is sent to the memory management module, and the memory management module releases the corresponding area; since there are many threads and many types of threads in the GPU, the space allocation request received by the memory management module, the release time, the length of time different threads use this memory, and the space will be different, resulting in space fragmentation. That is, at a certain moment, unallocated space and allocated space will appear alternately. If the space size requested in the current space allocation request is relatively large and smaller than the total unallocated space, but since the unallocated space may be multiple and discontinuous, the memory management module may not be able to allocate the corresponding continuous space for the current space allocation request, resulting in low storage space utilization and wasting precious memory resources.

[0135] In the embodiment provided in the present application, the memory is divided into several continuous areas through typical scenario training, and the space size in each continuous area is different. At the same time, two parameters are set for each continuous area, including: the range of requested space size of a single space allocation request that can be responded to (corresponding to the space request amount in the above embodiment), and the size of the continuous area.

[0136] In some embodiments, from the perspective of the memory, the range of the request space size that can be responded to the space allocation request becomes larger from the low address range to the high address range of the memory; in the actual implementation process, the memory management module searches for the target continuous area in the above-mentioned several continuous areas according to the size of the request space of the single space allocation request, wherein the size of the request space is within the range of the request space size of the single space allocation request that the target continuous area can respond to; then, searches from the low address of the target continuous area to the high address of the memory (total space) in sequence.

[0137] Based on the method provided by the above embodiment, in the actual working process, each space allocation request with similar request space size will be allocated in the same or similar area. The reason is that the request space of a single space allocation request is similar in size, and the resulting unallocated space will have a greater probability of being responded to by the memory management module. Overall, the storage space allocation in the memory will be more compact, avoiding the continuous allocation of smaller or larger spaces in space.

[0138] See also Figure 5 , which shows a flow chart of a storage space management method.

[0139] Step S501, divide the storage space into at least two continuous areas (corresponding to the storage areas in the above embodiment); each continuous area corresponds to a response range, and the response range corresponding to the continuous area (corresponding to the request amount range in the above embodiment) is related to the position of the continuous area in the storage space.

[0140] Among them, the entire storage space is divided into several continuous areas, and the size of each continuous area and the size range of the request space of a single space allocation request that each continuous area can respond to are determined through model training or statistical law analysis (it should be noted that the size ranges of the request spaces responded to by each continuous area do not overlap); from the perspective of the memory, from the low address to the high address of the memory, the range of the request space size that can be responded to the space allocation request becomes larger in sequence.

[0141] Exemplarily, if the storage space is divided into N continuous areas, the size range of the request space of a single space allocation request that the nth continuous area can respond to is (An, Bn], and the size range of the request space of a single space allocation request that the n+1 continuous areas can respond to is (An+1, Bn+1], wherein the n+1th continuous area is connected to the nth continuous area, and at the same time, (An, Bn] and (An+1, Bn+1] do not overlap. In some implementation scenarios, Bn=An+1, so that no matter how large the request space of a single space allocation request is, it can fall within the response range of any continuous area.

[0142] Step S502: The memory management module waits for a space allocation request.

[0143] After the thread sends a space allocation request to the memory management module, step S503 is executed.

[0144] Step S503, in response to the space allocation request, the memory management module determines a target continuous area in at least two continuous areas based on the size of the request space of the space allocation request, and uses the lower address boundary of the target continuous area to the highest address boundary of the storage space as the legal application area corresponding to the space allocation request.

[0145] Among them, a corresponding memory management module is configured for the memory, and the memory management module is used to receive the space allocation request of the thread, find the corresponding target continuous area in the divided continuous area according to the size of the request space of the space allocation request, and use the low address boundary of the target continuous area to the highest address boundary of the memory as the legal application area corresponding to the space allocation request.

[0146] Step S504: The memory management module searches for continuous unoccupied space (corresponding to the target storage domain segment in the above embodiment) from the lower address to the higher address of the legal application area.

[0147] Step S505: The memory management module determines whether there is an unoccupied space that satisfies the size of the requested space of the above space allocation request.

[0148] When an unoccupied space is found that satisfies the size of the requested space of the space allocation request, step S506 is executed.

[0149] Step S506: Return the starting address of the unoccupied space found as the base address to the thread.

[0150] Among them, the memory management module searches sequentially from the low address to the high address of the legal application area. If there is a continuous unoccupied continuous space starting from a certain address, the size of which is greater than or equal to the size of the request space of the space allocation request, this address is the base address of the space allocation request, and the memory management module returns this base address to the thread.

[0151] If there is no unoccupied space that satisfies the size of the requested space of the space allocation request, step S507 is executed.

[0152] Step S507, the memory management module records the legal application area corresponding to the space allocation request, and waits, and in response to receiving a space release request within the legal application area, returns to execute step S504 until an unoccupied space is found in the legal application area that meets the size of the requested space of the above space allocation request.

[0153] If not found, the memory management module waits and records the legal application area range found in step 3. When there is a request to release space in the legal application area range as a trigger event, the trigger event will repeat steps S504 and S505 until a suitable area response request thread is found.

[0154] To facilitate understanding of the embodiments of the present application, the storage space management method will be described below using a storage space with 256 granularity units (corresponding to the storage units in the above embodiments) and each granularity being 8 bytes as an example.

[0155] See also Figure 6 , which shows a schematic diagram of the regional division of a storage space. Figure 6 As shown, the entire storage unit is divided into four areas, and the configuration of the four areas is shown in Table 1.

[0156] Table 1

[0157]

[0158] Step 1: The memory management module initializes the storage space and sets the space allocation status of each divided area to unoccupied.

[0159] Among them, Figure 6 As shown, the memory management module initializes the storage space based on the area configuration information in Table 1, and sets the space allocation status of each divided area to unoccupied.

[0160] Step 2: Wait for the space allocation request of the receiving thread.

[0161] Step 3: The memory management module receives a space allocation request with a requested space size of 3, and detects that the request with a requested space size of 3 belongs to the response range set by area 1. Therefore, the address range of the legal application area of ​​the space allocation request is from the lowest boundary address 0 of area 1 to the highest boundary address 255 of the storage space. It can be understood that the current legal application area is area 1 to area 4, and the address range is 0 to 255.

[0162] Step 4: The memory management module searches from the low address to the high address of the legal application area and finds that there are three consecutive unallocated granularity units starting from the target address (since initialization has just been completed at this time, the target address is 0) in the direction of the high address. Therefore, the target address is returned as the base address of this request, and the three allocated granularity units are set to occupied status.

[0163] See also Figure 7 , compared to Figure 6 , 3 granularity units in region 1 are set to occupied state, and the remaining granularity units in region 1 are still in unoccupied state.

[0164] After several allocation and release, if no continuous unoccupied space greater than or equal to the number of requested granularity units can be found from the low address to the high address of the legal application area, the size of the requested space and the legal application area in this space allocation request are stored, the application is considered to have failed, and the process goes to step five.

[0165] See also Figure 8, which shows a schematic diagram of the allocation of various areas in the storage space after several allocations and releases. A space allocation request with a requested space size of 12 is received. Based on the method provided in the above embodiment, it can be known that the legal application areas corresponding to the current space allocation request are area 3 and area 4, and the address range is 40 to 255. If no continuous unoccupied space greater than or equal to "12" can be found from the low address to the high address direction (40 to 255) of the legal application area, the requested size "12" of the requested space in this space allocation request and the legal retrieval application area "area 3 and area 4, the address range is 40 to 255" are stored.

[0166] Step 5: Monitor the request to release the storage space. If there is a release event, jump to step 4.

[0167] Based on the above example, in response to the space release request corresponding to area 3 or area 4, step 4 is re-executed. For example, the "15" granularity units in area 3 are released by the corresponding thread. At this time, the storage space can be represented as Fig.9A In the state shown, during the execution of step 4, the "15" granularity units can be found in area 3 as continuous unoccupied space, and the lowest address boundary of the space is returned to the corresponding thread as the base address. Fig. 9B , which shows a schematic diagram of the state of storage space in a scenario of waiting for allocation and then reallocation of space. It can be seen that "12" of the "15" granularity units that were originally unoccupied have been occupied, and there are remaining "3" granularity units of unoccupied space in area 3, as well as the remaining unoccupied space in the historical allocation process.

[0168] It should be noted that the above-mentioned release event can not only appear in step five. In the hardware implementation of GPU, allocation and release are two parallel independent events. In each step of normal operation, the release request may be sent at any time, and the hardware can handle it, that is, mark the state of the storage unit to be released as unoccupied, and generate a storage release event signal for use in step five.

[0169] Based on the above embodiment, several space allocation requests requiring space of similar size can be placed in the same or similar area. After several application releases, the unoccupied space generated can be allocated by the memory management module to the space allocation request matching the unoccupied space with a higher probability, so that space allocation requests of similar size are placed in relatively close positions, thereby improving space utilization.

[0170] In other embodiments, the granularity unit in the above embodiments may also be a memory page, which is not limited in this application.

[0171] Compared with the related art, the embodiment of the present application reduces the problem of allocating smaller storage spaces and cutting the overall storage space into pieces through storage partitioning; at the same time, based on the embodiment of the present application, allocations of similar sizes can be distributed as closely as possible, thereby avoiding the problem of large fragmentation in existing solutions and improving resource utilization.

[0172] Based on the foregoing embodiments, an embodiment of the present application provides a storage space management device, which includes the units included and the modules included in the units, and can be implemented by a processor in a computer device; of course, it can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA), etc.

[0173] Fig.10 A schematic diagram of the structure of a storage space management device provided in an embodiment of the present application is shown in FIG. Fig.10 As shown, the storage space management device 1000 includes: a receiving module 1010, a determining module 1020, and an allocating module 1030, wherein:

[0174] A receiving module 1010 is used to receive a space allocation request sent by a thread, and determine a space request amount of the space allocation request for the storage space;

[0175] A determination module 1020, configured to determine a legal application area in the storage space based on the space request amount and the request amount range corresponding to each storage area; the legal application area includes at least one storage area;

[0176] The allocation module 1030 is used to determine a target storage domain segment in the legal application area and allocate the target storage domain segment to the thread.

[0177] In some embodiments, the address order of each storage area in the storage space is related to the size order of the request amount range of each storage area.

[0178] In some embodiments, the determining module 1020 is further configured to:

[0179] Based on the space request amount and the request amount range corresponding to each of the storage areas, the legal application area is determined in the at least two storage areas; the request amount range of the storage area in the legal application area is greater than or equal to the space request amount.

[0180] In some embodiments, the determination module 1020 is further used to: take all storage areas whose request amount range is greater than or equal to the space request amount as legal application areas.

[0181] In some embodiments, the allocation module 1030 is further configured to:

[0182] Searching for a continuous storage domain segment in the legal application area based on the space request amount;

[0183] When a continuous storage domain segment that satisfies the space request amount is found, the continuous storage domain segment is allocated to the thread as a target storage domain segment.

[0184] In some embodiments, the allocation module 1030 is further used to: obtain continuous storage domain segments from the legal application area in sequence based on the address from low to high, and determine whether the corresponding continuous storage domain segments meet the space request amount.

[0185] In some embodiments, the allocation module 1030 is further configured to:

[0186] In the case that no continuous storage domain segment that satisfies the space request amount can be found, recording the space request amount and the area range of the legal application area, and monitoring space release events;

[0187] In response to monitoring the space release event, a continuous storage domain segment is searched in the legal application area based on the space request amount until the continuous storage domain segment that meets the space request amount is found.

[0188] In some embodiments, the storage space management device 1000 includes an initialization module;

[0189] The initialization module is used to: in response to receiving an initialization instruction for the storage space, obtain area configuration information corresponding to the current storage scenario; the area configuration information includes an area size corresponding to each of the storage areas and a request amount range corresponding to each of the storage areas;

[0190] The storage space is divided into the at least two storage areas based on the area size corresponding to each of the storage areas, so as to complete the initialization of the storage space.

[0191] In some embodiments, the initialization module is further used to:

[0192] Acquire the scene type of the current storage scene and the space size of the storage space;

[0193] The space size is input into the trained space division model corresponding to the scene type to obtain the area configuration information.

[0194] In some embodiments, the storage space includes a plurality of storage units; the initialization module is further used to:

[0195] In response to completing the initialization instruction for the storage space, the state flag of the storage unit in each of the storage areas is set to an unoccupied state.

[0196] In some embodiments, the allocation module 1030 is further configured to:

[0197] In response to allocating the target storage domain segment to the thread, a state flag of a storage unit in the target storage domain segment is set to an occupied state.

[0198] The description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. In some embodiments, the functions or modules included in the device provided in the embodiment of the present application can be used to execute the method described in the above method embodiment. For technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.

[0199] It should be noted that in the embodiment of the present application, if the above-mentioned storage space management method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, which is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific hardware, software or firmware, or any combination of hardware, software, and firmware.

[0200] An embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, some or all of the steps in the above method are implemented.

[0201] The embodiment of the present application provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, some or all of the steps in the above method are implemented. The computer-readable storage medium can be transient or non-transient.

[0202] An embodiment of the present application provides a computer program, including a computer-readable code. When the computer-readable code is run in a computer device, a processor in the computer device executes some or all of the steps for implementing the above method.

[0203] The embodiment of the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and when the computer program is read and executed by a computer, some or all of the steps in the above method are implemented. The computer program product can be implemented specifically by hardware, software or a combination thereof. In some embodiments, the computer program product is specifically embodied as a computer storage medium, and in other embodiments, the computer program product is specifically embodied as a software product, such as a software development kit (SDK) and the like.

[0204] It should be noted here that the description of the various embodiments above tends to emphasize the differences between the various embodiments, and the same or similar aspects can be referenced to each other. The description of the above device, storage medium, computer program and computer program product embodiments is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the embodiments of the device, storage medium, computer program and computer program product of this application, please refer to the description of the method embodiment of this application for understanding.

[0205] Fig.11 A hardware entity diagram of a computer device provided in an embodiment of the present application is shown in FIG. Fig.11 As shown, the hardware entity of the computer device 1100 includes: a processor 1101 and a memory 1102, wherein the memory 1102 stores a computer program that can be run on the processor 1101, and the processor 1101 implements the steps in the method of any of the above embodiments when executing the program.

[0206] The memory 1102 stores computer programs that can be run on the processor. The memory 1102 is configured to store instructions and applications executable by the processor 1101. It can also cache data to be processed or processed by the processor 1101 and various modules in the computer device 1100 (for example, image data, audio data, voice communication data, and video communication data). This can be achieved through flash memory (FLASH) or random access memory (Random Access Memory, RAM).

[0207] When the processor 1101 executes the program, the steps of any of the above storage space management methods are implemented. The processor 1101 generally controls the overall operation of the computer device 1100.

[0208] An embodiment of the present application provides a computer storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps of the storage space management method of any of the above embodiments.

[0209] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.

[0210] The processor may be at least one of an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a Central Processing Unit (CPU), a controller, a microcontroller, and a microprocessor. It is understandable that the electronic device that implements the functions of the processor may also be other, and the embodiments of the present application are not specifically limited.

[0211] The above-mentioned computer storage medium / memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory (Flash Memory), a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM) and the like; it can also be various terminals including one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc.

[0212] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the serial number of each step / process mentioned above does not mean the order of execution, and the execution order of each step / process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application. The serial numbers of the embodiments of the present application mentioned above are for description only and do not represent the advantages and disadvantages of the embodiments.

[0213] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0214] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0215] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0216] In addition, all functional units in the embodiments of the present application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the above integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional units. A person of ordinary skill in the art can understand that all or part of the steps of the above method embodiments can be completed by hardware related to program instructions, and the above program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above method embodiments are executed; and the above storage medium includes: mobile storage devices, read-only memory (ROM), disks or optical disks, etc., which can store program codes.

[0217] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.

[0218] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.

Claims

1. A storage space management method, characterized in that: The storage space includes at least two storage areas, and the space request amount responded by each storage area has a different request amount range. The method includes: receiving a space allocation request sent by a thread, and determining a space request amount of the space allocation request for storage space; Based on the space request amount and the request amount range corresponding to each of the storage areas, determining a legal application area in the storage space; the legal application area at least includes a storage area corresponding to the request amount range within which the space request amount falls; Determine a target storage domain segment in the legal application area, and allocate the target storage domain segment to the thread; In response to allocating the target storage domain segment to the thread, a state flag of a storage unit in the target storage domain segment is set to an occupied state.

2. The method according to claim 1, characterized in that The address sequence of each storage area in the storage space is related to the size sequence of the request amount range of each storage area.

3. The method according to claim 2, characterized in that The determining of a legal application area in the storage space based on the space request amount and the request amount range corresponding to each storage area includes: Based on the space request amount and the request amount range corresponding to each of the storage areas, the legal application area is determined in the at least two storage areas; the request amount range of the storage area in the legal application area is greater than or equal to the space request amount.

4. The method according to claim 2, characterized in that: The determining the legal application area in the at least two storage areas based on the space request amount and the request amount range corresponding to each storage area includes: All storage areas whose request amount range is greater than or equal to the space request amount are regarded as legal application areas.

5. The method according to any one of claims 1 to 4, characterized in that: The step of determining a target storage domain segment in the legal application area and allocating the target storage domain segment to the thread comprises: Searching for a continuous storage domain segment in the legal application area based on the space request amount; When a continuous storage domain segment that satisfies the space request amount is found, the continuous storage domain segment is allocated to the thread as a target storage domain segment.

6. The method according to claim 5, characterized in that The searching for a continuous storage domain segment in the legal application area based on the space request amount includes: Based on the order of addresses from low to high, continuous storage domain segments are obtained from the legal application area in sequence, and it is determined whether the corresponding continuous storage domain segments meet the space request amount.

7. The method according to claim 5, characterized in that The method further comprises: In the case that no continuous storage domain segment that satisfies the space request amount can be found, recording the space request amount and the area range of the legal application area, and monitoring space release events; In response to monitoring the space release event, a continuous storage domain segment is searched in the legal application area based on the space request amount until the continuous storage domain segment that meets the space request amount is found.

8. The method according to any one of claims 1 to 4, characterized in that: The method comprises: In response to receiving an initialization instruction for the storage space, acquiring area configuration information corresponding to the current storage scenario; the area configuration information includes an area size corresponding to each of the storage areas and a request volume range corresponding to each of the storage areas; The storage space is divided into the at least two storage areas based on the area size corresponding to each of the storage areas, so as to complete the initialization of the storage space.

9. The method according to claim 8, characterized in that The obtaining of the area configuration information corresponding to the current storage scenario includes: Acquire the scene type of the current storage scene and the space size of the storage space; The space size is input into the trained space division model corresponding to the scene type to obtain the area configuration information.

10. The method according to claim 8, characterized in that The storage space includes a plurality of storage units; the method includes: In response to completing the initialization instruction for the storage space, the state flag of the storage unit in each of the storage areas is set to an unoccupied state.

11. A storage space management device, characterized in that: The storage space includes at least two storage areas, and the space request amount responded by each storage area has a different request amount range. The device includes: A receiving module, configured to receive a space allocation request sent by a thread, and determine a space request amount for storage space by the space allocation request; A determination module, configured to determine a legal application area in the storage space based on the space request amount and the request amount range corresponding to each of the storage areas; the legal application area at least includes a storage area corresponding to the request amount range within which the space request amount falls; An allocation module, used for determining a target storage domain segment in the legal application area and allocating the target storage domain segment to the thread; In response to allocating the target storage domain segment to the thread, a state flag of a storage unit in the target storage domain segment is set to an occupied state.

12. A computer device comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, wherein: When the processor executes the program, the steps in the method according to any one of claims 1 to 10 are implemented.

13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps in the method according to any one of claims 1 to 10 are implemented.

Citation Information

Patent Citations

  • Memory management method, system and device and readable storage medium

    CN113010453A