Method, device and computer-readable storage medium for detecting resource idleness

By intercepting messages in the message sending and receiving direction of the process to be detected in cloud computing and detecting their attribute information, the problem of large granularity and mistaken recycling of resource idle detection in the existing technology is solved, and more accurate resource idle detection and cloud saving are achieved. cost.

CN111767152BActive Publication Date: 2024-09-06TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010691146.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-17
Publication Date
2024-09-06
Estimated Expiration
2040-07-17

AI Technical Summary

Technical Problem

When existing technology detects idle cloud computing resources, the granularity is relatively large, making it difficult to accurately determine whether the resources of a specific process are idle, resulting in improper resource recycling and a waste of cloud resources.

Method used

Intercept messages in the message sending and receiving direction of the process to be detected, extract attribute information (address, port number, protocol number), and detect whether resources are idle based on the preset time or historical idle time interval to avoid accidentally recycling resources.

Benefits of technology

It improves the accuracy of idle resource detection, avoids unnecessary resource recycling, ensures the recycling of truly idle resources, and saves cloud usage costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111767152B
    Figure CN111767152B
Patent Text Reader

Abstract

The present application relates to the field of cloud computing, and provides a method, device, and computer-readable storage medium for detecting idle resources. The method includes: intercepting any message in the message receiving and sending direction of the process to be detected to obtain an intercepted message; extracting attribute information of the intercepted message from the intercepted message, wherein the attribute information of the intercepted message includes the address, port number, and protocol number carried by the intercepted message; according to the attribute information of the intercepted message, detecting the access of the process to be detected to the intercepted message within a preset time, and the preset time is set according to the detection requirements or according to the maximum time interval of the resources corresponding to the process to be detected in the history of being idle; when it is detected that the process to be detected has not accessed the intercepted message within the preset time, it is determined that the resources corresponding to the process to be detected are idle. The technical solution of the present application is more targeted or more accurate in detection, and only truly idle resources are recycled.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of cloud computing, and in particular to a method, device and computer-readable storage medium for detecting idle resources. Background Art

[0002] As a cloud computing infrastructure provider, a cloud computing resource pool platform (also called a cloud platform) will be established, in which various types of virtual resources will be deployed for external customers to choose and use. The cloud platform mainly includes computing devices (such as virtual machines), storage devices, and network devices, etc.

[0003] Although cloud platforms provide many conveniences for users, relevant studies have shown that about 35% of cloud expenditures are wasted when enterprises use cloud platforms. Therefore, recycling or reusing idle resources is of great significance for enterprises to save cloud usage costs. At present, one method to recycle and reuse idle resources of cloud platforms is the automatic scaling method. In this method, the automatic scaling component samples the utilization rate of cloud hosts and networks over a period of time, automatically recycles computing resources with low utilization rates, and shrinks the business from more cloud hosts to fewer cloud hosts.

[0004] However, since the above automatic scaling method is based on the calculation of the utilization of the entire cloud host and network, when individual nodes or in certain scenarios do not use resources for a "short period of time" due to some reasons, the resources will still be treated as idle resources and recycled, but in the long run, the resources are not idle resources and cannot be recycled. Summary of the invention

[0005] The embodiments of the present application provide a method, device and computer-readable storage medium for detecting idle resources to solve the problem of improper recycling of resources that are not idle in the prior art. The technical solution is as follows:

[0006] In one aspect, a method for detecting resource idleness is provided, the method comprising:

[0007] Intercept any message in the message receiving and sending direction of the process to be detected to obtain the intercepted message;

[0008] Extracting attribute information of the intercepted message from the intercepted message, wherein the attribute information of the intercepted message includes an address, a port number and a protocol number carried by the intercepted message;

[0009] According to the attribute information of the intercepted message, detecting the access of the process to be detected to the intercepted message within a preset time, wherein the preset time is set according to the detection requirement or according to the maximum time interval of the resource corresponding to the process to be detected being idle in history;

[0010] When it is detected that the process to be detected has not accessed the intercepted message within a preset time, it is determined that the resources corresponding to the process to be detected are idle.

[0011] In one aspect, a device for detecting resource idleness is provided, the device comprising:

[0012] The message interception module is used to intercept any message in the message receiving and sending direction of the process to be detected to obtain the intercepted message;

[0013] An extraction module, used for extracting attribute information of the intercepted message from the intercepted message, wherein the attribute information of the intercepted message includes an address, a port number and a protocol number carried by the intercepted message;

[0014] A detection module, configured to detect, based on the attribute information of the intercepted message, access of the process to be detected to the intercepted message within a preset time, wherein the preset time is set according to the detection requirement or according to the maximum time interval during which the resources corresponding to the process to be detected have been idle in history;

[0015] The determination module is used to determine that the resources corresponding to the process to be detected are idle when it is detected that the process to be detected has not accessed the intercepted message within a preset time.

[0016] On the one hand, a computer device is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program code is loaded and executed by the one or more processors to implement the operations performed by the method for detecting resource idleness.

[0017] On the one hand, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program that is loaded and executed by a processor to implement operations performed by the method for detecting resource idleness.

[0018] From the technical solution provided by the present application, it can be seen that, on the one hand, since any message is intercepted in the message receiving and sending direction of the process to be detected, that is, whether the resources are idle for a specific process, compared with the prior art that detects idle resources based on the utilization rate of the entire CPU or network, the technical solution of the present application has a smaller granularity of detection objects, and is therefore more targeted or more accurate in detection; on the other hand, since the preset time is set according to the detection requirements or according to the maximum time interval of the resources corresponding to the process to be detected that have been idle in history, compared with the prior art that frequently detects and thereby mistakenly recycles resources that are actually not suitable for recycling, the technical solution of the present application can avoid such misoperation, thereby only reclaiming truly idle resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] 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 ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0020] Figure 1 is a flow chart of a method for detecting idle resources provided in an embodiment of the present application;

[0021] Figure 2 It is a schematic diagram of intercepting any message in the message receiving and sending direction of the process to be detected provided by an embodiment of the present application;

[0022] Figure 3 It is a structural schematic diagram of a device for detecting idle resources provided in an embodiment of the present application;

[0023] Figure 4 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0024] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.

[0025] The embodiments of the present application are introduced based on computer devices as the execution subject. The computer device here can be a server or a terminal, wherein 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, and 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 above-mentioned terminal and server can be directly or indirectly connected via wired or wireless communication, and this application does not limit this.

[0026] In the prior art, it is often determined whether the resources of a computing node are idle for a computing node. However, this method is not objective. The reason is that there are multiple different processes on a computing node, and the resource idle time of different processes may be different. For example, the resource idle time of processes P1, P2 and P3 are T1, T2 and T3 respectively. When evaluating whether the resources of a computing node are idle, the prior art uses a certain time Tc as a boundary to judge whether the resources of the entire computing node are idle. However, there may be a situation where T2 is greater than Tc, but it is reasonable for process P2 to have idle resources within T2 (for example, due to testing requirements, process P2 is allowed not to use any resources within T2). However, if measured according to Tc, it is considered that process P2 has idle resources. Therefore, recycling P2's resources creates obstacles to the functioning of process P2. In order to solve the above problems, the present application provides a method for detecting idle resources. See. Figure 1 The method mainly includes the following steps S101 to S104, which are described in detail as follows:

[0027] Step S101: intercepting any message in the message receiving and sending direction of the process to be detected to obtain an intercepted message.

[0028] In the embodiment of the present application, the message sending and receiving direction of the process to be detected includes the direction in which the process to be detected sends messages and the direction in which the process to be detected receives messages. When the process to be detected is running on a computer device, the computer device is connected to the network through the network card therein; the network card receives messages from the network and transmits them to the process to be detected, or the process to be detected sends messages and sends them to the network via the network card. Figure 2 As shown, a detection program or a piece of code can be set between the network card and the process to be detected, that is, in the message sending and receiving direction of the process to be detected, and these detection programs or codes intercept any message.

[0029] Step S102: extracting attribute information of the intercepted message from the intercepted message, wherein the attribute information of the intercepted message includes the address, port number and protocol number carried by the intercepted message.

[0030] An intercepted message is any message intercepted in the message sending and receiving direction of the process to be detected, and its attribute information is the address, port number and protocol number carried by the message, wherein the address of the message includes the source address or the destination address, that is, the source address, port number and protocol number carried by the message, or the destination address, port number and protocol number carried by the message, these triplets constitute the basic attributes of the message.

[0031] Step S103: according to the attribute information of the intercepted message, detecting the access of the process to be detected to the intercepted message within a preset time, wherein the preset time is set according to the detection requirement or according to the maximum time interval of the resource corresponding to the process to be detected being idle in history.

[0032] In order to detect the access of the process to be detected to the intercepted message within a preset time according to the attribute information of the intercepted message, any message can be intercepted in the message receiving and sending direction of the process to be detected in step S101, and a hash table can be created before obtaining the intercepted message. The hash table here uses the address, port number and protocol number carried by each target message as the key code to form a key-value pair, and uses the timestamp of each target message to form the value of the key-value pair. The value or timestamp is stored in a storage unit whose address is the hash value obtained by performing a hash operation using a certain function as the hash function, wherein the above-mentioned port number represents the port used by the process to be detected to communicate. Considering that the access of the process to be detected to the intercepted message within the preset time is detected based on the attribute information of the intercepted message, mainly by using the address, port number and protocol number carried by the intercepted message as the key code, and using the calculated hash value to index on the hash table. However, since different key codes may obtain the same hash value, that is, there is a hash conflict, therefore, as an embodiment of the present application, when creating the hash table, it can be implemented through the following steps S11 to S15 to reduce the probability of hash conflicts:

[0033] Step S11: performing hash operations on the X key codes respectively based on the initial hash function to obtain first hash values ​​corresponding to the respective key codes of the X key codes.

[0034] In the embodiment of the present application, based on the initial hash algorithm, hash operations are performed on the X key codes respectively to obtain the first hash value corresponding to each of the X key codes.

[0035] Step S12: determining a collision probability p of the first Hash value of the key code according to the number Y of the key codes with conflicting first Hash values ​​and the number X of the key codes, wherein X and Y are positive integers.

[0036] The concept of hash value collision or hash collision is as described above. In the embodiment of the present application, the number of key codes is X, and the number of key codes with conflicting first hash values ​​is Y, then the collision probability of the first hash value of the key code is p=Y / X. For example, if the number of all key codes is 15000, only the first hash values ​​of the key codes "edsxu", "fexyz" and "byduk" are the same and there is a conflict, then the collision probability of the first hash value of this group of key codes is p=3 / 15000=0.02%.

[0037] Step S13: modifying the initial hash function according to the collision probability of the first hash value of the key code to obtain a determined hash function.

[0038] As an embodiment of the present application, the initial hash function is modified according to the collision probability of the first hash value of the key code, and the determined hash function can be: 1) setting the maximum allowable value P of the hash value collision probability m ; 2) According to the maximum allowable value P of the probability of hash value collision m The collision probability p of the first hash value of the key code is continuously adjusted, and the collision probability of the hash value is calculated using the hash functions with different parameters; 3) when the collision probability p of the hash value is reduced to less than the maximum allowable value P of the hash value collision probability m When , the parameters at this time are used as the parameters of the determined hash function to obtain the determined hash function.

[0039] Step S14: performing hash operations on the X key codes respectively based on the determined hash function to obtain second hash values ​​corresponding to the respective key codes of the X key codes.

[0040] After the determined hash function is obtained in step S3, the determined hash function is used to perform hash operations on the X key codes respectively to obtain second hash values ​​corresponding to each of the X key codes.

[0041] Step S15: construct a red-black tree according to the second hash value and construct a corresponding hash table based on the red-black tree.

[0042] In one or more embodiments of the present specification, the red-black tree is a self-balancing binary search tree, and the absolute value of the difference between the minimum height and the maximum height of the balanced binary tree does not exceed 1. When the red-black tree is in an empty state, the root node and the child nodes of the root node in the tree are both empty nodes. X key codes are used as keys (key), and the second hash values ​​of the X key codes are used as the storage address of the value (value) to construct a red-black tree. During the construction of the red-black tree, in order to maintain the balance of the red-black tree, the nodes of the tree will be color-changed and rotated. When the red-black tree representation is constructed, a traversal of the red-black tree representation is completed, and a hash table is created based on the information of each node in the red-black tree representation obtained by the traversal.

[0043] Corresponding to the hash table constructed by the above steps S11 to S15, as an embodiment of the present application, according to the attribute information of the intercepted message, detecting the access of the process to be detected to the intercepted message within a preset time can be implemented by the following steps S'11 to S'14:

[0044] Step S'11: Using the address, port number and protocol number carried in the intercepted message as key codes, the calculated hash value is used to index the hash table.

[0045] In an embodiment of the present application, the address, port number and protocol number carried by the message can be intercepted as a key code, and the hash function used when constructing the hash table is used as a hash function to calculate the hash value of the key code. The calculated hash value is the address of the storage unit of the value corresponding to the key-value pair corresponding to the key code.

[0046] Step S'12: If the hash table is hit, the value of the timestamp of the intercepted message is changed; otherwise, the initial value of the timestamp of the intercepted message is maintained.

[0047] As mentioned above, in the hash table, the address, port number and protocol number carried by each target message are used as the key code to form a key-value pair, and the timestamp of each target message is used to form the value of the key-value pair. Therefore, the value of the timestamp of the intercepted message here is the value of the key-value pair formed by the address, port number and protocol number carried by the intercepted message as the key code. For example, when the process to be detected receives the intercepted message, the value of the timestamp of the intercepted message here is the value of the key-value pair formed by the destination address, port number and protocol number carried by the intercepted message as the key code, and when the process to be detected sends the intercepted message, the value of the timestamp of the intercepted message here is the value of the key-value pair formed by the source address, port number and protocol number carried by the intercepted message as the key code. If the hash table is hit, it means that there is a storage unit with the address, port number and protocol number carried by a certain intercepted message as the key code and the hash value calculated by the hash function when the hash table is created as the hash function, and the storage unit stores the initial value of the timestamp of the intercepted message. The initial value of the timestamp is changed. Specifically, when the intercepted message is a message received by the process to be detected, the initial value of the timestamp of the intercepted message is changed to the time when the intercepted message is received; when the intercepted message is a message sent by the process to be detected, the initial value of the timestamp of the intercepted message is changed to the time when the intercepted message is sent.

[0048] Step S'13: The daemon process reads the timestamp of the intercepted message from the timestamp storage unit at a preset time period.

[0049] As mentioned above, the preset time of the present application can be set according to the detection requirements or according to the maximum time interval in which the resources corresponding to the process to be detected have been idle in history. For example, for some processes with management functions or processes with testing functions, it can be set according to the detection requirements. For example, if it is expected that the process may be idle for 2 days, the preset time can be set to 2 days. For other processes, it can also be set according to the maximum time interval in which the resources corresponding to the process to be detected have been idle in history. In this way, it can be objectively evaluated whether the resources are really idle.

[0050] In an embodiment of the present application, a daemon process may be set up, which reads the timestamp of the intercepted message from the timestamp storage unit at a preset time period.

[0051] Step S'14: If the value of the timestamp of the intercepted message has been changed, it is determined that the process to be detected has accessed the intercepted message within the preset time; otherwise, it is determined that the process to be detected has not accessed the intercepted message within the preset time.

[0052] Since the hash table may be hit after step S'11 indexing, after hitting the hash table, the value of the timestamp of the intercepted message is changed, otherwise, the initial value of the timestamp of the intercepted message is maintained. Therefore, if the daemon process reads the timestamp of the intercepted message from the timestamp storage unit and finds that the value of the timestamp of the intercepted message has changed, it is determined that the process to be detected has accessed the intercepted message within the preset time. If the value of the timestamp of the intercepted message has not changed, that is, it is still the initial value, it is determined that the process to be detected has not accessed the intercepted message within the preset time.

[0053] The probability of hash collision is reduced, the utilization rate of hash table storage space is improved, and storage resources are saved. As an embodiment of the present application, creating a hash table can be implemented through the following steps S21 to S24:

[0054] Step S21: allocate a first table entry storage space from the memory, where the first table entry storage space includes a plurality of address spaces.

[0055] In an embodiment of the present application, each address space of the first table item storage space is set and maintained with an empty and full flag indicating the fullness degree of the address space. For example, a variable is set for each address space as an empty and full flag. Every time a piece of information is stored in the address space, the variable is increased by 1. Therefore, the smaller the value of the empty and full flag of an address space, the more storage space the address space has.

[0056] Step S22: construct at least two hash functions, and use the at least two hash functions to perform hash calculations on the key codes to obtain at least two hash values ​​corresponding to each key code.

[0057] The key code is the address, port number and protocol number carried by the target message. In this embodiment, for each key code, at least two hash functions are used to perform hash calculations on it, and at least two hash values ​​are calculated, and the at least two hash values ​​correspond to at least two different address spaces.

[0058] Step S23: comparing the fullness of the address spaces corresponding to at least two hash values, and storing the information to be stored in the address space with the most storage space in the address space in the first entry storage space.

[0059] As mentioned above, the smaller the value of the empty and full flag of an address space, the more storage space the address space has. Therefore, by comparing the empty and full degrees of the address space corresponding to at least two hash values, the values ​​of the empty and full flags of the address space corresponding to the at least two hash values ​​can be compared. If the value of the empty and full flag of an address space is smaller, the information to be stored should be stored in this address space.

[0060] Step S24: If the address spaces corresponding to at least two hash values ​​are full, the information to be stored is stored in the second entry storage space.

[0061] As mentioned above, each address space of the first table item storage space maintains an empty and full flag indicating the fullness of the address space. Therefore, when comparing the fullness of the address spaces corresponding to at least two hash values, the empty and full flags of the at least two address spaces can be checked. If the at least two address spaces are not full, the information to be stored is stored in the address space with the most storage space in the address space in the first table item storage space. If the address spaces corresponding to at least two hash values ​​are full, the information to be stored is stored in the second table item storage space; in the embodiment of the present application, the second table item storage space can also include several address spaces as needed.

[0062] Obviously, storing the information to be stored in the address space with the most abundant storage space in the address space of the first table entry storage space can reduce the probability of hash conflict, and using at least two hash functions to calculate the storage address can save storage resources.

[0063] Corresponding to the hash table constructed by the above steps S21 to S24, as an embodiment of the present application, according to the attribute information of the intercepted message, detecting the access of the process to be detected to the intercepted message within a preset time can be implemented by the following steps S'21 to S'25:

[0064] Step S'21: using the address, port number and protocol number carried in the intercepted message as key codes, using at least two hash functions to perform hash calculations on the key codes in parallel to obtain at least two hash values.

[0065] The so-called parallel calculation of hash values ​​refers to that at least two hash functions perform hash calculations on the key code at the same time to obtain at least two hash values, which can improve efficiency.

[0066] Step S'22: indexing the hash table with at least two hash values.

[0067] It should be noted that indexing the hash table with at least two hash values ​​can also be performed in parallel, which can also improve indexing efficiency.

[0068] According to the search principle of the hash table, the hash table is indexed with at least two hash values, which is actually the first table item storage space and the second table item storage space mentioned in the above embodiment. When the first table item storage space cannot be indexed, that is, the hash table is not hit, the second table item storage space is continued to be indexed. If both table item storage spaces cannot be indexed, it indicates that the search failed, that is, the hash table was not hit.

[0069] Step S'23: If the hash table is hit, the value of the timestamp of the intercepted message is changed; otherwise, the initial value of the timestamp of the intercepted message is maintained.

[0070] Step S'24: the daemon process reads the timestamp of the intercepted message from the timestamp storage unit at a preset time period.

[0071] As mentioned above, the timestamp of the message is stored in the storage unit whose address is the hash value obtained when the hash table is created. Therefore, if the hash table is hit, the timestamp of the intercepted message can be read from the storage unit.

[0072] Step S'25: If the value of the timestamp of the intercepted message has been changed, it is determined that the process to be detected has accessed the intercepted message within the preset time; otherwise, it is determined that the process to be detected has not accessed the intercepted message within the preset time.

[0073] In this embodiment, steps S'23 to S'25 are respectively the same as steps S'12 to S'14 of the aforementioned embodiment, and reference may be made to the relevant description of the aforementioned embodiment, which will not be repeated here.

[0074] Step S104: when it is detected that the process to be detected has not accessed the intercepted message within a preset time, it is determined that the resources corresponding to the process to be detected are idle.

[0075] In step S104, the definition of the preset time is as described above, that is, it is set according to the detection requirements or according to the maximum time interval of the resources corresponding to the process to be detected that have been idle in history. For relevant explanations, please refer to the description of the previous embodiment, which will not be repeated here.

[0076] From the above attached Figure 1It can be seen from the technical solution of the example that, on the one hand, since any message is intercepted in the message receiving and sending direction of the process to be detected, that is, whether the resources are idle for a specific process, compared with the prior art that detects resource idleness based on the utilization rate of the entire CPU or network, the technical solution of the present application has a smaller granularity of detection objects, and is therefore more targeted or the detection is more accurate; on the other hand, since the preset time is set according to the detection requirements or according to the maximum time interval in which the resources corresponding to the process to be detected have been idle in history, compared with the prior art that frequently detects and thereby mistakenly recycles resources that are actually not suitable for recycling, the technical solution of the present application can avoid such misoperation, thereby only reclaiming truly idle resources.

[0077] Please see attached Figure 3 , is a schematic diagram of a structure of a device for detecting idle resources provided in an embodiment of the present application. The device can be integrated in a computer device such as a terminal. The device includes a message interception module 301, an extraction module 302, a detection module 303 and a determination module 304, wherein:

[0078] The message interception module 301 is used to intercept any message in the message receiving and sending direction of the process to be detected to obtain the intercepted message;

[0079] An extraction module 302 is used to extract attribute information of the intercepted message from the intercepted message, wherein the attribute information of the intercepted message includes an address, a port number and a protocol number carried by the intercepted message;

[0080] The detection module 303 is used to detect the access of the process to be detected to the intercepted message within a preset time according to the attribute information of the intercepted message, wherein the preset time is set according to the detection requirement or according to the maximum time interval of the resource corresponding to the process to be detected being idle in history;

[0081] The determination module 304 is used to determine that the resources corresponding to the process to be detected are idle when it is detected that the process to be detected has not accessed the intercepted message within a preset time.

[0082] In one possible implementation, Figure 3 The example device also includes a creation module, which is used to intercept any message in the message sending and receiving direction of the process to be detected in the message interception module 301, and create a hash table before obtaining the intercepted message, wherein the hash table uses the address, port number and protocol number carried by each target message as the key code to form a key-value pair, and uses the timestamp of each target message to form the value of the key-value pair.

[0083] In a possible implementation, the creation module of the above embodiment is used to perform hash operations on X key codes based on an initial hash function to obtain first hash values ​​corresponding to each of the X key codes, determine a collision probability p of the first hash values ​​of the key codes according to the number Y of key codes with conflicting first hash values ​​and the number X of key codes, modify the initial hash function according to the collision probability of the first hash values ​​to obtain a determined hash function; perform hash operations on the X key codes based on the determined hash function to obtain second hash values ​​corresponding to each of the X key codes, construct a red-black tree according to the second hash values, and construct a corresponding hash table based on the red-black tree, wherein X and Y are positive integers.

[0084] In one possible implementation, Figure 3 The detection module 303 of the example is used to use the address, port number and protocol number carried by the intercepted message as key codes, and use the calculated hash value to index on the hash table; if the hash table is hit, the value of the timestamp of the intercepted message is changed, otherwise, the initial value of the timestamp of the intercepted message is maintained; the daemon process reads the timestamp of the intercepted message from the timestamp storage unit with a preset time as a period; if the value of the timestamp of the intercepted message has been changed, it is determined that the process to be detected has accessed the intercepted message within the preset time, otherwise, it is determined that the process to be detected has not accessed the intercepted message within the preset time.

[0085] In one possible implementation, the creation module of the above embodiment is used to allocate a first table item storage space from the memory, construct at least two hash functions, and use the at least two hash functions to perform hash calculation on the key code to obtain at least two hash values ​​corresponding to each key code, compare the empty and full degrees of the address space corresponding to the at least two hash values, store the information to be stored in the address space with the most abundant storage space in the address space, and if the address spaces corresponding to the at least two hash values ​​are full, store the information to be stored in the second table item storage space, wherein the first table item storage space includes a plurality of address spaces; corresponding to this implementation, the attached Figure 3 The example detection module 303 is used to use the address, port number and protocol number carried by the intercepted message as key codes, and use the calculated hash value to index on the hash table. If the hash table is hit, the value of the timestamp of the intercepted message is changed, otherwise, the initial value of the timestamp of the intercepted message is maintained. The daemon process reads the timestamp of the intercepted message from the timestamp storage unit at a preset time period. If the value of the timestamp of the intercepted message has been changed, it is determined that the process to be detected has accessed the intercepted message within the preset time, otherwise, it is determined that the process to be detected has not accessed the intercepted message within the preset time.

[0086] It should be noted that the device for detecting idle resources provided in the above embodiment only uses the division of the above functional modules as an example when detecting idle resources. In actual applications, the above functional distribution can be completed by different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device for detecting idle resources provided in the above embodiment and the method embodiment for detecting idle resources belong to the same concept. The specific implementation process and technical effects are detailed in the method embodiment, which will not be repeated here.

[0087] The present application also provides a computer device, which may be a terminal or a server. Figure 4 As shown, it shows a schematic diagram of the structure of the computer device involved in the embodiment of the present application, specifically:

[0088] The computer device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will appreciate that Figure 4 The computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. Among them:

[0089] The processor 401 is the control center of the computer device. It uses various interfaces and lines to connect various parts of the entire computer device. By running or executing software programs and / or modules stored in the memory 402 and calling data stored in the memory 402, it executes various functions of the computer device and processes data, thereby performing overall detection of the computer device. Optionally, the processor 401 may include one or more processing cores; preferably, the processor 401 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 401.

[0090] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 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 computer device, etc. In addition, the memory 402 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 402 may also include a memory controller to provide the processor 401 with access to the memory 402.

[0091] The computer device also includes a power supply 403 for supplying power to various components. Optionally, the power supply 403 can be logically connected to the processor 401 through a power management system, so as to manage charging, discharging, and power consumption through the power management system. The power supply 403 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.

[0092] The computer device may further include an input unit 404, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.

[0093] Although not shown, the computer device may also include a display unit, etc., which will not be described in detail here. Specifically in this embodiment, the processor 401 in the computer device will load the executable file corresponding to the process of one or more applications into the memory 402 according to the following instructions, and the processor 401 will run the application stored in the memory 402, thereby realizing various functions, as follows: intercepting any message in the message receiving and sending direction of the process to be detected to obtain an intercepted message; extracting attribute information of the intercepted message from the intercepted message, wherein the attribute information of the intercepted message includes the address, port number and protocol number carried by the intercepted message; according to the attribute information of the intercepted message, detecting the access of the process to be detected to the intercepted message within a preset time, the preset time is set according to the detection requirement or according to the maximum time interval of the resource corresponding to the process to be detected being idle in history; when it is detected that the process to be detected has not accessed the intercepted message within the preset time, it is determined that the resource corresponding to the process to be detected is idle.

[0094] The specific implementation of the above operation can refer to the previous implementation, which will not be described again here.

[0095] From the above, it can be seen that, unlike the prior art which detects idle resources based on the utilization of the entire CPU or network, the technical solution of the present application, on the one hand, intercepts any message in the message receiving and sending direction of the process to be detected, that is, detects whether the resources are idle for a specific process, so the granularity of the detection object is smaller, more targeted or the detection is more accurate; on the other hand, since the preset time is set according to the detection requirements or according to the maximum time interval of the resources corresponding to the process to be detected in history, compared with the prior art which frequently detects and thereby mistakenly recycles resources that are actually not suitable for recycling, the technical solution of the present application can avoid such misoperation, thereby only reclaiming truly idle resources.

[0096] 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.

[0097] 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 one of the methods for detecting resource idleness provided in the embodiment of the present application. For example, the instruction can execute the following steps: intercepting any message in the message receiving and sending direction of the process to be detected to obtain an intercepted message; extracting attribute information of the intercepted message from the intercepted message, wherein the attribute information of the intercepted message includes the address, port number and protocol number carried by the intercepted message; according to the attribute information of the intercepted message, detecting the access of the process to be detected to the intercepted message within a preset time, the preset time is set according to the detection requirements or according to the maximum time interval of the resource corresponding to the process to be detected being idle in history; when it is detected that the process to be detected has not accessed the intercepted message within the preset time, it is determined that the resource corresponding to the process to be detected is idle.

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

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

[0100] Since the instructions stored in the computer-readable storage medium can execute the steps in any method for detecting idle resources provided in the embodiments of the present application, the beneficial effects that can be achieved by any method for detecting idle resources 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.

[0101] The above is a detailed introduction to a method, device and computer-readable storage medium for detecting idle resources provided in an embodiment 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, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A method for detecting idle resources, characterized in that: The method comprises: Create a hash table, wherein the address, port number and protocol number carried by each target message are used as key codes to form a key-value pair, and the timestamp of each target message is used to form a value of the key-value pair; Intercept any message in the message receiving and sending direction of the process to be detected to obtain the intercepted message; Extracting attribute information of the intercepted message from the intercepted message, wherein the attribute information of the intercepted message includes an address, a port number and a protocol number carried by the intercepted message; According to the attribute information of the intercepted message, the access of the process to be detected to the intercepted message within a preset time is detected, and the preset time is set according to the detection requirements or according to the maximum time interval of the resources corresponding to the process to be detected being idle in history, including: using the address, port number and protocol number carried by the intercepted message as key codes, using the calculated hash value to index on the hash table, if the hash table is hit, then changing the value of the timestamp of the intercepted message, otherwise, keeping the initial value of the timestamp of the intercepted message, the daemon process uses the preset time as a period, reads the timestamp of the intercepted message from the timestamp storage unit, if the value of the timestamp of the intercepted message has been changed, it is determined that the process to be detected has accessed the intercepted message within the preset time, otherwise, it is determined that the process to be detected has not accessed the intercepted message within the preset time; When it is detected that the process to be detected has not accessed the intercepted message within a preset time, it is determined that the resources corresponding to the process to be detected are idle.

2. The method for detecting idle resources according to claim 1, characterized in that: The creating of the hash table comprises: Performing hash operations on the X key codes respectively based on the initial hash function to obtain first hash values ​​corresponding to each of the X key codes; Determine a collision probability p of the first hash value of the key code according to the number Y of key codes with conflicting first hash values ​​and the number X of the key codes, where X and Y are positive integers; Modify the initial Hash function according to the collision probability of the first Hash value to obtain a determined Hash function; Based on the determined hash function, hash operations are performed on the X key codes respectively to obtain second hash values ​​corresponding to each of the X key codes; A red-black tree is constructed according to the second hash value, and a corresponding hash table is constructed based on the red-black tree.

3. The method for detecting idle resources according to claim 1, characterized in that: The creating of the hash table comprises: Allocate a first table entry storage space from the memory, wherein the first table entry storage space includes a plurality of address spaces; Constructing at least two hash functions, and performing hash calculation on the key code using the at least two hash functions to obtain at least two hash values ​​corresponding to each of the key codes; Comparing the fullness of the address spaces corresponding to the at least two hash values, and storing the information to be stored in the address space with the most storage space among the address spaces; If the address spaces corresponding to the at least two hash values ​​are full, the information to be stored is stored in the second table entry storage space.

4. The method for detecting idle resources according to claim 3, characterized in that: The detecting, according to the attribute information of the intercepted message, access of the process to be detected to the intercepted message within a preset time includes: Using the address, port number and protocol number carried by the intercepted message as key codes, using the at least two hash functions to perform hash calculations on the key codes in parallel to obtain at least two hash values; Indexing the hash table with the at least two hash values; If the hash table is hit, the value of the timestamp of the intercepted message is changed; otherwise, the initial value of the timestamp of the intercepted message is maintained; The daemon process reads the timestamp of the intercepted message from the timestamp storage unit at the preset time period; If the value of the timestamp of the intercepted message has been changed, it is determined that the process to be detected has accessed the intercepted message within a preset time; otherwise, it is determined that the process to be detected has not accessed the intercepted message within the preset time.

5. A device for detecting idle resources, characterized in that: The device comprises: A hash table creation module, used to create a hash table, wherein the address, port number and protocol number carried by each target message are used as key codes to form a key-value pair, and the timestamp of each target message is used to form a value of the key-value pair; The message interception module is used to intercept any message in the message receiving and sending direction of the process to be detected to obtain the intercepted message; An extraction module, used for extracting attribute information of the intercepted message from the intercepted message, wherein the attribute information of the intercepted message includes an address, a port number and a protocol number carried by the intercepted message; A detection module, used for detecting, according to the attribute information of the intercepted message, the access of the process to be detected to the intercepted message within a preset time, wherein the preset time is set according to the detection requirement or according to the maximum time interval of the resource corresponding to the process to be detected being idle in history, including: using the address, port number and protocol number carried by the intercepted message as key codes, using the calculated hash value to index on the hash table, if the hash table is hit, then changing the value of the timestamp of the intercepted message, otherwise, keeping the initial value of the timestamp of the intercepted message, the daemon process reads the timestamp of the intercepted message from the timestamp storage unit with the preset time as a period, if the value of the timestamp of the intercepted message has been changed, then determining that the process to be detected has accessed the intercepted message within the preset time, otherwise, determining that the process to be detected has not accessed the intercepted message within the preset time; The determination module is used to determine that the resources corresponding to the process to be detected are idle when it is detected that the process to be detected has not accessed the intercepted message within a preset time.

6. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.

7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.