Model detection method and device, equipment and storage medium
By load balancing model detection requests between multiple worker processes, the problem of low multi-core CPU utilization caused by Python GIL is solved, and efficient model detection and processing is achieved.
Patent Information
- Application Number
- CN202510020883.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-07
- Publication Date
- 2025-04-15
AI Technical Summary
Python's global interpreter lock (GIL) causes the multi-core CPU to be unable to fully utilize in multi-threaded environments, resulting in performance bottlenecks, especially in high concurrency scenarios with severe response latency.
By setting up multiple worker processes to listen to the port at the same time, when receiving a model detection request, the receiving worker process is randomly selected from multiple worker processes, and the target worker process detects the target model, thereby realizing the load balancing of the request.
It realizes efficient processing of model detection, avoids the bottleneck pressure caused by the port corresponding to a main work process, and improves the system's model detection capabilities.
Smart Images

Figure CN119829350A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a model detection method, device, equipment and storage medium. Background Art
[0002] Python is indeed very popular in the field of data science and machine learning, with a wealth of libraries and frameworks, such as Tensor Flow, PyTorch, Scikit-learn, etc. Python's simple syntax and developed ecosystem make it the preferred language for many developers and researchers. Building a Python-based machine learning model service involves many aspects, including model deployment, performance optimization, service architecture design, etc. Machine learning models are usually large and take a long time to load, especially when the service is started. If the model is loaded for each request, it will result in a long response time. Python's Global Interpreter Lock (GIL) will prevent the full utilization of multi-core CPUs in a multi-threaded environment, resulting in performance bottlenecks. In high-concurrency scenarios, response delays may occur, and model reasoning itself may be computationally intensive, especially when processing large batches of data, which may become a performance bottleneck. A common solution is to use frameworks such as Flask and Django, and then use a process pool to perform detection tasks.
[0003] Frameworks such as Flask and Django are all single-process. One process listens to one port and provides machine learning algorithm services to the outside world. In order to solve the problems caused by GIL, this framework can use multiple processes to handle multiple detection requests at the same time, but at the same time the main process will become a performance bottleneck. In the case of high concurrency, when the child process can still provide more detections, the main process will reach the maximum load. Summary of the invention
[0004] The invention provides a model detection method to realize efficient detection of the model.
[0005] According to a first aspect of the present invention, there is provided a model detection method, comprising: receiving a model detection request through a port of an operating system, wherein the model detection request includes a model identifier;
[0006] Randomly select a receiving work process from a plurality of work processes listening to the port, and send the model detection request to the receiving work process;
[0007] A target working process is determined through the receiving working process, and the target working process detects the target model corresponding to the model identifier.
[0008] Optionally, randomly selecting a receiving working process from a plurality of working processes listening to the port includes:
[0009] Get all working processes that listen to the port;
[0010] An event notification mechanism is used to determine the receiving work process from all the work processes.
[0011] Optionally, before sending the model detection request to the receiving work process, the method further includes:
[0012] Creating a domain socket for each of the working processes;
[0013] The corresponding relationship between each of the working processes and the domain socket is saved.
[0014] Optionally, determining the target working process through the receiving working process includes:
[0015] The receiving work process uses a consistent hash algorithm to calculate the model identifier to obtain a target domain socket;
[0016] The working process corresponding to the target domain socket is used as the target working process.
[0017] Optionally, the target working process detects the target model corresponding to the model identifier, including:
[0018] When the target domain socket does not match the domain socket of the receiving working process, forwarding the model detection request to the target working process through the receiving working process;
[0019] When it is determined that the target model is cached in the target working process, the target model is directly detected through the target working process.
[0020] Optionally, the method further includes:
[0021] When it is determined that the target model is not cached in the target working process, loading the target model from a model storage database;
[0022] The loaded target model is cached in the target working process.
[0023] Optionally, after the target working process detects the target model corresponding to the model identifier, the method further includes:
[0024] Determine whether the target working process directly receives the model detection request, and if so, directly feed back the model detection result to the port of the operating system,
[0025] Otherwise, the model detection result is forwarded to the receiving working process, and the model detection result is fed back to the port of the operating system through the receiving working process.
[0026] According to another aspect of the present invention, there is provided a model detection device, comprising:
[0027] A model detection request receiving module, used for receiving a model detection request through a port of an operating system, wherein the model detection request includes a model identifier;
[0028] A model detection request sending module, used for randomly selecting a receiving work process from a plurality of work processes listening to the port, and sending the model detection request to the receiving work process;
[0029] The model detection module is used to determine the target working process through the receiving working process, and the target working process detects the target model corresponding to the model identifier.
[0030] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0031] at least one processor; and
[0032] a memory communicatively connected to the at least one processor; wherein,
[0033] The memory stores a computer program that can be executed by the at least one processor. The computer program is executed by the at least one processor so that the at least one processor can perform the method described in any embodiment of the present invention.
[0034] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method described in any embodiment of the present invention when executed.
[0035] The technical solution of the embodiment of the present invention is to set up multiple working processes to listen to the port at the same time. When a model detection request is received through the port, a target working process can be determined from the multiple working processes to detect the target model, thereby realizing load balancing of the requests and avoiding the bottleneck pressure caused when the port corresponds to one main working process.
[0036] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0038] Figure 1 is a flow chart of a model detection method provided according to Embodiment 1 of the present invention;
[0039] Figure 2 is a schematic diagram of an application architecture of a model detection method provided in Embodiment 1 of the present invention;
[0040] Figure 3 is a flow chart of a model detection method provided according to Embodiment 2 of the present invention;
[0041] Figure 4 is a structural schematic diagram of a model detection device provided according to Embodiment 3 of the present invention;
[0042] Figure 5 It is a schematic diagram of the structure of an electronic device provided by Embodiment 4 of the present invention. DETAILED DESCRIPTION
[0043] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0044] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0045] Embodiment 1
[0046] Figure 1A flowchart of a model detection method is provided for the first embodiment of the present invention. This embodiment is applicable to the case where a model is detected based on a model detection request. The method can be executed by a model detection device, which can be implemented in the form of hardware and / or software. Figure 1 As shown, the method includes:
[0047] Step S101: receiving a model detection request through a port of an operating system.
[0048] Specifically, Figure 2 The schematic diagram of the application architecture of the model detection method in this embodiment is shown. When the user needs to detect the specified model, the detection request can be sent to the operating system. The system specifically receives the model detection request sent by the user through the port. The model detection request includes a model identifier. There will be multiple working processes listening to the port of the operating system, from which a target working process can be screened out to execute the model detection request to detect the target model corresponding to the model identifier, and each working process can load the model from the model storage database located on the hard disk, and cache the loaded model in the memory. Among them, the function of the working process monitoring each port in this embodiment is the same, and there is no distinction between master and slave. Therefore, the working process can be increased according to the processing pressure, so as to achieve vertical expansion in the architecture to improve the model detection capability of the system. Therefore, the specific number of working processes listening to the port is not limited in this embodiment, and the user can set it according to the actual processing pressure.
[0049] Among them, in this embodiment, the user can set the model detection request on the user side. For example, the user side can be a human-computer interaction interface, which includes options for various models. The user can input the model identifier by clicking. After receiving the target model selected by the user through the human-computer interaction interface, the terminal can generate a model detection request according to the model identifier. There is also a modification button on the human-computer interaction interface, which can modify the selected target model. In addition, there is also a model detection result display panel on the human-computer interaction interface, and the detection results obtained by detecting the target model can be displayed on the display panel. Of course, this embodiment is only an example, and does not limit the specific generation method of the model detection request.
[0050] It should be noted that in the above framework, each model has a model identifier, such as uuid, and the uuids of each model are different, so that each work process knows which specific model to test. Therefore, the model detection request sent by the user contains the model identifier corresponding to the model to be tested, such as uuid1. Of course, this implementation is only an example for illustration, and does not limit the specific content of the model identifier contained in the model.
[0051] Step S102: randomly select a receiving work process from multiple work processes listening to the port, and send a model detection request to the receiving work process.
[0052] Optionally, randomly selecting a receiving working process from a plurality of working processes of the listening port includes: obtaining all working processes of the listening port; and determining the receiving working process from all working processes using an event notification mechanism.
[0053] Specifically, in this embodiment, after receiving the model detection request, the operating system will obtain all the working processes of the listening port, for example, working process 1, working process 2 and working process 3, and then use the event notification mechanism, such as the epoll method, to randomly select a working process as the receiving working process, such as working process 2, and send the model detection request to working process 2. Among them, the epoll method is an improved poll in the Linux kernel for processing large batches of file descriptors. It is an enhanced version of the multiplexed IO interface select or poll under Linux. It can significantly improve the system CPU utilization rate when the program has only a small number of active connections in a large number of concurrent connections. Another reason is that when obtaining events, it does not need to traverse the entire set of descriptors being listened to, but only needs to traverse the descriptor sets that are asynchronously awakened by the kernel IO event and added to the ready queue. In addition to providing the horizontal triggering of IO events such as select or poll, epoll also provides edge triggering, which makes it possible for user space programs to cache IO status, reduce the calls of epoll_wait or epoll_pwait, and improve application efficiency. Since the working principle of the epoll method is not the focus of this application, it will not be described in detail in this implementation.
[0054] It should be noted that the receiving work process determined in this implementation may be the target work process for executing the model detection request, or may not be the target work process, which needs to be determined by the receiving work process.
[0055] Optionally, before sending the model detection request to the receiving working process, the method further includes: creating a domain socket for each working process; and saving the corresponding relationship between each working process and the domain socket.
[0056] Among them, in this implementation, a domain socket is created for each work process when configuring the work process. The domain socket is determined by a file path, and then a working directory is specified. Each work process corresponds to a file in the directory. For example, work process 1 can start a domain socket with a file address of / socket / 1, and work process 2 can start a domain socket with a file address of / socket / 2. Of course, this implementation is only an example, and does not limit the specific content of the domain socket corresponding to each work process.
[0057] It is worth mentioning that in this implementation, after creating a domain socket for each work process, the corresponding relationship between the work process and the domain socket will be saved, and the corresponding relationship can be saved in each work process, so that each work process can know the domain socket corresponding to each work process in the framework. The following Table 1 shows an example of the corresponding relationship between the work process and the domain socket saved by the work process:
[0058] Table 1
[0059] Work process Domain Sockets Worker Process 1 file1 / socket / 1 Worker Process 2 file1 / socket / 2 … Worker process n File2socket / n
[0060] Among them, the correspondence between the above-mentioned work processes and domain sockets can be saved in each work process located in the memory, so that when each work process is selected as a receiving work process, the target work process can be determined based on the above-mentioned correspondence to forward the model detection request to the determined target work process. Of course, this implementation is only an example for illustration, and does not limit the specific content of the domain socket of each work process in Table 1.
[0061] Step S103, determining a target working process by receiving the working process, and having the target working process detect the target model corresponding to the model identifier.
[0062] Optionally, determining the target working process by receiving the working process includes: calculating the model identifier by using a consistent hashing algorithm to obtain a target domain socket by receiving the working process; and using the working process corresponding to the target domain socket as the target working process.
[0063] Among them, in this implementation, for each model detection request, it is hoped that the request will be routed to the working process of the cached model, so that there is no need to load the model twice, thereby improving the detection efficiency of the model. However, since multiple working processes listen to the same port together, the request cannot be distinguished in which working process it should be processed when the operating system processes it. Based on the above problem, this application can use the above-created domain socket to forward the request to the cached working process for processing.
[0064] Specifically, in the present embodiment, the receiving work process that receives the model detection request is not necessarily the target work process that performs the detection. After obtaining the model detection request, the receiving work process, such as work process 2, will extract the model identifier in the model detection request, such as uuid1, and then use the consistent hashing algorithm to calculate the model identifier to obtain the target domain socket, for example, hashing the model identifier uuid1 to the corresponding target domain socket: file 1 / socket / 1, work process 2 determines whether the obtained target domain socket is the same as its own domain socket. If they are the same, it directly uses itself as the target work process. If they are not the same, it determines the target work process corresponding to the target domain socket. For example, work process 2 can obtain the target work process corresponding to the target domain socket as work process 1 by querying the above Table 1. In addition, when determining the target work process through the consistent hashing algorithm, it is best to select the work process that has cached the target model.
[0065] Optionally, the target working process detects the target model corresponding to the model identifier, including: when the target domain socket does not match the domain socket of the receiving working process, forwarding the model detection request to the target working process through the receiving working process; when it is determined that the target model is cached in the target working process, directly detecting the target model through the target working process.
[0066] Optionally, the method further includes: when it is determined that the target model is not cached in the target working process, loading the target model from the model storage database; and caching the loaded target model in the target working process.
[0067] Specifically, in this embodiment, when work process 2 determines that it is the target work process, it does not need to route the request, but work process 2 directly detects the target model; however, when work process 2 determines that it is not the target work process, it needs to route the request to forward the model detection request to the target work process, thereby using the domain socket to forward the request to the work process of the cached model for processing. For example, when the target work process is determined to be work process 1 based on the domain socket, since multiple models can be cached in each work process, when work process 1 receives the model detection request, it will extract the model identifier in the request and determine the target model to be detected, and detect the target model to obtain the detection result.
[0068] It should be noted that when the working process is started for the first time and no model detection has been performed, there may be a situation where the target model is not cached in the working process. In this case, the target working process will load the target model from the model storage database located on the hard disk, and cache the loaded target model in the memory to detect the currently cached target model. Since the working processes of the listening port in this embodiment are equal in status and there is no master-slave distinction, and all have the function of detecting the model, the best target working process can be selected from multiple working processes to perform model detection. Even when the number of requests increases, the processing pressure of a single working process can be reduced by increasing the number of working processes listening to the port, thereby avoiding the bottleneck pressure problem caused by the limited processing capacity of the main working process when the port corresponds to one main working process and the main working process corresponds to multiple sub-working processes.
[0069] It is worth mentioning that a large number of models are stored in the model storage database of the present embodiment, and each work process of the listening port can load the model from the model storage data as needed, so as to cache the model located on the hard disk to each work process located in the memory, thereby improving the model detection efficiency. In addition, after each work process has cached the model, when the cached model needs to be detected later, the cached work process can be preferentially selected as the target work process to detect the model, thereby avoiding repeated secondary loading of the model and improving the detection efficiency of the model.
[0070] In the implementation manner of the present application, multiple work processes are set to listen to the port at the same time. When a model detection request is received through the port, a target work process can be determined from the multiple work processes to detect the target model, thereby achieving load balancing of the requests and avoiding the bottleneck pressure caused when the port corresponds to one main work process.
[0071] Embodiment 2
[0072] Figure 3 A flowchart of a model detection method is provided in the second embodiment of the present invention. This embodiment is based on the above embodiment. After the target working process detects the target model corresponding to the model identifier, it also includes: feeding back the model detection result to the port of the operating system.
[0073] Step S201: receiving a model detection request through a port of the operating system.
[0074] Among them, in this embodiment, the user can set the model detection request on the user side. For example, the user side can be a human-computer interaction interface, which includes options for various models. The user can input the model identifier by clicking. After receiving the target model selected by the user through the human-computer interaction interface, the terminal can generate a model detection request according to the model identifier. There is also a modification button on the human-computer interaction interface, which can modify the selected target model. In addition, there is also a model detection result display panel on the human-computer interaction interface, and the detection results obtained by detecting the target model can be displayed on the display panel. Of course, this embodiment is only an example, and does not limit the specific generation method of the model detection request.
[0075] Step S202: randomly select a receiving work process from multiple work processes listening to the port, and send a model detection request to the receiving work process.
[0076] Optionally, randomly selecting a receiving working process from a plurality of working processes of the listening port includes: obtaining all working processes of the listening port; and determining the receiving working process from all working processes using an event notification mechanism.
[0077] Optionally, before sending the model detection request to the receiving working process, the method further includes: creating a domain socket for each working process; and saving the corresponding relationship between each working process and the domain socket.
[0078] Step S203: determine the target working process by receiving the working process, and have the target working process detect the target model corresponding to the model identifier.
[0079] Optionally, determining the target working process by receiving the working process includes: calculating the model identifier by using a consistent hashing algorithm to obtain a target domain socket by receiving the working process; and using the working process corresponding to the target domain socket as the target working process.
[0080] Optionally, the target working process detects the target model corresponding to the model identifier, including: when the target domain socket does not match the domain socket of the receiving working process, forwarding the model detection request to the target working process through the receiving working process; when it is determined that the target model is cached in the target working process, directly detecting the target model through the target working process.
[0081] Optionally, the method further includes: when it is determined that the target model is not cached in the target working process, loading the target model from the model storage database; and caching the loaded target model in the target working process.
[0082] Among them, in this implementation, for each model detection request, it is hoped that the request will be routed to the working process of the cached model, so that there is no need to load the model twice, thereby improving the detection efficiency of the model. However, since multiple working processes listen to the same port together, the request cannot be distinguished in which working process it should be processed when the operating system processes it. Based on the above problem, this application can use the above-created domain socket to forward the request to the cached working process for processing.
[0083] Step S204, feeding back the model detection result to the port of the operating system.
[0084] Optionally, after the target working process detects the target model corresponding to the model identifier, it also includes: determining whether the target working process directly receives the model detection request, and if so, directly feeding back the model detection result to the port of the operating system; otherwise, forwarding the model detection result to the receiving working process, and feeding back the model detection result to the port of the operating system through the receiving working process.
[0085] Specifically, in this embodiment, the target model is detected through the target work process and the detection results are obtained, wherein the detection results can be specifically in the form of a detection report. For example, the detection report includes the detection results of each item, the detection results of the model as a whole, the reasons for detection failure, and recommended maintenance suggestions, etc. Of course, this embodiment is only an example for illustration, and does not limit the specific content of the detection report.
[0086] Among them, after obtaining the detection result, the detection result needs to be returned along the original route adopted at the sending time of the model detection request. For example, when the forwarding route is not adopted, that is, the receiving work process is the target work process, then after the target work process obtains the detection result, the model detection result is directly fed back to the port of the operating system, and sent to the user end through the port, for example, the detection result is displayed on the human-computer interaction interface through the port; when the forwarding route is adopted, that is, the receiving work process is not the target work process, the target work process needs to forward the model detection result to the receiving work process, and then the model detection result is fed back to the port of the operating system through the receiving work process, so as to send it to the user end through the port. Of course, this implementation is only an example for illustration, and does not limit the specific feedback method of the model detection result. As long as it can finally be fed back to the user end through the port, it is within the protection scope of this application and will not be repeated in this implementation.
[0087] It should be noted that, in this embodiment, when the information is fed back to the user end through the port, it can be directly displayed on the human-computer interaction interface or sent to the user's mobile terminal. In addition, when it is determined that the detection fails, an alarm prompt information will be generated to facilitate the user to repair the model in time according to the prompt information, so that when the model detection fails, the user can repair the target model in time according to the prompt information and refer to the recommended maintenance suggestions in the detection report, thereby ensuring the correct operation of the target model.
[0088] In the implementation manner of the present application, multiple work processes are set to listen to the port at the same time. When a model detection request is received through the port, a target work process can be determined from the multiple work processes to detect the target model, thereby achieving load balancing of the requests and avoiding the bottleneck pressure caused when the port corresponds to one main work process.
[0089] Embodiment 3
[0090] Figure 4 A schematic diagram of the structure of a network intrusion prevention device provided in Embodiment 3 of the present invention. Figure 4 As shown, the device includes: a model detection request receiving module 310, a model detection request sending module 320 and a model detection module 330.
[0091] The model detection request receiving module 310 is used to receive a model detection request through a port of the operating system, wherein the model detection request includes a model identifier;
[0092] A model detection request sending module 320 is used to randomly select a receiving work process from multiple work processes listening to the port, and send a model detection request to the receiving work process;
[0093] The model detection module 330 is used to determine the target working process by receiving the working process, and the target working process detects the target model corresponding to the model identifier.
[0094] Optionally, a model detection request sending module is used to obtain all working processes of the listening port;
[0095] An event notification mechanism is used to determine the receiving work process from all work processes.
[0096] Optionally, the device further includes a corresponding relationship saving module, which is used to create a domain socket for each working process;
[0097] The correspondence between each working process and the domain socket is saved.
[0098] Optionally, the model detection module includes a target work process determination unit, which is used to obtain a target domain socket by calculating the model identifier using a consistent hash algorithm by the receiving work process;
[0099] Set the worker process corresponding to the target domain socket as the target worker process.
[0100] Optionally, the model detection module includes a model detection unit, which is used to forward the model detection request to the target working process through the receiving working process when the target domain socket does not match the domain socket of the receiving working process;
[0101] When it is determined that the target model is cached in the target working process, the target model is directly detected through the target working process.
[0102] Optionally, the device further includes a model caching module, which is used to load the target model from the model storage database when it is determined that the target model is not cached in the target working process;
[0103] Cache the loaded target model in the target worker process.
[0104] Optionally, the device further includes a model detection result feedback module for determining whether the target working process directly receives the model detection request, and if so, directly feeding back the model detection result to the port of the operating system.
[0105] Otherwise, the model detection result is forwarded to the receiving working process, and the model detection result is fed back to the port of the operating system through the receiving working process.
[0106] The model detection device provided in the embodiment of the present invention can execute the model detection method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0107] Embodiment 4
[0108] Figure 5 The present invention is a block diagram of an electronic device 10 that can be used to implement an embodiment of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0109] like Figure 5As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0110] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0111] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the model detection method.
[0112] In some embodiments, the model detection method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the model detection method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the model detection method in any other appropriate manner (e.g., by means of firmware).
[0113] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0114] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0115] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0116] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0117] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0118] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0119] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0120] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A model detection method, characterized in that: include: Receiving a model detection request through a port of the operating system, wherein the model detection request includes a model identifier; Randomly select a receiving work process from a plurality of work processes listening to the port, and send the model detection request to the receiving work process; A target working process is determined through the receiving working process, and the target working process detects the target model corresponding to the model identifier.
2. The method according to claim 1, characterized in that The randomly selecting a receiving working process from a plurality of working processes that monitor the port comprises: Get all working processes that listen to the port; An event notification mechanism is used to determine the receiving work process from all the work processes.
3. The method according to claim 1, characterized in that Before sending the model detection request to the receiving working process, the method further includes: Creating a domain socket for each of the working processes; The corresponding relationship between each of the working processes and the domain socket is saved.
4. The method according to claim 3, characterized in that Determining the target working process by receiving the working process includes: The receiving work process uses a consistent hash algorithm to calculate the model identifier to obtain a target domain socket; The working process corresponding to the target domain socket is used as the target working process.
5. The method according to claim 3, characterized in that: The detecting, by the target working process, the target model corresponding to the model identifier includes: When the target domain socket does not match the domain socket of the receiving working process, forwarding the model detection request to the target working process through the receiving working process; When it is determined that the target model is cached in the target working process, the target model is directly detected through the target working process.
6. The method according to claim 5, characterized in that The method further comprises: When it is determined that the target model is not cached in the target working process, loading the target model from a model storage database; The loaded target model is cached in the target working process.
7. The method according to any one of claims 1 to 6, characterized in that: After the target working process detects the target model corresponding to the model identifier, the method further includes: Determine whether the target working process directly receives the model detection request, and if so, directly feed back the model detection result to the port of the operating system, Otherwise, the model detection result is forwarded to the receiving working process, and the model detection result is fed back to the port of the operating system through the receiving working process.
8. A model detection device, characterized in that: include: A model detection request receiving module, used for receiving a model detection request through a port of an operating system, wherein the model detection request includes a model identifier; A model detection request sending module, used for randomly selecting a receiving work process from a plurality of work processes listening to the port, and sending the model detection request to the receiving work process; The model detection module is used to determine the target working process through the receiving working process, and the target working process detects the target model corresponding to the model identifier.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method according to any one of claims 1 to 7 when executed.