CN113900825A - App time-consuming task optimization method and device based on artificial intelligence and related equipment - Google Patents

App time-consuming task optimization method and device based on artificial intelligence and related equipment Download PDF

Info

Publication number
CN113900825A
CN113900825A CN202111371482.8A CN202111371482A CN113900825A CN 113900825 A CN113900825 A CN 113900825A CN 202111371482 A CN202111371482 A CN 202111371482A CN 113900825 A CN113900825 A CN 113900825A
Authority
CN
China
Prior art keywords
time
preset
sub
app
consuming
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111371482.8A
Other languages
Chinese (zh)
Inventor
董秋平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN202111371482.8A priority Critical patent/CN113900825A/en
Publication of CN113900825A publication Critical patent/CN113900825A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5044Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering hardware capabilities
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • G06F9/526Mutual exclusion algorithms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5017Task decomposition
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5018Thread allocation

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The application relates to artificial intelligence and provides an App time-consuming task optimization method based on artificial intelligence. The method provided by the invention comprises the following steps: splitting an App time-consuming task into sub time-consuming tasks of a preset first number according to the operation attribute of the terminal equipment where the App is located, and setting the initial value of CountDownLatch as the preset first number; creating a preset first number of sub threads to execute the sub time-consuming tasks; the main thread of the App enters a waiting state, the sub-threads start to execute in parallel and the execution process is finished, the CountDownLatch value is reduced by one, and the first time consumed by the execution process is recorded; when the sub-thread execution is finished and the value of the CountDownLatch is less than or equal to zero, the main thread of the App is restored to a working state, and the waiting time of the main thread is recorded; and optimizing and updating the preset first quantity after analyzing the execution condition of the time-consuming task by using the operation attribute, the preset first quantity, the first time and the second time.

Description

App time-consuming task optimization method and device based on artificial intelligence and related equipment
Technical Field
The invention relates to the technical field of artificial intelligence, in particular to an artificial intelligence-based App time-consuming task optimization method and device and electronic equipment.
Background
At present, the operation on the time-consuming task in the App on the terminal device can only be written into the program code by a developer according to the solidification of development experience in the software development stage, so that the execution efficiency on some terminal devices is low, the subsequent modification process also needs to revise the code again to generate an installation package and then release a new version, meanwhile, the multithreading method for processing the time-consuming task in the program code can be used for thread switching, and complicated codes such as nesting, callback and monitoring exist in a Handler mode used for thread switching in the traditional mobile development technology, so that the complexity of the project code of the App is increased and the maintainability is reduced.
Disclosure of Invention
The embodiment of the invention provides an artificial intelligence-based method and device for optimizing an App time-consuming task, computer equipment and a storage medium, and aims to solve the problems that the execution efficiency of the time-consuming task in the App on terminal equipment is low and the code complexity for completing the time-consuming task is high.
An App time-consuming task optimization method based on artificial intelligence comprises the following steps:
splitting an App time-consuming task into sub time-consuming tasks of a preset first number according to the operation attribute of the terminal equipment where the App is located, and setting the initial value of CountDownLatch as the preset first number;
creating the preset first number of sub-threads, and distributing the sub-time consuming tasks to the sub-threads in one-to-one correspondence;
the main thread of the App enters a waiting state, all the sub-threads start to execute the sub-time consuming tasks in parallel, and the value of CountDownLatch is reduced by one when the sub-thread execution process is finished, and the first time consumed by the sub-thread execution process is recorded;
when all the sub-threads are executed and the value of the CountDownLatch is less than or equal to zero, the main thread of the App is recovered to be in a working state from a waiting state, and the waiting time of the main thread of the App is recorded;
analyzing the execution condition of the time-consuming task by using the operation attribute, the preset first quantity, the first time and the second time, and optimizing and updating the preset first quantity according to the execution condition and a preset first rule.
App time-consuming task optimization device based on artificial intelligence includes:
the task splitting module is used for splitting the App time-consuming task into sub time-consuming tasks of a preset first number according to the operation attribute of the terminal equipment where the App is located, and the initial value of the CountDownLatch is set as the preset first number;
the task allocation module is used for creating the preset first number of sub-threads and allocating the sub-time consuming tasks to the sub-threads in one-to-one correspondence;
the task execution module is used for enabling the main thread of the App to enter a waiting state, enabling all the sub-threads to start to execute the sub-time consuming tasks in parallel, reducing the CountDownLatch value by one when the sub-thread execution process is finished, and recording the first time consumed by the sub-thread execution process;
the thread switching module is used for recovering the main thread of the App from a waiting state to a working state and recording the second waiting time of the main thread of the App when all the sub-threads are executed and the value of the CountDownLatch is less than or equal to zero;
and the analysis optimization module is used for analyzing the execution condition of the time-consuming task by using the operation attribute, the preset first quantity, the first time and the second time, and optimizing and updating the preset first quantity according to the execution condition and a preset first rule.
A computer device comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the processor executes the computer program to realize the steps of the artificial intelligence based App time-consuming task optimization method.
A computer readable storage medium storing a computer program which, when executed by a processor, implements the steps of the above artificial intelligence based App time-consuming task optimization method.
The App time-consuming task optimization method and device based on artificial intelligence, the computer equipment and the storage medium, splitting an App time-consuming task into a preset first number of sub time-consuming tasks according to hardware performance parameters, an operating state and the type of the time-consuming task of a terminal device where the App is located, creating sub threads with corresponding quantity to correspondingly execute the sub time-consuming tasks one by one, recording the completion time of the time-consuming tasks, optimizing the preset first quantity, scheduling the main threads and the sub threads of the App by using CountDownLatch, improving the execution efficiency of the App time-consuming tasks and dynamically optimizing the execution efficiency of the App time-consuming tasks in the App on the terminal equipment, and the method of using CountDownLatch to manage the switching of the main thread and the sub-thread of the App further reduces the code complexity of the code part of the time-consuming task and improves the code maintainability.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive labor.
FIG. 1 is a schematic diagram of an application environment of an artificial intelligence-based App time-consuming task optimization method according to an embodiment of the present invention;
FIG. 2 is a flow chart of a method for artificial intelligence based optimization of App time consuming tasks in accordance with an embodiment of the present invention;
FIG. 3 is a schematic structural diagram of an artificial intelligence based App time-consuming task optimization device according to an embodiment of the present invention;
fig. 4 is a schematic diagram of an electronic device according to an embodiment of the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The time-consuming task optimization method based on artificial intelligence App can be applied to an application environment 100 shown in FIG. 1, wherein a terminal device 102 communicates with a server 101 through a network 103; the terminal device 102 may be, but is not limited to, various smart phones, tablet computers, and portable wearable devices; the server 101 may be an independent server, or may be a cloud server that provides basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a Network service, cloud communication, a middleware service, a domain name service, a security service, a Content Delivery Network (CDN), a big data and artificial intelligence platform, and the like; it should be noted that the terminal device 102 may also perform without the network 103 communicating with the server 101.
It is understood that the number of servers, networks and terminal devices in fig. 1 is merely illustrative and any number of extensions may be made according to actual needs.
In an embodiment, as shown in fig. 2, an App time-consuming task optimization method based on artificial intelligence is provided, which is described by taking the method as an example applied to the terminal device 102 in fig. 1, and includes the following steps S201 to S205:
s201, splitting the App time-consuming task into sub time-consuming tasks of a preset first number according to the operation attribute of the terminal equipment where the App is located, and setting the initial value of CountDownLatch as the preset first number.
Further, the operation attribute includes a hardware performance parameter of the terminal device, an operation state of the terminal device, and a type of the time-consuming task.
The hardware performance parameters of the terminal device include, but are not limited to: CPU model, CPU frequency, CPU digit, CPU support instruction set, CPU core number, GPU model, GPU video memory capacity, screen density, screen resolution, screen size, system version, system kernel version, system virtual machine type, support network type, etc.; the operating state data includes, but is not limited to: the current network type, the current battery power, the current CPU utilization rate, the current memory utilization rate, the current storage residual space, the current GPS positioning position and the like; the time consuming task types include, but are not limited to: the method comprises the steps of downloading a network file, reading and writing a large file, performing time-consuming operation on a database, rendering an audio/video file, calculating a large data volume, calculating a neural network related operation task and the like. The hardware performance parameters greatly influence the efficiency of the terminal equipment for executing the time-consuming task, namely the efficiency of the terminal equipment with high-performance parameter hardware for executing the time-consuming task is higher than that of the terminal equipment with general performance parameter hardware; for the same terminal device, different operating states may also affect the execution efficiency of the time-consuming task, for example, the time consumption generated by downloading the same file in different states under different network conditions is necessarily different; the types of the time-consuming tasks are different, and key hardware resources required to be used when the time-consuming tasks are executed are different, for example, file operation is I/O intensive operation, which consumes less CPU resources but consumes more memory resources, and the calculation of the circumference ratio is calculation intensive operation, which consumes more CPU resources but less memory resources.
Optionally, after the App is installed in the terminal device, the method further includes: and acquiring the hardware performance parameters of the terminal equipment, judging the hardware performance of the terminal equipment, and modifying the preset first quantity according to the preset first rule. In a software development stage of the App, a developer can only set the preset first quantity based on hardware performance parameters of mainstream terminal equipment in the current market, but after the App is installed on different terminal equipment used by different users, the preset first quantity needs to be modified according to the hardware performance parameters of the terminal equipment and the preset first rule because the hardware performance parameters of the different terminal equipment are different; in the preset first rule, the terminal device having high-performance parameter hardware is set to be the larger preset first number, for example, 8, and the terminal device having general or lower-performance parameter hardware is set to be the smaller preset first number, for example, 4, and meanwhile, not only the hardware performance parameters of the mainstream terminal device in the current market but also the terminal device having higher hardware performance parameters in the future market need to be considered.
The App time-consuming task is divided into the sub time-consuming tasks of the preset first number, the service types of the time-consuming tasks need to be considered comprehensively, for example, when a network requests to download a large file, the large file is divided into the small file segments of the preset first number, the small file segments are downloaded respectively and then merged into the large file, and for the time-consuming tasks needing to copy the picture files in batch, all the picture files needing to be copied are divided into a plurality of sub time-consuming tasks for copying a part of the picture files, and then merging operation is not needed.
The countdown latch is a tool assistant class for implementing thread synchronization, and different implementation forms exist in different operating systems of the terminal device, in this embodiment, an implementation manner in an android system is taken as an example for explanation, the countdown latch tool assistant class may be used to block at least one thread from running into a waiting state until other threads added to the countdown latch are executed completely, and then the execution continues, and the threads added to the countdown latch are not interrupted by other threads during the running process to ensure the execution safety; the method comprises the steps that a counting lock is arranged inside the CountDownLatch and used for metering the number of threads added into the CountDownLatch, the initial value of the counting lock is equal to the value of the preset first number, the counting lock is correspondingly reduced by one after the running of each thread added into the CountDownLatch is finished, and the thread in the waiting state is awakened to enter the running state to be continuously executed until the counting lock is equal to or less than zero.
S202, creating the preset first number of sub-threads, and distributing the sub-time consuming tasks to the sub-threads in one-to-one correspondence.
After the App time consuming task is divided into the sub time consuming tasks of the preset first number, each time consuming sub task needs to be executed by one sub thread, sub threads with the same number as the sub time consuming tasks need to be created, and the sub time consuming tasks are distributed to the sub threads corresponding to one for execution.
Further, the creating the preset first number of sub-threads and allocating the sub-time consuming tasks to the one-to-one corresponding sub-threads includes:
when all the child threads are successfully created, distributing the child time-consuming tasks to the child threads corresponding to one;
when at least one child thread is failed to be created and at least one child thread is successfully created, splitting the time-consuming tasks into a second number of sub time-consuming tasks according to a second number of the child threads which are successfully created, and distributing the split second number of sub time-consuming tasks to the child threads which correspond to one another one by one;
and when the sub-thread creation fails, stopping the execution of the time-consuming task, recovering the main thread of the App from a waiting state to a working state, and recording and storing an abnormal record of the sub-thread creation failure, the current running state of the terminal equipment and the type of the time-consuming task.
S203, the main thread of the App enters a waiting state, all the sub-threads start to execute the sub-time consuming tasks in parallel, and when the sub-thread execution process is finished, the CountDownLatch value is reduced by one, and the first time consumed by the sub-thread execution process is recorded.
Optionally, after the creating of the preset first number of child threads, the method further includes: when the sub-thread fails to execute the sub-thread task, retry operation not greater than preset retry times is carried out, and when the preset retry times are exceeded and the sub-thread still fails, the sub-thread execution process is finished; when the current retry number is smaller than the preset retry number, the child thread restarts to attempt to execute the child time-consuming task; and when the retry times of restarting the execution of the sub time-consuming task by the child thread due to the execution failure are equal to or more than the preset retry times, the child thread finishes the operation and the sub time-consuming task fails.
Whether the sub-thread executes the sub-time consuming task successfully or fails, after the sub-thread execution process is finished, the value of the CountDownLatch is correspondingly reduced by one; meanwhile, the sub-thread with an idle state is prevented from occupying the system resources of the terminal equipment, and developers can define rules to destroy and recover the system resources of the sub-thread which finishes the execution process or continue to reserve the resources for subsequent reuse; however, the sub-thread execution success or failure does not necessarily affect the completion of the time-consuming task, for example, in the case of network downloading of a large file, if there is a failure in downloading a part of the large file by at least one sub-thread, a file block is missing, so that the large file cannot be synthesized at last, and further the time-consuming execution fails, and for example, in the case of performing a large-order picture copying task, if there is a failure in executing the copying task by at least one sub-thread, so that a part of a picture is not copied, the large-order picture copying task may still be considered to be partially successful, and the picture that has not been copied successfully may be placed into the next time-consuming task to be executed.
Further, after the creating of the preset first number of child threads, the method further includes: creating a thread pool to manage the sub-threads, adding the sub-threads into the thread pool, and waiting for the next sub-time consuming task to be allocated after the execution process of the sub-threads is finished; in the App's operational scenario, there are cases where the time-consuming task needs to be executed at a higher frequency for a certain period of time, in order to avoid that frequently creating and destroying new sub-threads in the system of the terminal device affects the operation of the terminal device, the child thread that has been created may be put into a newly created thread pool for management, a management rule of the thread pool is set, after the sub time-consuming task is executed, the thread pool decides to destroy or reserve the sub thread according to the management rule, so that the time-consuming task is divided into the sub time-consuming tasks when the next time-consuming task arrives, the sub time-consuming tasks are directly distributed to the idle sub threads in the thread pool, so that the reduction of system performance caused by frequent creation of the sub threads is avoided, and the execution efficiency of the sub time-consuming tasks is improved; for example, when a user of the App starts to download a large number of files in a batch manner using a network, a single sub-thread needs to be frequently used to execute a download task, and it is more reasonable to manage the sub-thread using a thread pool.
And S204, when all the sub-threads are executed and the value of the CountDownLatch is less than or equal to zero, the main thread of the App is recovered to be in a working state from a waiting state, and the second waiting time of the main thread of the App is recorded.
One of the characteristics of the countdown latch class is that when all the sub-threads are operated and the value of the countdown latch class is equal to or less than zero, the thread which previously enters a waiting state is waken up to enter an operating state for continuous execution, that is, when the value of the countdown latch class is equal to or less than zero, the main thread of the App is waken up to enter the operating state for executing other tasks, for example, when the App starts to execute the time-consuming task of downloading a large file, the main thread friendly shows an interface which allows a user to wait durably on a UI interface of the App and enters the waiting state, and after the main thread is waken up to enter the operating state, the main thread shows relevant information of successful downloading of the large file to a user of the App in a friendly interactive mode;
and recording the waiting second time of the main thread of the App, namely counting the execution time of the time-consuming task, and analyzing the reasonableness of the preset first quantity set value after the time-consuming task is executed, wherein the function of the time-consuming task is not repeated herein.
S205, analyzing the execution condition of the time-consuming task by using the operation attribute, the preset first quantity, the first time and the second time, and optimizing and updating the preset first quantity according to the execution condition and a preset first rule.
The App time-consuming task is divided into a preset first number of sub time-consuming tasks, then the preset first number of sub threads are created and executed in parallel, the preset first number is increased, the App time-consuming task is divided into a greater number of sub time-consuming tasks to be executed in parallel, and then the execution time of the App time-consuming task is shortened; however, increasing the preset first number also increases the number of created sub-threads, and creating more sub-threads increases more system resource overhead when the operating system of the terminal device manages the sub-threads, which in turn causes a decrease in the efficiency of executing the sub-time-consuming task by a single sub-thread, and further causes no decrease in the execution time of the App time-consuming task; at this time, the preset first quantity needs to be optimized after analysis is performed according to the operation attribute, the preset first quantity, the first time, the second time and the preset first rule when the App time-consuming task is executed each time, and meanwhile, the preset first rule includes a rule of how to determine the preset first quantity of the terminal device with different hardware performance parameters under the condition of different operation attributes.
Further, after the optimizing and updating the preset first number according to the execution condition and a preset first rule, the method further includes: and sending the operation attribute, the preset first quantity, the preset first rule, the first time and the second time of the terminal equipment to a cloud management platform for management and analysis. After acquiring a large number of hardware performance parameters, the running state, detailed information of time-consuming tasks, the preset first quantity, the first time and the second time data samples of the terminal device, the cloud management platform can conveniently and visually display by using a graphical tool and a method, can analyze information such as the performance improvement condition of the terminal device in the current market, the network condition of the area where the user is located, and the like, and is convenient for further optimizing the first rule.
Further, after the operation attribute, the preset first quantity, the preset first rule, the first time and the second time of the terminal device are sent to a cloud management platform for management and analysis, the method further includes: the cloud management platform receives the operation attribute, the preset first quantity, the preset first rule, the first time and the second time of the terminal equipment, dynamically generates the preset first quantity again, returns the preset first quantity to the terminal equipment, and generates the optimal preset first quantity. Namely, the terminal device can instantly request the cloud management platform through an open interface of the cloud management platform and obtain the optimal preset first quantity of the time-consuming tasks executed in the current running state of the terminal device.
Further, after the operation attribute, the preset first quantity, the preset first rule, the first time and the second time of the terminal device are sent to a cloud management platform for management and analysis, the method further includes: the cloud management platform receives the operation attribute, the preset first quantity, the preset first rule, the first time and the second time of the terminal equipment, optimizes and adjusts the preset first rule and then returns the optimized and adjusted preset first rule to the terminal equipment, and the cloud management platform generates the optimal preset first rule. Namely, the terminal device can instantly request the cloud management platform through an open interface of the cloud management platform and acquire an optimal preset first rule suitable for the App to execute a time-consuming task on the terminal device.
Further, after the operation attribute, the preset first quantity, the preset first rule, the first time and the second time of the terminal device are sent to a cloud management platform for management and analysis, the method further includes: the method comprises the steps that the App runs an automatic packing script to access the cloud management platform after the development is completed, the optimal preset first quantity is obtained and dynamically covers the preset first quantity in App codes, the optimal preset first rule is obtained and dynamically covers the preset first rule in the App codes, and finally an installation package of the App is generated. That is, after the App completes a development task of one version each time, the preset first quantity and the preset first rule in the generated installation package are the optimal preset first quantity and the optimal preset first rule which are analyzed by the cloud management platform according to the received data.
Further, optimizing the preset first rule in the terminal equipment by using a machine learning method in artificial intelligence, taking the first time and the second time generated by each execution of the App time-consuming task, the type of the time-consuming task and the operation attribute of the terminal equipment as machine learning algorithm input data, building a model, training, evaluating the training result, determining whether parameters need to be further adjusted, and finally outputting the optimized preset first rule; the preset first rule specifies the value taking condition of the preset first quantity under all the running states of the terminal equipment; the basis of optimizing the preset first rule by the machine learning method is based on the operation attribute of the terminal device, that is, the preset first rule which is finally output and optimized is the preset first rule for the terminal device, and the preset first rules which are optimized by the machine learning method on other terminal devices are not necessarily the same.
Further, optimizing the optimal preset first rule by using a machine learning method in artificial intelligence on the cloud management platform, taking the received first time and the second time sent by all the terminal devices, the type of the time-consuming task and the operation attribute of the terminal devices as machine learning algorithm input data, building a model, training, evaluating the training result, determining whether parameters need to be further adjusted, and finally outputting the optimized optimal preset first rule; the machine learning method is characterized in that the optimal preset first rule is optimized by using all data sent by the terminal equipment accessed to the cloud management platform, namely the optimal preset first rule which is finally output and optimized is the rule with the best App time-consuming task support for the terminal equipment which is on the market and the terminal equipment which is not on the market.
The time-consuming task optimization method for the App based on artificial intelligence provided by this embodiment obtains the hardware performance parameters of the terminal device where the App is located in advance, splitting the time-consuming task into a preset first number of unfixed time-consuming subtasks according to the type of the time-consuming task, and creates a corresponding number of sub-threads to complete the time consuming task, records the time consumed for the execution process of the time consuming task, and according to the time consumed for completing the time consuming task for a plurality of times, the preset first quantity is continuously optimized, the time consumed for completing the time-consuming task is further shortened, the execution efficiency of the App time-consuming task is improved, and meanwhile, the state of the main thread of the App is managed in a CountDownLatch mode when the time-consuming task is carried out, so that the complexity of the code of the time-consuming task is reduced, and the maintainability of the code is improved.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
In an embodiment, an artificial intelligence based App time-consuming task optimization device 30 is provided, and the artificial intelligence based App time-consuming task optimization device 30 corresponds to the artificial intelligence based App time-consuming task optimization method in the above embodiment one to one. As shown in fig. 3, the apparatus for App time-consuming task optimization based on artificial intelligence includes a task splitting module 301, a task allocating module 302, a task executing module 303, a thread switching module 304, and an analysis optimizing module 305. The functional modules are explained in detail as follows:
the task splitting module 301 is configured to split the App time consuming task into a preset first number of sub time consuming tasks according to the running attribute of the terminal device where the App is located, and an initial value of countdown latch is set to the preset first number;
the task allocation module 302 is configured to create the preset first number of sub-threads and allocate the sub-time consuming tasks to the sub-threads corresponding to one another;
the task execution module 303 is used for enabling the main thread of the App to enter a waiting state, enabling all the sub-threads to start to execute the sub-time consuming tasks in parallel, and recording the first time consumed by the sub-thread execution process by reducing the CountDownLatch value by one when the sub-thread execution process is finished;
the thread switching module 304 is configured to, when the execution of all the sub-threads is finished and the value of CountDownLatch is less than or equal to zero, restore the main thread of the App from the waiting state to the working state, and record a second time for the main thread of the App to wait;
an analysis optimization module 305, configured to analyze an execution condition of the time-consuming task by using the operation attribute, the preset first quantity, the first time, and the second time, and optimize and update the preset first quantity according to the execution condition and a preset first rule.
Wherein the task splitting module 301 is further configured to:
and acquiring the hardware performance parameters of the terminal equipment, judging the hardware performance of the terminal equipment, and modifying the preset first quantity according to the preset first rule.
Wherein, the task allocation module 302 further includes the following sub-modules:
the thread task allocation submodule is used for allocating the sub time-consuming tasks to the sub threads in one-to-one correspondence when all the sub threads are successfully created;
the thread task reconfiguration sub-module is used for splitting the time-consuming tasks into the second number of sub time-consuming tasks again according to the second number of the sub threads which are successfully created when at least one sub thread is failed to be created and at least one sub thread is successfully created, and distributing the split second number of sub time-consuming tasks to the sub threads which are in one-to-one correspondence;
and the task completion recording submodule is used for stopping the execution of the time-consuming task when the sub-thread is failed to be created, recovering the main thread of the App from a waiting state to a working state, and recording and storing the abnormal record of the sub-thread creation failure, the current running state of the terminal equipment and the type of the time-consuming task.
The task execution module 303 further includes the following sub-modules:
the task retry submodule is used for carrying out retry operation which is not more than the preset retry times when the sub-thread fails to execute the sub-thread task, and finishing the sub-thread execution process when the preset retry times are exceeded and the sub-thread still fails;
and the thread pool management submodule is used for creating a thread pool to manage the sub-threads, adding the sub-threads into the thread pool, and waiting for the sub-time-consuming task to be allocated next time after the execution process of the sub-threads is finished.
Wherein, the analysis optimization module 305 further comprises the following sub-modules:
the cloud management and analysis submodule is used for sending the operation attribute, the preset first quantity, the preset first rule, the first time and the second time of the terminal equipment to a cloud management platform for management and analysis;
the optimal preset first quantity management submodule is used for the cloud management platform to receive the operation attribute, the preset first quantity, the preset first rule, the first time and the second time of the terminal equipment, dynamically generate the preset first quantity again and return the preset first quantity to the terminal equipment, and generate the optimal preset first quantity on the cloud management platform;
the optimal preset first rule management submodule is used for receiving the operation attribute, the preset first quantity, the preset first rule, the first time and the second time of the terminal equipment by the cloud management platform, optimizing and adjusting the preset first rule, returning the optimized and adjusted preset first rule to the terminal equipment, and generating an optimal preset first rule on the cloud management platform;
and the automatic packing management submodule is used for running an automatic packing script to access the cloud management platform after the App is developed, acquiring the optimal preset first quantity to dynamically cover the preset first quantity in the App codes, acquiring the optimal preset first rule to dynamically cover the preset first rule in the App codes, and finally generating an installation package of the App.
Wherein the meaning of "first" and "second" in the above modules/units is only to distinguish different modules/units, and is not used to define which module/unit has higher priority or other defining meaning. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or modules is not necessarily limited to those steps or modules explicitly listed, but may include other steps or modules not explicitly listed or inherent to such process, method, article, or apparatus, and such that a division of modules presented in this application is merely a logical division and may be implemented in a practical application in a further manner.
For specific limitations of the artificial intelligence based App time-consuming task optimization device, reference may be made to the above limitations of the artificial intelligence based App time-consuming task optimization method, and details are not repeated here. The modules in the artificial intelligence based App time-consuming task optimization device can be wholly or partially implemented by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, an electronic device is provided, the internal structure of which may be as shown in FIG. 4. The electronic device includes a processor, a memory connected by a system bus. Wherein the processor of the electronic device is configured to provide computing and control capabilities. The memory of the electronic equipment comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communicating with an external server through a network connection. The computer program is executed by a processor to implement the steps of the artificial intelligence based App time-consuming task optimization method in the above embodiments, such as the steps S201 to S205 shown in fig. 2 and other extensions of the method and related steps. Alternatively, the processor, when executing the computer program, implements the functions of the modules/units of the artificial intelligence based App time-consuming task optimization apparatus in the above embodiments, such as the functions of the modules 301 to 305 shown in fig. 3. To avoid repetition, further description is omitted here.
The Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like that is the control center for the electronic device and that connects the various parts of the overall electronic device using various interfaces and wires.
The memory may be used to store the computer programs and/or modules, and the processor may implement various functions of the electronic device by running or executing the computer programs and/or modules stored in the memory and calling data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, video data, etc.) created according to the use of the cellular phone, etc.
The memory may be integrated in the processor or may be provided separately from the processor.
In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, which when executed by a processor implements the steps of the artificial intelligence based App time-consuming task optimization method in the above embodiments, such as the steps S201 to S205 shown in fig. 2 and extensions of other extensions and related steps of the method. Alternatively, the computer program, when executed by the processor, implements the functions of the modules/units of the artificial intelligence based App time-consuming task optimization apparatus in the above embodiments, such as the functions of modules 301 to 305 shown in fig. 3. To avoid repetition, further description is omitted here.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, or other media used in the embodiments provided herein can include non-volatile and/or volatile memory. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (12)

1. An artificial intelligence-based App time-consuming task optimization method is characterized by comprising the following steps:
splitting an App time-consuming task into sub time-consuming tasks of a preset first number according to the operation attribute of the terminal equipment where the App is located, and setting the initial value of CountDownLatch as the preset first number;
creating the preset first number of sub-threads, and distributing the sub-time consuming tasks to the sub-threads in one-to-one correspondence;
the main thread of the App enters a waiting state, all the sub-threads start to execute the sub-time consuming tasks in parallel, and the value of CountDownLatch is reduced by one when the sub-thread execution process is finished, and the first time consumed by the sub-thread execution process is recorded;
when all the sub-threads are executed and the value of the CountDownLatch is less than or equal to zero, the main thread of the App is recovered to be in a working state from a waiting state, and the waiting time of the main thread of the App is recorded;
analyzing the execution condition of the time-consuming task by using the operation attribute, the preset first quantity, the first time and the second time, and optimizing and updating the preset first quantity according to the execution condition and a preset first rule.
2. The artificial intelligence based App time-consuming task optimization method of claim 1, wherein the running attributes comprise hardware performance parameters of the terminal device, and after the App is installed on the terminal device, the method further comprises:
and acquiring the hardware performance parameters of the terminal equipment, judging the hardware performance of the terminal equipment, and modifying the preset first quantity according to the preset first rule.
3. The artificial intelligence-based App time-consuming task optimization method according to claim 2, wherein the operation attributes include an operation state of the terminal device and a type of the time-consuming task, and the creating the preset first number of sub-threads and allocating the sub-time-consuming tasks to the sub-threads in one-to-one correspondence comprises:
when all the child threads are successfully created, distributing the child time-consuming tasks to the child threads corresponding to one;
when at least one child thread is failed to be created and at least one child thread is successfully created, splitting the time-consuming tasks into a second number of sub time-consuming tasks according to a second number of the child threads which are successfully created, and distributing the split second number of sub time-consuming tasks to the child threads which correspond to one another one by one;
and when the sub-thread creation fails, stopping the execution of the time-consuming task, recovering the main thread of the App from a waiting state to a working state, and recording and storing an abnormal record of the sub-thread creation failure, the current running state of the terminal equipment and the type of the time-consuming task.
4. The artificial intelligence based App time-consuming task optimization method of claim 1, wherein after the creating a preset first number of sub-threads, the method further comprises:
and when the sub-thread fails to execute the sub-thread task, carrying out retry operation with the retry time not more than the preset retry time, and when the preset retry time is exceeded and the sub-thread still fails, finishing the sub-thread execution process.
5. The artificial intelligence based App time-consuming task optimization method of claim 1, wherein after the creating a preset first number of sub-threads, the method further comprises:
and creating a thread pool to manage the sub-threads, adding the sub-threads into the thread pool, and waiting for the next sub-time-consuming task to be allocated after the execution process of the sub-threads is finished.
6. The artificial intelligence based App time-consuming task optimization method of claim 3, wherein after the optimizing and updating the preset first number according to the execution situation and a preset first rule, the method further comprises:
and sending the operation attribute, the preset first quantity, the preset first rule, the first time and the second time of the terminal equipment to a cloud management platform for management and analysis.
7. The artificial intelligence based App time-consuming task optimization method of claim 6, wherein after sending the operating attributes, the preset first number, the preset first rule, the first time and the second time of the terminal device to a cloud management platform for management and analysis, the method further comprises:
the cloud management platform receives the operation attribute, the preset first quantity, the preset first rule, the first time and the second time of the terminal equipment, dynamically generates the preset first quantity again, returns the preset first quantity to the terminal equipment, and generates the optimal preset first quantity.
8. The artificial intelligence based App time-consuming task optimization method of claim 7, wherein after sending the operating attributes, the preset first number, the preset first rule, the first time and the second time of the terminal device to a cloud management platform for management and analysis, the method further comprises:
the cloud management platform receives the operation attribute, the preset first quantity, the preset first rule, the first time and the second time of the terminal equipment, optimizes and adjusts the preset first rule and then returns the optimized and adjusted preset first rule to the terminal equipment, and the cloud management platform generates the optimal preset first rule.
9. The artificial intelligence based App time-consuming task optimization method of claim 8, wherein after sending the operating attributes, the preset first number, the preset first rule, the first time and the second time of the terminal device to a cloud management platform for management and analysis, the method further comprises:
the method comprises the steps that the App runs an automatic packing script to access the cloud management platform after the development is completed, the optimal preset first quantity is obtained and dynamically covers the preset first quantity in App codes, the optimal preset first rule is obtained and dynamically covers the preset first rule in the App codes, and finally an installation package of the App is generated.
10. App time-consuming task optimization device based on artificial intelligence, which is characterized by comprising:
the task splitting module is used for splitting the App time-consuming task into sub time-consuming tasks of a preset first number according to the operation attribute of the terminal equipment where the App is located, and the initial value of the CountDownLatch is set as the preset first number;
the task allocation module is used for creating the preset first number of sub-threads and allocating the sub-time consuming tasks to the sub-threads in one-to-one correspondence;
the task execution module is used for enabling the main thread of the App to enter a waiting state, enabling all the sub-threads to start to execute the sub-time consuming tasks in parallel, reducing the CountDownLatch value by one when the sub-thread execution process is finished, and recording the first time consumed by the sub-thread execution process;
the thread switching module is used for recovering the main thread of the App from a waiting state to a working state and recording the second waiting time of the main thread of the App when all the sub-threads are executed and the value of the CountDownLatch is less than or equal to zero;
and the analysis optimization module is used for analyzing the execution condition of the time-consuming task by using the operation attribute, the preset first quantity, the first time and the second time, and optimizing and updating the preset first quantity according to the execution condition and a preset first rule.
11. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor when executing the computer program implements the steps of the artificial intelligence based App time-consuming task optimization method of any one of claims 1 to 9.
12. A computer-readable storage medium storing a computer program which, when executed by a processor, performs the steps of the artificial intelligence based App time-consuming task optimization method of any one of claims 1 to 9.
CN202111371482.8A 2021-11-18 2021-11-18 App time-consuming task optimization method and device based on artificial intelligence and related equipment Pending CN113900825A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111371482.8A CN113900825A (en) 2021-11-18 2021-11-18 App time-consuming task optimization method and device based on artificial intelligence and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111371482.8A CN113900825A (en) 2021-11-18 2021-11-18 App time-consuming task optimization method and device based on artificial intelligence and related equipment

Publications (1)

Publication Number Publication Date
CN113900825A true CN113900825A (en) 2022-01-07

Family

ID=79194719

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111371482.8A Pending CN113900825A (en) 2021-11-18 2021-11-18 App time-consuming task optimization method and device based on artificial intelligence and related equipment

Country Status (1)

Country Link
CN (1) CN113900825A (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109117203A (en) * 2018-07-13 2019-01-01 广州小鹏汽车科技有限公司 A kind of Android APP starting velocity optimization method and system
CN111488255A (en) * 2020-03-27 2020-08-04 深圳壹账通智能科技有限公司 Multithreading concurrent monitoring method, device, equipment and storage medium
US20210201317A1 (en) * 2019-12-31 2021-07-01 Paypal, Inc. Rule engine optimization via parallel execution

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109117203A (en) * 2018-07-13 2019-01-01 广州小鹏汽车科技有限公司 A kind of Android APP starting velocity optimization method and system
US20210201317A1 (en) * 2019-12-31 2021-07-01 Paypal, Inc. Rule engine optimization via parallel execution
CN111488255A (en) * 2020-03-27 2020-08-04 深圳壹账通智能科技有限公司 Multithreading concurrent monitoring method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
US11853820B2 (en) Cross-process communication method, apparatus, and device
CN110673853B (en) Compiling method, device and system
CN113377348B (en) Task adjusting method applied to task engine, related device and storage medium
US20230205561A1 (en) Managing containers across multiple operating systems
CN110362301B (en) Processing method for terminal application behavior reflection
CN110162344B (en) Isolation current limiting method and device, computer equipment and readable storage medium
CN113448728B (en) Cloud resource scheduling method, device, equipment and storage medium
CN113190282A (en) Android operating environment construction method and device
US10467027B1 (en) Dynamic script loading resource files
CN113986402A (en) Function calling method and device, electronic equipment and storage medium
CN112235132A (en) Method, device, medium and server for dynamically configuring service
CN113722114A (en) Data service processing method and device, computing equipment and storage medium
CN110286996A (en) Container instance IP switching method, device, computer equipment and storage medium
CN106293790B (en) application program upgrading method and device based on Firefox operating system
CN114006815B (en) Automatic deployment method and device for cloud platform nodes, nodes and storage medium
CN106775608B (en) Method and device for realizing independent system process
CN110347448B (en) Method for constructing runtime model of terminal application behavior
CN112214325A (en) FPGA task dynamic arrangement method, device, chip and storage medium
WO2023245940A1 (en) Processing method and apparatus for data in cache
CN113900825A (en) App time-consuming task optimization method and device based on artificial intelligence and related equipment
CN115904387A (en) Program module compiling method, computer device, and program product
CN115374083A (en) Data source switching method and device, electronic equipment and storage medium
CN115480897A (en) Task processing method, device, equipment, storage medium and program product
CN113448585A (en) Optimization method and device for thread pool, electronic equipment and storage medium
CN113708971A (en) Openstack cloud platform deployment method and related device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination