Resource compression method and device and electronic equipment

By adjusting the frequency critical value and compressing the resources that are not frequently accessed, the problem of the ineffective utilization of free memory space in the prior art is solved, and the equipment performance is improved.

CN119127453APending Publication Date: 2024-12-13TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310695435.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-12
Publication Date
2024-12-13

AI Technical Summary

Technical Problem

In the case of tight memory space, the prior art is difficult to effectively match the freed free memory space to the application's needs, resulting in a degradation of device performance.

Method used

By obtaining the space allocation request for free space, adjusting the frequency threshold to determine the target frequency, compressing the resources that are not frequently accessed, and freeing the target free space matching the application.

Benefits of technology

It effectively utilizes the free free memory space, improves the performance of the device, and ensures that the free space matches the needs of the application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119127453A_ABST
    Figure CN119127453A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a resource compression method and device and electronic equipment. The method can be applied to the field of storage reading, and comprises the steps of obtaining a space allocation request for a free space; adjusting the frequency critical value based on the failure rate of the space allocation request to obtain an adjusted frequency critical value; obtaining the accessed frequency of the to-be-allocated resource; determining a target frequency from the accessed frequencies based on the adjusted frequency critical value, and obtaining to-be-compressed resources corresponding to the target frequency in the to-be-allocated resources; and compressing the to-be-compressed resource to obtain a target free space released after the to-be-compressed resource is compressed. In the embodiment of the invention, the released free space can reduce the failure rate of the space allocation request. Therefore, the released target free space can be matched with the space allocation request initiated when the application program runs, so that the released target free space can be effectively utilized by the application program, and the performance of equipment can be improved by the scheme.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and in particular to a resource compression method, device and electronic equipment. Background Art

[0002] When memory space is tight, cold memory compression (CMC) is used to compress or move rarely used resources to disk for storage, thereby freeing up more free memory space for other applications to use.

[0003] However, after the current resources are compressed, the free memory space released is difficult to match the needs of the application, resulting in the free memory space being unable to be effectively used by the application, affecting the performance of the device. Summary of the invention

[0004] The embodiments of the present application provide a resource compression method, device, and electronic device, which can enable released free memory space to be effectively used by applications and improve the performance of the device.

[0005] The present application provides a resource compression method, including:

[0006] Obtain a space allocation request for free space, where the free space is unoccupied memory space, and the space allocation request is used to request the use of the free space;

[0007] Based on the failure rate of the space allocation request, the frequency threshold is adjusted to obtain an adjusted frequency threshold, wherein the failure rate is a ratio of the space allocation requests that are not satisfied;

[0008] Obtain the access frequency of the resources to be allocated;

[0009] Based on the adjusted frequency critical value, determine the target frequency from the accessed frequencies, and obtain the resources to be compressed corresponding to the target frequency in the resources to be allocated;

[0010] The resource to be compressed is compressed to obtain the target free space released after the resource to be compressed is compressed.

[0011] The embodiment of the present application also provides a resource compression device, including:

[0012] A request acquisition unit, used to acquire a space allocation request for a free space, where the free space is an unoccupied memory space, and the space allocation request is used to request to use the free space;

[0013] an adjusting unit, configured to adjust the frequency critical value based on the failure rate of the space allocation request to obtain an adjusted frequency critical value, wherein the failure rate is a ratio of the space allocation request that is not satisfied;

[0014] A frequency acquisition unit, used to acquire the access frequency of the resource to be allocated;

[0015] A frequency determination unit, configured to determine a target frequency from the accessed frequencies based on the adjusted frequency critical value, and obtain resources to be compressed corresponding to the target frequency in the resources to be allocated;

[0016] The compression unit is used to compress the resources to be compressed to obtain the target free space released after the resources to be compressed are compressed.

[0017] In some embodiments, the frequency critical value includes an initial frequency critical value, and before the frequency critical value is adjusted based on the failure rate of the space allocation request to obtain the adjusted frequency critical value, the method further includes:

[0018] Obtaining a preset frequency threshold and a historical access frequency of historical resources to be allocated;

[0019] Based on the preset frequency critical value, determine the historical target frequency from the historical access frequency, and obtain the historical resources to be compressed corresponding to the historical target frequency in the historical resources to be allocated;

[0020] Compress the historical resources to be compressed to obtain the historical free space released after the historical resources to be compressed are compressed;

[0021] Obtain a historical space allocation request for historical free space, where the historical space allocation request is used to request the use of historical free space;

[0022] Based on the correspondence between the historical failure rate of historical space allocation requests and the historical resources to be compressed, the initial frequency critical value is determined from the preset frequency critical value, and the historical failure rate is the ratio of the historical space allocation requests that are not satisfied.

[0023] In some embodiments, based on the correspondence between the historical failure rate of historical space allocation requests and the historical resources to be compressed, determining the initial frequency threshold from the preset frequency threshold includes:

[0024] Based on all preset frequency thresholds, a first trend graph corresponding to the historical failure rate and a second trend graph corresponding to the historical resources to be compressed are established;

[0025] Based on the same preset frequency threshold, calculating the amplitude difference between the first trend graph and the second trend graph;

[0026] Based on all the amplitude differences, an initial frequency threshold is determined from all preset frequency thresholds.

[0027] In some embodiments, compressing the resource to be compressed to obtain the target free space released after the resource to be compressed is compressed includes:

[0028] Compressing the resource to be compressed to obtain the compressed resource;

[0029] Obtaining a mapping relationship between a preset compression value and a storage level;

[0030] Based on a mapping relationship between a preset compression value and a storage level, determining a target storage level corresponding to the compression value of the compressed resource from the storage levels;

[0031] The compressed resources are stored in the storage space corresponding to the target storage level, and the target free space is released.

[0032] In some embodiments, after storing the compressed resource in the storage space corresponding to the target storage level and releasing the target free space, the method further includes:

[0033] Obtaining a storage device identifier of a compressed resource, where the storage device identifier is an identifier of a device storing the compressed resource;

[0034] Establishing a target correspondence relationship, where the target correspondence relationship is a correspondence relationship between a storage device identifier, a compression resource, and a target storage level;

[0035] The target correspondence is sent to the shared resource manager, and the shared resource manager manages the compressed resources in the multiple devices through the target correspondence.

[0036] In some embodiments, after sending the corresponding relationship to the shared resource manager, the method further includes:

[0037] Responding to a service request for a target compression resource, obtaining a service state of the target compression resource, where the target compression resource is any compression resource;

[0038] If the service state does not satisfy the service request, the target storage device identifier corresponding to the target compression resource is determined from the target corresponding relationship through the shared resource manager;

[0039] Based on the service status, the device corresponding to the target storage device identifier is checked.

[0040] In some embodiments, based on the failure rate of the space allocation request, the frequency critical value is adjusted to obtain the adjusted frequency critical value, including:

[0041] Determine a target difference, where the target difference is equal to the difference between the failure rate of the space allocation request and a preset threshold;

[0042] If the target difference is greater than zero, the preset downward adjustment value is used to adjust the frequency critical value to obtain an adjusted frequency critical value, and the adjusted frequency critical value is equal to the difference between the frequency critical value and the preset downward adjustment value.

[0043] In some embodiments, compressing the resource to be compressed to obtain the target free space released after the resource to be compressed is compressed includes:

[0044] Get the number of times the frequency threshold is adjusted;

[0045] If the number of adjustments is greater than the preset number of adjustments, stop compressing the resources to be compressed.

[0046] An embodiment of the present application also provides an electronic device, including a memory storing multiple instructions; the processor loads instructions from the memory to execute the steps in any one of the resource compression methods provided in the embodiments of the present application.

[0047] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a plurality of instructions, wherein the instructions are suitable for loading by a processor to execute the steps in any one of the resource compression methods provided in the embodiment of the present application.

[0048] The embodiment of the present application also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps in any one of the resource compression methods provided in the embodiment of the present application.

[0049] The embodiment of the present application can obtain a space allocation request for free space, where the free space is unoccupied memory space, and the space allocation request is used to request the use of the free space; based on the failure rate of the space allocation request, the frequency critical value is adjusted to obtain the adjusted frequency critical value, and the failure rate is the ratio of the space allocation requests that are not satisfied; the access frequency of the resources to be allocated is obtained; based on the adjusted frequency critical value, the target frequency is determined from the accessed frequencies to obtain the resources to be compressed corresponding to the target frequency in the resources to be allocated; the resources to be compressed are compressed to obtain the target free space released after the resources to be compressed are compressed.

[0050] In the present application, the frequency critical value can be adjusted according to the failure rate of the space allocation request, so that the target frequency can be determined from the accessed frequency through the adjusted frequency critical value, thereby obtaining the resources to be compressed corresponding to the target frequency in the resources to be allocated, so that after the resources to be compressed are compressed, the target free space released can match the space allocation request initiated when the application is running, so that the released target free space can be effectively utilized by the application, thereby improving the performance of the device. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0052] Figure 1a is a scenario diagram of a resource compression method provided in an embodiment of the present application;

[0053] Figure 1b It is a flowchart of a resource compression method provided in an embodiment of the present application;

[0054] Figure 2a is a schematic diagram of the correction frequency critical value provided in the embodiment of the present application;

[0055] Figure 2b is a schematic diagram of a first trend graph and a second trend graph provided in an embodiment of the present application;

[0056] Figure 2c It is a schematic diagram of a process for constructing a stable compression resource provided in an embodiment of the present application;

[0057] Figure 3 is a schematic diagram of the structure of a resource compression device provided in an embodiment of the present application;

[0058] Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0059] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0060] Embodiments of the present application provide a resource compression method, device, and electronic device.

[0061] The resource compression device can be integrated into an electronic device, which can be a terminal, a server, or other devices. The terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop, or a personal computer (PC), etc. The server can be a single server or a server cluster composed of multiple servers.

[0062] In some embodiments, the resource compression device may also be integrated into multiple electronic devices. For example, the resource compression device may be integrated into multiple servers, and the resource compression method of the present application may be implemented by multiple servers.

[0063] In some embodiments, the server may also be implemented in the form of a terminal.

[0064] For example, refer to Figure 1a The electronic device can obtain a space allocation request for free space, where the free space is unoccupied memory space, and the space allocation request is used to request the use of the free space; based on the failure rate of the space allocation request, the frequency critical value is adjusted to obtain the adjusted frequency critical value, and the failure rate is the ratio of the space allocation requests that are not satisfied; the access frequency of the resources to be allocated is obtained; based on the adjusted frequency critical value, the target frequency is determined from the access frequency to obtain the resources to be compressed corresponding to the target frequency in the resources to be allocated; the resources to be compressed are compressed to obtain the target free space released after the resources to be compressed are compressed.

[0065] Among them, the frequency critical value can be adjusted according to the failure rate of the space allocation request, so that the target frequency can be determined from the accessed frequency through the adjusted frequency critical value, thereby obtaining the resources to be compressed corresponding to the target frequency in the resources to be allocated, so that after the resources to be compressed are compressed, the target free space released can match the space allocation request initiated when the application is running, so that the released target free space can be effectively used by the application, thereby improving the performance of the device.

[0066] It should be noted that the serial numbers of the following embodiments are not intended to limit the preferred order of the embodiments.

[0067] In this embodiment, a resource compression method is provided, such as Figure 1b As shown, the specific process of the resource compression method can be as follows:

[0068] 110. Obtain a space allocation request for free space, where the free space is unoccupied memory space, and the space allocation request is used to request the use of the free space.

[0069] Among them, the free space is the memory space that is not currently occupied by any process and can be used by other processes.

[0070] Free memory can be obtained by:

[0071] For example, when you start the computer, the operating system will reserve a portion of the memory space for the system to run and run necessary applications. The remaining memory space is free space and can be used by other applications to run. Or when running a larger application, the application may take up a large amount of memory. After closing the application, the memory space occupied by the application becomes free space for other applications to use. Or when running an application, the operating system can release the memory space occupied by cached data that is not frequently read, thereby obtaining free space for other applications to run, and so on.

[0072] A space allocation request is a request initiated by an application to use free space during its operation. For example, a space allocation request may be initiated by a media player to cache a video, a document editor to write data, or an application to create a new process.

[0073] For example, when creating a new process, an application can send a space allocation request to the device's operating system to allocate free space for the new process, so that the code and data that the new process needs to read can be loaded from the file system into the free space for use by the new process.

[0074] 120. Based on the failure rate of the space allocation request, the frequency critical value is adjusted to obtain an adjusted frequency critical value, and the failure rate is a ratio of the space allocation requests that are not satisfied.

[0075] The failure rate is the ratio of unsatisfied space allocation requests per unit time, wherein an unsatisfied space allocation request means that after the space allocation request is sent, free space is not allocated or the allocated free space is insufficient.

[0076] For example, within a unit of time, there are N space allocation requests for free space, among which M of the N space allocation requests are not allocated free space or the allocated free space is insufficient, and the failure rate = M / N.

[0077] The frequency threshold is used to divide the resources occupying the memory space into frequently accessed resources and infrequently accessed resources. For example, the frequency threshold can be a pre-set threshold, a threshold that changes dynamically based on the failure rate of space allocation requests, a threshold selected from pre-set thresholds, and so on.

[0078] Compared with the frequency critical value before adjustment, the adjusted frequency critical value has different frequently accessed resources and infrequently accessed resources divided from the resources occupying the memory space. For example, the adjusted frequency critical value may be greater than the frequency critical value, less than the frequency critical value, equal to the frequency critical value, and so on.

[0079] For example, when the failure rate of the space allocation request is 0, the frequency critical value after adjustment can be made greater than the frequency critical value before adjustment, or the frequency critical value after adjustment can be made equal to the frequency critical value before adjustment, and so on.

[0080] When the failure rate of the space allocation request is greater than 0, the frequency critical value after adjustment may be made smaller than the frequency critical value before adjustment, so that more resources that are not frequently accessed may be divided from the resources occupying the memory space.

[0081] For example, the frequency critical value before adjustment is 5 minutes, that is, resources accessed within 5 minutes can be determined as frequently accessed resources, and resources accessed for more than 5 minutes can be determined as infrequently accessed resources. After the frequency critical value is adjusted to 4 minutes, resources accessed within 4 minutes can be determined as frequently accessed resources, and resources accessed for more than 4 minutes can be determined as infrequently accessed resources. Compared with the frequency critical value before adjustment, the time interval for dividing infrequently accessed resources is increased. In this way, more infrequently accessed resources can be divided from the resources occupying memory space.

[0082] In some embodiments, considering that as the application continues to run, the space allocation request will continue to grow, so there may not be enough free space for the application to continue running. In order to make the released memory space match the space allocation request initiated when the application is running, the frequency critical value is adjusted based on the failure rate of the space allocation request, and the adjusted frequency critical value is obtained, including:

[0083] Determine a target difference, where the target difference is equal to the difference between the failure rate of the space allocation request and a preset threshold;

[0084] If the target difference is greater than zero, the preset downward adjustment value is used to adjust the frequency critical value to obtain an adjusted frequency critical value, and the adjusted frequency critical value is equal to the difference between the frequency critical value and the preset downward adjustment value.

[0085] The preset threshold is a preset threshold used to measure the failure rate.

[0086] The target difference is the difference between the failure rate of the space allocation request and the preset threshold. For example, if the failure rate is greater than the preset threshold, the target difference is greater than 0, and if the failure rate is not greater than the preset threshold, the target difference is not less than 0.

[0087] The preset down-adjustment value is a preset value for down-adjusting the frequency critical value. For example, the preset minor value may be a preset threshold value, wherein the preset down-adjustment value may also be equal to the interval between two adjacent preset frequency critical values. For example, the interval between two adjacent preset frequency critical values ​​may be 1 minute, 2 minutes, etc., and the preset down-adjustment value may be 1 minute, 2 minutes, etc., and the preset down-adjustment value is not limited here.

[0088] The adjusted frequency critical value is equal to the difference between the frequency critical value and the preset downward adjustment value. In order to reduce the frequency critical value, the time interval for dividing infrequently accessed resources is increased compared to the frequency critical value before adjustment. In this way, more infrequently accessed resources can be divided from the resources occupying memory space.

[0089] In some embodiments, in order to make the frequency critical value satisfy more space allocation requests, the frequency critical value includes an initial frequency critical value. Before the frequency critical value is adjusted based on the failure rate of the space allocation request to obtain the adjusted frequency critical value, the following steps are further included:

[0090] Obtaining a preset frequency threshold and a historical access frequency of historical resources to be allocated;

[0091] Based on the preset frequency critical value, determine the historical target frequency from the historical access frequency, and obtain the historical resources to be compressed corresponding to the historical target frequency in the historical resources to be allocated;

[0092] Compress the historical resources to be compressed to obtain the historical free space released after the historical resources to be compressed are compressed;

[0093] Obtain a historical space allocation request for historical free space, where the historical space allocation request is used to request the use of historical free space;

[0094] Based on the correspondence between the historical failure rate of historical space allocation requests and the historical resources to be compressed, the initial frequency critical value is determined from the preset frequency critical value, and the historical failure rate is the ratio of the historical space allocation requests that are not satisfied.

[0095] The preset frequency critical value is a preset frequency critical value waiting for screening, so that after screening, the preset frequency critical value after screening is adjusted according to the failure rate of the space allocation request. The interval between two adjacent preset frequency critical values ​​can be a preset interval, and the preset interval can be 1 minute, 2 minutes, 3 minutes, etc., and the preset interval is not limited here.

[0096] The historical resources to be allocated are uncompressed resources that can be directly accessed by the device in the historical time period. For example, the historical resources to be allocated may include resources that are frequently read and / or written, resources that are not frequently read and / or written, etc. in the historical time period.

[0097] The historical access frequency is the frequency at which the historical resources to be allocated are accessed during runtime. For example, the historical access frequency may be the frequency at which the historical resources to be allocated are read during runtime, the frequency at which they are written, the frequency at which they are read and written, and so on.

[0098] The historical target frequency may be a historical access frequency that is not less than a preset frequency threshold.

[0099] For example, if the preset frequency critical values ​​can include 1 minute, 2 minutes, ..., 30 minutes, the interval between the two adjacent preset frequency critical values ​​is 1 minute, and the historical target frequency can include a historical access frequency of not less than 1 minute, a historical access frequency of not less than 2 minutes, ..., a historical access frequency of not less than 30 minutes, and so on.

[0100] The historical resources to be compressed are historical resources to be allocated and waiting to be compressed corresponding to the historical target frequency.

[0101] The historical free space is the space released after the historical resources to be compressed are compressed.

[0102] The historical space allocation request is a request initiated when the historical free space is released and the application needs to use the historical free space during operation.

[0103] The historical failure rate is the ratio of unsatisfied historical space allocation requests per unit time, wherein an unsatisfied historical space allocation request means that after the historical space allocation request is sent, no historical free space is allocated or the allocated historical free space is insufficient.

[0104] The corresponding relationship between the historical failure rate of the historical space allocation request and the historical resources to be compressed represents the historical failure rate and the resources to be compressed corresponding to the same preset frequency threshold.

[0105] The initial frequency critical value may be a preset frequency critical value for the first adjustment, and the corresponding historical failure rate and resources to be compressed may meet the preset conditions. For example, the initial frequency critical value may be a preset frequency critical value corresponding to the historical failure rate being lower than the preset failure rate threshold, and the historical resources to be compressed being not less than the preset memory space occupancy, or a preset frequency critical value corresponding to the difference between the historical resources to be compressed and the historical failure rate meeting the preset difference, and so on.

[0106] The preset failure rate threshold is a preset threshold used to measure the historical failure rate.

[0107] The preset memory space usage is a preset amount of memory space used to measure the historical memory usage of resources to be compressed.

[0108] The preset difference is a preset value used to measure the difference between the historical resources to be compressed and the historical failure rate.

[0109] For example, through the historical failure rates and to-be-compressed resources corresponding to all preset frequency critical values, the initial frequency critical value can be screened out from the preset frequency critical values, so that the initial frequency critical value can be adjusted according to the failure rate of the space allocation request.

[0110] In some embodiments, in order to screen out a preset frequency critical value corresponding to a large historical value to be compressed and a small historical failure rate, based on the corresponding relationship between the historical failure rate of the historical space allocation request and the historical resources to be compressed, the initial frequency critical value is determined from the preset frequency critical value, including:

[0111] Based on all preset frequency thresholds, a first trend graph corresponding to the historical failure rate and a second trend graph corresponding to the historical resources to be compressed are established;

[0112] Based on the same preset frequency threshold, calculating the amplitude difference between the first trend graph and the second trend graph;

[0113] Based on all the amplitude differences, an initial frequency threshold is determined from all preset frequency thresholds.

[0114] The first trend graph is a trend graph showing changes in the historical failure rate with a preset frequency threshold.

[0115] The second trend graph is a trend graph of historical changes in resources to be compressed along with a preset frequency threshold.

[0116] The amplitude difference is the difference between the amplitude value of the first trend graph and the amplitude value of the second trend graph obtained based on the same preset frequency critical value.

[0117] For example, the preset frequency critical value may include 1 minute, 2 minutes, ..., 30 minutes. Each preset frequency critical value corresponds to a historical resource to be compressed and a historical failure rate. A first trend graph of the historical resources to be compressed changing with the preset frequency critical value is established, and a second trend graph of the historical failure rate changing with the preset frequency critical value is established. The amplitude value a corresponding to the same preset frequency critical value in the first trend graph and the amplitude value b corresponding to the second trend graph are obtained, the amplitude difference between the amplitude value a and the amplitude value b is calculated, the amplitude difference that meets the conditions is screened out from all amplitude differences, and the preset frequency critical value corresponding to the amplitude difference that meets the conditions is determined as the initial frequency critical value.

[0118] For example, the amplitude difference between amplitude value a and amplitude value b can be a positive value, 0, and a negative value. When amplitude value a is greater than amplitude value b, the amplitude difference is a positive value. When amplitude value a is equal to amplitude value b, the amplitude difference is 0. When amplitude value a is less than amplitude value b, the amplitude difference is a negative value. In order to obtain a smaller historical failure rate corresponding to historical resources to be compressed, the amplitude difference that meets the conditions can be any amplitude difference less than 0, or the smallest amplitude difference, and so on.

[0119] 130. Obtain the access frequency of the resources to be allocated.

[0120] The resources to be allocated are uncompressed resources that can be directly accessed by the device in the current time period. For example, the resources to be allocated may include resources that are frequently read and / or written, resources that are not frequently read and / or written, etc. in the current time period.

[0121] For example, the resources to be allocated may be resources stored in a server or a terminal device, and so on.

[0122] The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., but is not limited to this. The terminal and the server can be directly or indirectly connected via wired or wireless communication, which is not limited in this application.

[0123] The access frequency is the frequency at which the resource to be allocated is accessed during runtime. For example, the access frequency may be the frequency at which the resource to be allocated is read during runtime, or the frequency at which it is written, or the frequency at which it is read and written, and so on.

[0124] For example, the resources running on the device's operating interface refer to the resources of applications running in the device's graphical user interface (GUI), such as web pages opened by a browser, multimedia content (music, video, etc.) played by a media player, documents edited by a document editor, and so on.

[0125] The resources running in the background of the device refer to applications and related system resources that run continuously in the background of the device in the form of services or processes. These resources usually do not require user interaction, but provide services or complete certain tasks in an automated manner. For example, network connection, file sharing, print management, backup files, log cleaning, software update, mail server, network server, background process management, etc.

[0126] The resources to be allocated that are frequently read and / or written and the resources to be allocated that are not frequently read and / or written can be determined from the resources running on the operation interface of the device and the resources running in the background of the device. For example, the resources to be allocated that are frequently read and / or written can be web pages opened by a browser, multimedia content (music, video, etc.) played by a media player, documents edited by a document editor, etc. The resources to be allocated that are not frequently read and / or written can be print management, log cleaning, software update, etc. running in the background of the device.

[0127] The access frequency of the resources to be allocated can be obtained by detecting the usage status of the resources through a task manager to obtain the access frequency of the resources to be allocated through the usage status, or by collecting resource usage data through sensors to obtain the access frequency of the resources to be allocated through usage data, or by obtaining the access frequency of the resources to be allocated through log analysis, etc.

[0128] 140. Based on the adjusted frequency critical value, determine the target frequency from the accessed frequencies, and obtain the resources to be compressed corresponding to the target frequency in the resources to be allocated.

[0129] The target frequency may be a frequency to be accessed that is not less than the adjusted frequency threshold. For example, the access frequencies include 1 minute, 2 minutes, 3 minutes, ... 29 minutes, 30 minutes. If the adjusted frequency threshold is 5 minutes, the target frequency is a frequency to be accessed that is not less than 5 minutes.

[0130] The resources to be compressed are allocated resources corresponding to the target frequency and waiting to be compressed.

[0131] For example, if the target frequency is an access frequency of not less than 5 minutes, where the access frequency of the resources to be allocated includes the access frequency of multimedia content played by the media player of 0.2 minutes, the access frequency of web pages opened by the browser of 2 minutes, the access frequency of print management of 5 minutes, the access frequency of backup files of 10 minutes, etc., then the resources to be compressed include print management, backup files, etc.

[0132] 150. Compress the resources to be compressed to obtain target free space released after the resources to be compressed are compressed.

[0133] The target free space is the space released after the resource to be compressed is compressed. For example, the memory space occupied by the resource to be compressed before compression is 50 megabytes (MB), and after compression, the memory space occupied may be 25MB. Then, after the resource to be compressed is compressed, the target free space released = 50MB-25MB = 25MB.

[0134] In some embodiments, considering that there is a memory hierarchical center in the computer system, the memory hierarchical center is a unified management center of all memory levels in the computer system, responsible for controlling and coordinating data exchange and access between memories at each level, and the memory hierarchical center can be divided according to factors such as read and write speed, storage capacity, and cost. In order to facilitate the management of compressed resources so that the compressed resources can also provide assistance in the subsequent operation of the application, the resources to be compressed are compressed to obtain the target free space released after the compressed resources are compressed, including:

[0135] Compressing the resource to be compressed to obtain the compressed resource;

[0136] Obtaining a mapping relationship between a preset compression value and a storage level;

[0137] Based on a mapping relationship between a preset compression value and a storage level, determining a target storage level corresponding to the compression value of the compressed resource from the storage levels;

[0138] The compressed resources are stored in the storage space corresponding to the target storage level, and the target free space is released.

[0139] The compressed resources are the resources corresponding to the resources to be compressed after being compressed.

[0140] The preset compression value is a preset compression value used to measure the compression resource. For example, the preset compression value may be a preset compression ratio, or a preset memory usage of the compression resource, and so on.

[0141] The storage class is associated with the storage space in the device and is used to encapsulate the compressed resources into the storage space associated with the storage class.

[0142] The mapping relationship between the preset compression value and the storage level is used to locate the storage level corresponding to the compressed resource so as to store the compressed resource.

[0143] The compression value of the compressed resource indicates the compression degree of the compressed resource. For example, the compression value of the compressed resource may be the compression ratio of the compressed resource, or the memory usage of the compressed resource, and so on.

[0144] The target storage level is the storage level corresponding to the compression value of the compressed resource.

[0145] The storage space corresponding to the target storage level is the storage space for storing the compressed resources corresponding to the target storage level.

[0146] For example, the storage level can be divided into 5 levels, namely 2 gigabyte (G) memory space, 4G memory space, 8G memory space, 16G memory space and 32G memory space. If the preset compression value is the memory usage of the compressed resource, the preset compression value may include 3G, 4G, 10G, 20G, and 32G. In order to avoid the risk of system crash or performance degradation due to insufficient memory space, it is necessary to limit the compression value of the compressed resource to be greater than the storage level. In this way, the mapping relationship between the preset compression value and the storage level may include the mapping relationship between 3G and 2G memory space, the mapping relationship between 4G and 4G memory space, the mapping relationship between 10G and 8G memory space, the mapping relationship between 16G and 20G memory space, and the mapping relationship between 32G and 32G memory space.

[0147] If the compression value of the compressed resource is 3G, through the preset mapping relationship between the compression value and the storage level, the target storage level obtained is 2G memory space, so that the compressed resource is encapsulated in the 2G memory space and the target free space is released.

[0148] In some embodiments, considering that the application may need support from multiple devices when it is running, in order to simultaneously manage the compressed resources generated when the application is running on each device, after storing the compressed resources in the storage space corresponding to the target storage level and releasing the target free space, the following steps are further included:

[0149] Obtaining a storage device identifier of a compressed resource, where the storage device identifier is an identifier of a device storing the compressed resource;

[0150] Establishing a target correspondence relationship, where the target correspondence relationship is a correspondence relationship between a storage device identifier, a compression resource, and a target storage level;

[0151] The target correspondence is sent to the shared resource manager, and the shared resource manager manages the compressed resources in the multiple devices through the target correspondence.

[0152] The storage device identifier is an identifier of a device storing compressed resources, for example, an Internet Protocol Address (IP address), a physical address (MAC address), a hard disk serial number, and the like.

[0153] The target correspondence is a correspondence between a storage device identifier, a compression resource, and a target storage level.

[0154] The shared resource manager may receive target correspondence relationships sent by multiple devices to manage compression resources in the multiple devices through the target correspondence relationships.

[0155] For example, considering that the video data that can be played in the video player is stored in multiple devices, due to the different access rates of the video data in the devices, the video data corresponding to the access frequency not less than the frequency critical value in the device is compressed to obtain compressed resources, and the compressed resources are encapsulated in the storage space corresponding to the target storage level, and a correspondence between the storage device identifier for storing the compressed resources, the compressed resources and the target storage level is established to obtain the target correspondence, and the target correspondence is sent to the shared resource manager so that the video player can manage the compressed resources through the target correspondence in the shared resource manager.

[0156] For example, considering that the content data (images, videos, text, etc.) in the circle of friends or video accounts in the instant messaging application can be stored in multiple devices, due to the different access rates of the content data in the devices, the content data corresponding to the access frequency not less than the frequency critical value in the device is compressed to obtain compressed resources, and the compressed resources are encapsulated in the storage space corresponding to the target storage level. A correspondence between the storage device identifier for storing the compressed resources, the compressed resources and the target storage level is established to obtain the target correspondence, and the target correspondence is sent to the shared resource manager, so that the instant messaging application can manage the compressed resources through the target correspondence in the shared resource manager.

[0157] In some embodiments, considering the transcoding of compressed resources, the application program for compressing resource transcoding always has a high latency problem, which is a service failure. In order to locate the device where the failure occurs, after sending the target correspondence to the shared resource manager, the following is further included:

[0158] Responding to a service request for a target compression resource, obtaining a service state of the target compression resource, where the target compression resource is any compression resource;

[0159] If the service state does not satisfy the service request, the target storage device identifier corresponding to the target compression resource is determined from the target corresponding relationship through the shared resource manager;

[0160] Based on the service status, the device corresponding to the target storage device identifier is checked.

[0161] The target compressed resource is the compressed resource that the application needs to run when it is running. For example, if the application is a video player, the target compressed resource can be the compressed resource corresponding to the video data that needs to be played. If the application is an instant messaging application, the target compressed resource can be the compressed resource corresponding to the circle of friends content that needs to be displayed, or the compressed resource corresponding to the video number content that needs to be played, etc.

[0162] The business request is a request for running target compression resources initiated by the application when it is running.

[0163] For example, if the application is a video player and the target compressed resource is video data, the service request may be a request initiated by clicking on the video data to play; if the application is an instant messaging application and the target compressed resource is the Moments content of a communication contact in the instant messaging application, the service request may be a request initiated by clicking on the Moments content of the communication contact; the target compressed resource may also be the video number content in the instant messaging application, then the service request may be a request initiated when the user's sliding operation stays on the video number content for a preset time period, so as to play the video number content after the preset time period, and so on.

[0164] The business status is the running status of the target compression resource in the application. For example, the business status can be normal operation, abnormal operation, transcoding delay, transcoding error, etc.

[0165] The target storage device identifier is an identifier of a device storing the target compressed resource. For example, the target storage identifier may be an IP address, a MAC address, a hard disk serial number, etc. of the device storing the target compressed resource.

[0166] For example, if video a is the target compressed resource in device A, after the video player in device B initiates a service request to play video a, after obtaining video a through the service request, video a is first transcoded and then the transcoded video a is played. When transcoding video a, if a transcoding delay or transcoding error occurs, the target storage device identifier corresponding to video a can be obtained from the target correspondence relationship through the shared resource manager, which is convenient for quickly locating the device storing video a and checking the device corresponding to the target storage device identifier, so that the video a sent by the device corresponding to the target storage device identifier can be played normally in device A.

[0167] In some embodiments, considering that releasing more free space cannot satisfy the space allocation request initiated by the application program when it is running, in order to avoid that the free space generated after compressing the resources to be compressed cannot provide effective services for the application program, the resources to be compressed are compressed to obtain the target free space released after the resources to be compressed are compressed, including:

[0168] Get the number of times the frequency threshold is adjusted;

[0169] If the number of adjustments is greater than the preset number of adjustments, stop compressing the resources to be compressed.

[0170] The number of adjustments is the number of times the frequency critical value is adjusted.

[0171] The preset adjustment number is a preset adjustment number used to measure the frequency threshold.

[0172] For example, when adjusting the frequency critical value once, the calculation is added by 1, and the number of times the frequency critical value is adjusted is accumulated to obtain the number of adjustments. When the number of adjustments exceeds the preset number of adjustments, the control device terminates the compression of the resources to be compressed, so as to avoid the situation where the free space generated after compressing the resources to be compressed cannot provide effective services for the application, and can reduce the consumption of device performance by compressing the resources to be compressed.

[0173] As can be seen from the above, the embodiments of the present application can obtain a space allocation request for free space, where the free space is unoccupied memory space, and the space allocation request is used to request the use of the free space; based on the failure rate of the space allocation request, the frequency critical value is adjusted to obtain the adjusted frequency critical value, and the failure rate is the ratio of unsatisfied space allocation requests; the access frequency of the resources to be allocated is obtained; based on the adjusted frequency critical value, the target frequency is determined from the accessed frequency to obtain the resources to be compressed corresponding to the target frequency in the resources to be allocated; the resources to be compressed are compressed to obtain the target free space released after the resources to be compressed are compressed.

[0174] Therefore, this scheme can adjust the frequency critical value according to the failure rate of the space allocation request, so as to determine the target frequency from the accessed frequency through the adjusted frequency critical value, thereby obtaining the resources to be compressed corresponding to the target frequency in the resources to be allocated, so that after the resources to be compressed are compressed, the target free space released can match the space allocation request initiated when the application is running, so that the released target free space can be effectively used by the application, thereby improving the performance of the device.

[0175] The method described in the above embodiment will be further described in detail below.

[0176] In this embodiment, if Figure 2a As shown, taking building stable compression resources to achieve cost reduction by overselling memory space as an example, the method of the embodiment of the present application is described in detail.

[0177] (a) Test the initial frequency critical value.

[0178] In some embodiments, testing the initial frequency threshold includes:

[0179] Obtaining a preset frequency threshold and a historical access frequency of historical resources to be allocated;

[0180] Based on the preset frequency critical value, determine the historical target frequency from the historical access frequency, and obtain the historical resources to be compressed corresponding to the historical target frequency in the historical resources to be allocated;

[0181] Compress the historical resources to be compressed to obtain the historical free space released after the historical resources to be compressed are compressed;

[0182] Obtain a historical space allocation request for historical free space, where the historical space allocation request is used to request the use of historical free space;

[0183] Based on the correspondence between the historical failure rate of historical space allocation requests and the historical resources to be compressed, the initial frequency critical value is determined from the preset frequency critical value, and the historical failure rate is the ratio of the historical space allocation requests that are not satisfied.

[0184] For example, every 1 minute, the historical resources to be compressed and the historical failure rate are obtained, and the corresponding relationship between the historical failure rate of historical space allocation requests and the historical resources to be compressed is established. As shown in Table 1:

[0185]

[0186]

[0187] Table 1

[0188] Table 1 can be used to easily select the initial frequency critical value from the preset frequency critical values ​​based on the correspondence between the historical resources to be compressed and the historical failure rate.

[0189] In some embodiments, based on the correspondence between the historical failure rate of historical space allocation requests and the historical resources to be compressed, determining the initial frequency threshold from the preset frequency threshold includes:

[0190] Based on all preset frequency thresholds, a first trend graph corresponding to the historical failure rate and a second trend graph corresponding to the historical resources to be compressed are established;

[0191] Based on the same preset frequency threshold, calculating the amplitude difference between the first trend graph and the second trend graph;

[0192] Based on all the amplitude differences, an initial frequency threshold is determined from all preset frequency thresholds.

[0193] For example, Figure 2bAs shown, a first trend graph S corresponding to the historical failure rate and a second trend graph Y corresponding to the historical resources to be compressed are established, and the first trend graph S and the second trend graph Y are merged into one trend graph, and the amplitude value s corresponding to the same preset frequency critical value in the first trend graph S and the amplitude value y corresponding to the second trend graph Y can be obtained, and the amplitude difference between the amplitude value s and the amplitude value y is calculated. Figure 2b In the example, when the preset frequency critical value is 6 minutes, there are many historical resources to be compressed that can be compressed, and the historical failure rate is relatively small, so 6 minutes is set as the preset frequency critical value.

[0194] (2) Obtain the access frequency of the resources to be allocated.

[0195] (iii) Based on the initial frequency critical value, a target frequency is determined from the accessed frequencies, and the resources to be compressed corresponding to the target frequency in the resources to be allocated are obtained.

[0196] (iv) compressing the resources to be compressed to obtain target free space released after the resources to be compressed are compressed.

[0197] In some embodiments, compressing the resource to be compressed to obtain the target free space released after the resource to be compressed is compressed includes:

[0198] Compressing the resource to be compressed to obtain the compressed resource;

[0199] Obtaining a mapping relationship between a preset compression value and a storage level;

[0200] Based on a mapping relationship between a preset compression value and a storage level, determining a target storage level corresponding to the compression value of the compressed resource from the storage levels;

[0201] The compressed resources are stored in the storage space corresponding to the target storage level, and the target free space is released.

[0202] For example, compressed resources are stored in the memory classification center: the purpose of this center is to manage compressed resources and use them for business packaging. The memory classification strategy in this solution is based on 3 to perform classification. The classification interval range is defined by a power-of-two integer interval. The memory is divided into 5 levels, namely 2G memory, 4G memory, 8G memory, 16G memory and 32G memory. The packaging business also uses this memory specification to perform packaging operations. The management table resource design of the memory classification center is shown in Table 2 below:

[0203] time Compressing memory values IP Storage Class x minutes 3G IP1 2G memory specification xx minutes 10G IP2 8G memory specification xxx minute level 20G IP3 16G memory specification

[0204] Table 2

[0205] Among them, the time field in Table 2 records the time point where the latest compression resource is located, in order to facilitate the auxiliary location of operational problems. The IP field (i.e., storage device identifier) ​​identifies the address of the device where the compression resource is located, which helps to directly index the target device when locating the fault. The storage level represents the specification of the allocable compression resource. Although the compression resource will not be exactly the memory specification of the power of two, considering the consumption of other memory such as program deployment and system calls brought by the packaging business, this solution will limit the compression resource to be greater than the graded specification memory value.

[0206] (iv) obtaining a space allocation request for a target free space, where the target free space is an unoccupied memory space, and the space allocation request is used to request the use of the target free space.

[0207] (V) Based on the failure rate of the space allocation request, the frequency critical value is adjusted to obtain an adjusted frequency critical value, the failure rate is the ratio of the space allocation requests that are not satisfied, and the frequency critical value includes the initial frequency critical value.

[0208] Since the initial frequency critical value is obtained by surveying and mapping, during the operation of the existing network, there may be processes that use memory that are not covered by the surveying scenario, that is, the resources to be compressed determined by the initial frequency critical value are too small or too large. If the initial frequency critical value is too small, it will not affect the service business. However, if the initial frequency critical value is too large, it may potentially lead to unstable business operations of the resources to be compressed. The purpose of adjusting this process is to stabilize the compressed memory as soon as possible and achieve compression overselling on the basis of stable business operation.

[0209] like Figure 2c As shown, when the compressed resources to be compressed are packed and used by the business, the space allocation request for the free space on the device will be detected and collected, and a preset threshold will be configured. For the determination of the preset threshold, this solution performs configuration according to the service tolerance of the business. The preset thresholds configured in different scenarios of each business will also be different, especially for some offline calculations. The preset threshold configuration here is relatively looser than that of online. During the execution of the solution collection process, if the failure rate of the space allocation request is greater than the preset threshold, the frequency critical value will be corrected according to the surveyed Table 2, where the frequency critical value includes the initial frequency critical value. The correction and adjustment process may continue for multiple rounds until the failure rate of the space allocation request is less than the preset threshold, and the compressed memory enters a steady-state operation process.

[0210] The computing scenario of packing compressed resources in this application adopts an offline computing task, which has high tolerance. The preset threshold in the scheme is configured as a tolerance threshold of 3%. After each adjustment, the count will be increased by 1. When the count exceeds a preset threshold, this scheme is configured to be 5, that is, after 5 adjustments, the failure rate of space allocation requests is still greater than the preset threshold, then the compression operation of the resources to be compressed of the business node will be terminated. Since each frequency critical value correction involves the release operation of the original memory, the compressed memory packing business will be readjusted before the release is executed, in order to ensure the stability of the business service.

[0211] This application is positioned to discuss the process of running a processor (Central Processing Unit, CPU) computing program. The memory space occupied by the process is divided into hot and cold memory spaces. The memory space that needs to be read and written in real time is called hot memory space, and the cached data is not read frequently. The memory space that is only read and written probabilistically is called cold memory space. How to release the cold memory space or compress and swap out the unallocated resources occupying the cold memory space to undertake new computing business is the problem to be solved in this article.

[0212] From the above, it can be seen that this solution defines the resources to be compressed by proposing to use the allocated resources that have not been accessed by the initial frequency critical value, and through mapping operations, observes the failure rate of space allocation requests to determine the initial frequency critical value, and compresses the resources to be compressed determined by the initial frequency critical value, and then corrects the initial frequency critical value according to the failure rate of space allocation requests in the operation of the existing network service to obtain a stable compressible memory value; by building a stable compressed memory, it is helpful for the business side to implement it. The scale of CPU equipment of Internet manufacturers is huge, and the cost-benefit of executing memory compression overselling and boxing computing business is huge; and it is helpful for the steady-state operation of the business. In the process of building a stable memory, the impact of the compressed business is always used as the basic indicator value, eliminating the increase in operation and maintenance problems caused by memory compression overselling, and reducing the investment in operation manpower.

[0213] In order to better implement the above method, the embodiment of the present application also provides a resource compression device, which can be integrated in an electronic device, and the electronic device can be a terminal, a server, etc. Among them, the terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop, a personal computer, etc.; the server can be a single server or a server cluster composed of multiple servers.

[0214] For example, in this embodiment, the method of the embodiment of the present application will be described in detail by taking the resource compression device being specifically integrated into an electronic device as an example.

[0215] For example, Figure 3As shown, the resource compression device may include a request acquisition unit 310, an adjustment unit 320, a frequency acquisition unit 330, a frequency determination unit 340 and a compression unit 350, as follows:

[0216] (i) Request acquisition unit 310.

[0217] The request acquisition unit 310 is used to acquire a space allocation request for free space, where the free space is unoccupied memory space, and the space allocation request is used to request to use the free space.

[0218] (ii) Adjustment unit 320.

[0219] The adjustment unit 320 is used to adjust the frequency critical value based on the failure rate of the space allocation request to obtain the adjusted frequency critical value, and the failure rate is the ratio of the space allocation request that is not satisfied.

[0220] In some embodiments, the frequency critical value includes an initial frequency critical value, and before the frequency critical value is adjusted based on the failure rate of the space allocation request to obtain the adjusted frequency critical value, the method further includes:

[0221] Obtaining a preset frequency threshold and a historical access frequency of historical resources to be allocated;

[0222] Based on the preset frequency critical value, determine the historical target frequency from the historical access frequency, and obtain the historical resources to be compressed corresponding to the historical target frequency in the historical resources to be allocated;

[0223] Compress the historical resources to be compressed to obtain the historical free space released after the historical resources to be compressed are compressed;

[0224] Obtain a historical space allocation request for historical free space, where the historical space allocation request is used to request the use of historical free space;

[0225] Based on the correspondence between the historical failure rate of historical space allocation requests and the historical resources to be compressed, the initial frequency critical value is determined from the preset frequency critical value, and the historical failure rate is the ratio of the historical space allocation requests that are not satisfied.

[0226] In some embodiments, based on the correspondence between the historical failure rate of historical space allocation requests and the historical resources to be compressed, determining the initial frequency threshold from the preset frequency threshold includes:

[0227] Based on all preset frequency thresholds, a first trend graph corresponding to the historical failure rate and a second trend graph corresponding to the historical resources to be compressed are established;

[0228] Based on the same preset frequency threshold, calculating the amplitude difference between the first trend graph and the second trend graph;

[0229] Based on all the amplitude differences, an initial frequency threshold is determined from all preset frequency thresholds.

[0230] In some embodiments, based on the failure rate of the space allocation request, the frequency critical value is adjusted to obtain the adjusted frequency critical value, including:

[0231] Determine a target difference, where the target difference is equal to the difference between the failure rate of the space allocation request and a preset threshold;

[0232] If the target difference is greater than zero, the preset downward adjustment value is used to adjust the frequency critical value to obtain an adjusted frequency critical value, and the adjusted frequency critical value is equal to the difference between the frequency critical value and the preset downward adjustment value.

[0233] (iii) Frequency acquisition unit 330.

[0234] The frequency acquisition unit 330 is used to acquire the access frequency of the resources to be allocated.

[0235] (iv) Frequency determination unit 340.

[0236] The frequency determination unit 340 is configured to determine a target frequency from the accessed frequencies based on the adjusted frequency critical value, and obtain the resources to be compressed corresponding to the target frequency in the resources to be allocated.

[0237] (V) Compression unit 350.

[0238] The compression unit 350 is used to compress the resources to be compressed to obtain the target free space released after the resources to be compressed are compressed.

[0239] In some embodiments, compressing the resource to be compressed to obtain the target free space released after the resource to be compressed is compressed includes:

[0240] Compressing the resource to be compressed to obtain the compressed resource;

[0241] Obtaining a mapping relationship between a preset compression value and a storage level;

[0242] Based on a mapping relationship between a preset compression value and a storage level, determining a target storage level corresponding to the compression value of the compressed resource from the storage levels;

[0243] The compressed resources are stored in the storage space corresponding to the target storage level, and the target free space is released.

[0244] In some embodiments, after storing the compressed resource in the storage space corresponding to the target storage level and releasing the target free space, the method further includes:

[0245] Obtaining a storage device identifier of a compressed resource, where the storage device identifier is an identifier of a device storing the compressed resource;

[0246] Establishing a target correspondence relationship, where the target correspondence relationship is a correspondence relationship between a storage device identifier, a compression resource, and a target storage level;

[0247] The target correspondence is sent to the shared resource manager, and the shared resource manager manages the compressed resources in the multiple devices through the target correspondence.

[0248] In some embodiments, after sending the corresponding relationship to the shared resource manager, the method further includes:

[0249] Responding to a service request for a target compression resource, obtaining a service state of the target compression resource, where the target compression resource is any compression resource;

[0250] If the service state does not satisfy the service request, the target storage device identifier corresponding to the target compression resource is determined from the target corresponding relationship through the shared resource manager;

[0251] Based on the service status, the device corresponding to the target storage device identifier is checked.

[0252] In some embodiments, compressing the resource to be compressed to obtain the target free space released after the resource to be compressed is compressed includes:

[0253] Get the number of times the frequency threshold is adjusted;

[0254] If the number of adjustments is greater than the preset number of adjustments, stop compressing the resources to be compressed.

[0255] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can refer to the previous method embodiments, which will not be repeated here.

[0256] As can be seen from the above, the resource compression device of this embodiment obtains a space allocation request for free space by a request acquisition unit, where the free space is unoccupied memory space, and the space allocation request is used to request the use of the free space; the adjustment unit adjusts the frequency critical value based on the failure rate of the space allocation request to obtain an adjusted frequency critical value, and the failure rate is the ratio of unsatisfied space allocation requests; the frequency acquisition unit obtains the access frequency of the resources to be allocated; the frequency determination unit determines the target frequency from the accessed frequencies based on the adjusted frequency critical value, and obtains the resources to be compressed corresponding to the target frequency in the resources to be allocated; the compression unit compresses the resources to be compressed to obtain the target free space released after the resources to be compressed are compressed.

[0257] Therefore, the embodiments of the present application can enable the released free memory space to be effectively utilized by applications, thereby improving the performance of the device.

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

[0259] In some embodiments, the resource compression device can also be integrated into multiple electronic devices. For example, the resource compression device can be integrated into multiple servers, and the query plan construction method of the present application is implemented by multiple servers.

[0260] In this embodiment, the electronic device of this embodiment is a server as an example for detailed description, for example, Figure 4 As shown, it shows a schematic diagram of the structure of the server involved in the embodiment of the present application, specifically:

[0261] The server may include one or more processing core processors 410, one or more computer-readable storage media memories 420, a power supply 430, an input module 440, and a communication module 450. Those skilled in the art will appreciate that Figure 4 The server structure shown in the figure does not constitute a limitation on the server, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. Among them:

[0262] The processor 410 is the control center of the server, and uses various interfaces and lines to connect various parts of the entire server. It executes various functions of the server and processes data by running or executing software programs and / or modules stored in the memory 420, and calling data stored in the memory 420. In some embodiments, the processor 410 may include one or more processing cores; in some embodiments, the processor 410 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 410.

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

[0264] The server also includes a power supply 430 for supplying power to various components. In some embodiments, the power supply 430 can be logically connected to the processor 410 through a power management system, so that the power management system can manage charging, discharging, and power consumption. The power supply 430 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.

[0265] The server may further include an input module 440, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.

[0266] The server may further include a communication module 450. In some embodiments, the communication module 450 may include a wireless module. The server may perform short-range wireless transmission through the wireless module of the communication module 450, thereby providing wireless broadband Internet access to the user. For example, the communication module 450 may be used to help the user send and receive emails, browse web pages, and access streaming media.

[0267] Although not shown, the server may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 410 in the server will load the executable files corresponding to the processes of one or more application programs into the memory 420 according to the following instructions, and the processor 410 will run the application programs stored in the memory 420, thereby realizing various functions, as follows:

[0268] Obtain a space allocation request for free space, where the free space is unoccupied memory space, and the space allocation request is used to request the use of the free space;

[0269] Based on the failure rate of the space allocation request, the frequency threshold is adjusted to obtain an adjusted frequency threshold, wherein the failure rate is a ratio of the space allocation requests that are not satisfied;

[0270] Obtain the access frequency of the resources to be allocated;

[0271] Based on the adjusted frequency critical value, determine the target frequency from the accessed frequencies, and obtain the resources to be compressed corresponding to the target frequency in the resources to be allocated;

[0272] The resource to be compressed is compressed to obtain the target free space released after the resource to be compressed is compressed.

[0273] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0274] From the above, we can see that the released free memory space can be effectively used by applications to improve the performance of the device.

[0275] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0276] To this end, an embodiment of the present application provides a computer-readable storage medium, in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any resource compression method provided in the embodiment of the present application. For example, the instructions can execute the following steps:

[0277] Obtain a space allocation request for free space, where the free space is unoccupied memory space, and the space allocation request is used to request the use of the free space;

[0278] Based on the failure rate of the space allocation request, the frequency threshold is adjusted to obtain an adjusted frequency threshold, wherein the failure rate is a ratio of the space allocation requests that are not satisfied;

[0279] Obtain the access frequency of the resources to be allocated;

[0280] Based on the adjusted frequency critical value, determine the target frequency from the accessed frequencies, and obtain the resources to be compressed corresponding to the target frequency in the resources to be allocated;

[0281] The resource to be compressed is compressed to obtain the target free space released after the resource to be compressed is compressed.

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

[0283] According to one aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method provided in various optional implementations of the resource compression aspect provided in the above-mentioned embodiments.

[0284] Since the instructions stored in the storage medium can execute the steps in any resource compression method provided in the embodiments of the present application, the beneficial effects that can be achieved by any resource compression method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0285] The above is a detailed introduction to a resource compression method, device and electronic device provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, based on the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A resource compression method, characterized in that: include: Obtaining a space allocation request for a free space, where the free space is an unoccupied memory space, and the space allocation request is used to request to use the free space; Based on the failure rate of the space allocation request, adjusting the frequency critical value to obtain an adjusted frequency critical value, wherein the failure rate is a ratio of the space allocation request that is not satisfied; Obtain the access frequency of the resources to be allocated; Based on the adjusted frequency critical value, determining a target frequency from the accessed frequencies, and obtaining resources to be compressed corresponding to the target frequency in the resources to be allocated; The resource to be compressed is compressed to obtain a target free space released after the resource to be compressed is compressed.

2. The resource compression method according to claim 1, characterized in that: The frequency critical value includes an initial frequency critical value. Before the frequency critical value is adjusted based on the failure rate of the space allocation request to obtain the adjusted frequency critical value, the method further includes: Obtaining a preset frequency threshold and a historical access frequency of historical resources to be allocated; Based on the preset frequency critical value, determine the historical target frequency from the historical accessed frequencies, and obtain the historical resources to be compressed corresponding to the historical target frequency in the historical resources to be allocated; Compressing the historical resources to be compressed to obtain historical free space released after the historical resources to be compressed are compressed; Acquire a historical space allocation request for the historical free space, where the historical space allocation request is used to request to use the historical free space; Based on the correspondence between the historical failure rate of the historical space allocation request and the historical resources to be compressed, an initial frequency critical value is determined from the preset frequency critical value, and the historical failure rate is the ratio of the historical space allocation request that is not satisfied.

3. The resource compression method according to claim 2, characterized in that: The determining the initial frequency critical value from the preset frequency critical value based on the correspondence between the historical failure rate of the historical space allocation request and the historical resources to be compressed includes: Based on all the preset frequency thresholds, establishing a first trend graph corresponding to the historical failure rate and a second trend graph corresponding to the historical resources to be compressed; Based on the same preset frequency critical value, calculating the amplitude difference between the first trend graph and the second trend graph; An initial frequency threshold is determined from all the preset frequency thresholds according to all the amplitude differences.

4. The resource compression method according to claim 1, characterized in that: The compressing the resource to be compressed to obtain a target free space released after the resource to be compressed is compressed, including: Compressing the resource to be compressed to obtain a compressed resource; Obtaining a mapping relationship between a preset compression value and a storage level; Based on the mapping relationship between the preset compression value and the storage level, determining the target storage level corresponding to the compression value of the compression resource from the storage levels; The compressed resource is stored in a storage space corresponding to the target storage level, and the target free space is released.

5. The resource compression method according to claim 4, characterized in that: After storing the compressed resource in the storage space corresponding to the target storage level and releasing the target free space, the method further includes: Acquire a storage device identifier of the compressed resource, where the storage device identifier is an identifier of a device storing the compressed resource; Establishing a target correspondence relationship, wherein the target correspondence relationship is a correspondence relationship between the storage device identifier, the compression resource, and the target storage level; The target correspondence relationship is sent to a shared resource manager, and the shared resource manager manages the compressed resources in the plurality of devices through the target correspondence relationship.

6. The resource compression method according to claim 5, characterized in that: After sending the target correspondence relationship to the shared resource manager, the method further includes: In response to a service request for a target compressed resource, obtaining a service state of the target compressed resource, the target compressed resource being any one of the compressed resources; If the service state does not satisfy the service request, determining, through the shared resource manager, a target storage device identifier corresponding to the target compression resource from the target corresponding relationship; Based on the service status, a device corresponding to the target storage device identifier is checked.

7. The resource compression method according to claim 1, characterized in that: The step of adjusting the frequency critical value based on the failure rate of the space allocation request to obtain the adjusted frequency critical value includes: Determine a target difference, where the target difference is equal to the difference between the failure rate of the space allocation request and a preset threshold; If the target difference is greater than zero, the frequency critical value is adjusted using a preset downward adjustment value to obtain an adjusted frequency critical value, where the adjusted frequency critical value is equal to the difference between the frequency critical value and the preset downward adjustment value.

8. The resource compression method according to claim 1, characterized in that: The compressing the resource to be compressed to obtain a target free space released after the resource to be compressed is compressed, including: Obtaining the number of times the frequency critical value is adjusted; If the adjustment times are greater than the preset adjustment times, the compression of the resource to be compressed is stopped.

9. A resource compression device, characterized in that: include: a request acquisition unit, configured to acquire a space allocation request for a free space, wherein the free space is an unoccupied memory space, and the space allocation request is used to request to use the free space; an adjusting unit, configured to adjust the frequency critical value based on the failure rate of the space allocation request to obtain an adjusted frequency critical value, wherein the failure rate is a ratio of the space allocation request that is not satisfied; A frequency acquisition unit, used to acquire the access frequency of the resource to be allocated; A frequency determination unit, configured to determine a target frequency from the accessed frequencies based on the adjusted frequency critical value, and obtain resources to be compressed corresponding to the target frequency in the resources to be allocated; The compression unit is used to compress the resource to be compressed to obtain the target free space released after the resource to be compressed is compressed.

10. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps in the resource compression method according to any one of claims 1 to 8.