CN108446199A - A kind of detection method and device using interim card - Google Patents

A kind of detection method and device using interim card Download PDF

Info

Publication number
CN108446199A
CN108446199A CN201710083350.2A CN201710083350A CN108446199A CN 108446199 A CN108446199 A CN 108446199A CN 201710083350 A CN201710083350 A CN 201710083350A CN 108446199 A CN108446199 A CN 108446199A
Authority
CN
China
Prior art keywords
period
interim card
event loop
loop system
moment
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
CN201710083350.2A
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.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201710083350.2A priority Critical patent/CN108446199A/en
Publication of CN108446199A publication Critical patent/CN108446199A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3051Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computing Systems (AREA)
  • Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the present application discloses a kind of detection method and device using interim card.The method includes:The event loop system for obtaining subject thread executes the first moment of deliberate action in single cycle, and the deliberate action is to execute action in the event loop system circulation implementation procedure;Interim card period of the event loop system in the single cycle is calculated according to first moment;If the interim card period is more than the first predetermined threshold value, it is determined that the subject thread is in interim card state.Using the application method or apparatus embodiment, the more accurate interim card period can be calculated, the period for executing task in event loop system sleep procedure will not be ignored, because of the application interim card without occurring between in missing inspection sleep procedure.

Description

A kind of detection method and device using interim card
Technical field
This application involves apply interim card technical field, more particularly to a kind of detection method and device using interim card.
Background technology
Using interim card generally refer to user application upper operation when occur it is more slow with application interface interaction response Phenomenon, such as browsing pages, video playing have some setbacks, and even user interface occur blocks phenomena such as motionless when serious.In order to It is enough to eliminate using the phenomenon caused by interim card, it is provided with system monitoring module in some operating systems, such as linux system " house dog " (watchdog) mechanism, when the interim card time of application being more than the predetermined time, system monitoring module can generally be forced The process for disconnecting the application causes the sudden strain of a muscle of application to move back.At this point, for users, to the application even body of the equipment It tests very bad.
Using interim card producing cause there are many, for example, main thread deadlock, that is, main thread obtain lock a, need lock b, At this moment another thread has got lock b, needs to lock a, the interim card of main thread is caused in recycling waiting process.For another example, The frequent input/output operations of main thread, main thread execute a large amount of interface drafting or calculating task, main thread send network Request is abnormal the events such as situation all when transferring data to server can cause the interim card of application.
It is difficult often localized reason, therefore, the prior art even to be moved back using sudden strain of a muscle using interim card caused by the above problem In there is an urgent need for it is a kind of it is easy, quickly detection using interim card method.
Invention content
The embodiment of the present application is designed to provide a kind of detection method and device using interim card, can improve application card Immediately the counting accuracy between.
What a kind of detection method and device using interim card provided by the embodiments of the present application were specifically realized in:
A kind of detection method using interim card, the method includes:
The event loop system for obtaining subject thread executes the first moment of deliberate action in single cycle, described default Action is to execute action in the event loop system circulation implementation procedure;
Interim card period of the event loop system in the single cycle is calculated according to first moment;
If the interim card period is more than the first predetermined threshold value, it is determined that the subject thread is in interim card state.
A kind of detection device using interim card, described device include:
First moment acquiring unit, the event loop system for obtaining subject thread execute default dynamic in single cycle The first moment made, the deliberate action are to execute action in the event loop system circulation implementation procedure;
Interim card period computing unit is followed for calculating the event loop system according to first moment in the single The interim card period in ring;
Interim card determination unit, if being more than the first predetermined threshold value for the interim card period, it is determined that at the subject thread In interim card state.
Detection method and device provided by the present application using interim card can exist according to the event loop system of subject thread In single cycle at the time of execution deliberate action, into the initial time of dormant state, the event loop system is calculated The interim card period in the single cycle.The application method can solve two technical problems in the prior art, and reason is such as Under:It is described execute deliberate action at the time of as the event loop system single cycle initial time, then next It can be executed from entire cycle as the end time of last cyclic process at the time of executing the deliberate action in secondary cycle From the point of view of process, the period of the initial time to end time includes the period that entire cycle executes.Relative to existing skill Art method, the interim card period that the present embodiment method is calculated is more accurate, will not ignore suspend mode between stage 4 to the stage 5 The period that task is executed in journey, because of the application interim card without occurring between stage described in missing inspection 4 to the stage 5.
Description of the drawings
In order to illustrate the technical solutions in the embodiments of the present application or in the prior art more clearly, to embodiment or will show below There is attached drawing needed in technology description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this Some embodiments described in application, for those of ordinary skill in the art, in the premise of not making the creative labor property Under, other drawings may also be obtained based on these drawings.
Fig. 1 is the execution flow chart of the event loop systems operational mechanism of iOS in the prior art;
Fig. 2 is the method flow diagram of interim card detection in the prior art;
Fig. 3 is the method flow diagram monitored in the prior art event loop system;
Fig. 4 is work flow diagram when event loop system is in sleep procedure in the prior art;
Fig. 5 is a kind of method flow diagram of embodiment of the detection method provided by the present application using interim card;
Fig. 6 is a kind of method flow diagram of the embodiment provided by the present application for calculating the interim card period;
Fig. 7 is the method flow diagram provided by the present application that monitoring is executed to event loop system;
Fig. 8 is a kind of method flow diagram of the embodiment provided by the present application analyzed and lead to interim card reason method;
Fig. 9 is a kind of modular structure schematic diagram of embodiment provided by the present application using interim card detection device;
Figure 10 is a kind of modular structure schematic diagram of embodiment of interim card period computing unit provided by the present application.
Specific implementation mode
In order to make those skilled in the art better understand the technical solutions in the application, below in conjunction with the application reality The attached drawing in example is applied, technical solutions in the embodiments of the present application is clearly and completely described, it is clear that described implementation Example is merely a part but not all of the embodiments of the present application.Based on the embodiment in the application, this field is common The every other embodiment that technical staff is obtained without creative efforts should all belong to the application protection Range.
For convenience those skilled in the art understand that technical solution provided by the embodiments of the present application, below first to technical solution The technological accumulation and inheritance of realization illustrates.Common thread can only once execute an event, and thread will move back after handling part of finishing Go out.But a kind of mechanism that thread can be allowed to handle event at any time and do not exit is needed in many application scenarios, it is typical to apply Scene such as voice input monitor, the monitoring etc. of various hardware events (such as touching screen, rock mobile phone).In such application In scene, user's incoming event is the process constantly repeated, and thread is only configured to cyclically execute monitoring task, can The incoming event of user is handled in time.The above problem can be well solved using event loop (Event Loop) mechanism. So-called event loop mechanism refers to the process of that the main thread of application repeatedly obtains message from message queue, executes message, In, every message in message queue corresponds to an event.At the typical event loop mechanism such as event of Node js Reason, the RunLoop operating mechanisms etc. of the message loop in Windows operating system, iOS.That is, being followed just because of event The presence of ring mechanism can make App constantly run, and otherwise, APP runs will be immediately finished at the beginning.
The characteristics of repeating task in event loop mechanism often leads to the interim card of application, and is collapsed caused by interim card It is one of the problem of most influencing user experience in applying and the maximum pain spot of application developer, so quickly identifying application card , orientation problem root be best one of solution.Usually, it applies after reaching the standard grade, for developer and O&M people For member, the framework of application, the executive condition of program code are all a black boxs, can not perceive user and use the true of application Impression can not be predicted using that whether interim card can occur, can't see how the specific data of business execute on earth, standard of more having no way The reason of really navigating to using interim card occurs.
Interim card of the main thread in single cycle is calculated using several material time nodes in event loop system Time can well solve the above problem.Before the embodiment for introducing interim card detection provided by the present application, introduce first The execution step of event loop mechanism, it can be seen from the above, the otherness of platform leads to the realization method of event loop mechanism not to the utmost It is identical, in order to clearly show the details of this programme, therefore it is without limitation the thing based on iOS by event loop mechanism construction The part circulatory system, still, one of skill in the art will understand that, the event loop mechanism of the application can be based on any behaviour Make the event loop mechanism of system.
In iOS, when an application is activated, correspondingly, operating system can create one and be applied relatively with described The host process answered, the main thread are used to execute the task in the application.While creating the host process, the main line Journey is also started immediately.In iOS, the main thread of the event loop system and application has one-to-one relationship.Fig. 1 is existing There is the execution flow chart of the event loop system based on iOS in technology, as shown in Figure 1, in the implementation procedure of event loop system In, it is related to the objects such as timer, the source (source1) based on port, the source (source0) for being not based on port, observer.Under Effect and performed task of the above-mentioned several objects played in the event loop system of iOS are introduced respectively in face.
Wherein, the timer may include time-based trigger, for example, the trigger include time span and It adjusts back (function pointer).The timer is added to event loop system, the event loop system can register correspondence At the time point of time span, when reaching at the time point, event loop system can be waken up to execute the institute in timer State readjustment.
The place that source is generated as event can be divided into two kinds of source0 and source1.Wherein, source0 cannot be led Dynamic trigger event, and source1 can be used for mutually sending message by kernel and other threads, and being capable of active main thread (if event loop system is in a dormant state).
The observer can include readjustment (function pointer), when the state of event loop system changes, observation Person can receive the state change of event loop system by the readjustment.The observer can be used for tracking following things Part:Event, the event loop system of the entry event circulatory system will handle the event of timer, event loop system will stop The event etc. that event, the event loop system that event, the event loop system of dormancy are waken up will exit.
As shown in Figure 1, the implementation procedure of event loop system can be divided into 7 stages, wherein the stage in stage 2- 6 is set It is set to the process that cycle executes.After the source0 events in the stage that handled 3, event loop system is begun listening in applying Source1 events whether occur, if listening to source1 events, skip phase 4 and stage 5, go in the stage 6 Execute the source1 events received.From the process that the process in stage 4 to stage 5 is waiting event, at this point, event loop system System in a dormant state, when source1 events occur, the source1 events can the active wake events circulatory system, allow Event loop system executes the event received.It is based on above-mentioned event loop system, can be installed in iOS It applies and rests when user does not operate, and the operation for the user that can make an immediate response when user's operation.
Based on above-mentioned event loop system, a kind of method that interim card is applied in detection is proposed in the prior art, Fig. 2 is existing skill The method flow diagram that interim card detects in art, as shown in Fig. 2, one in 7 execution stages that event loop system can be obtained Crucial moment, the crucial moment can be subject thread (such as main thread) event loop system in single cycle from Tm at the time of wake-up in suspend mode.The specific method that moment tm is waken up from suspend mode that obtains can refer to method stream shown in Fig. 3 Cheng Tu judges whether the event loop system calls out from suspend mode as shown in figure 3, can monitor event loop system It wakes up, if the determination result is YES, then obtains tm at the time of the event loop system wakes up from suspend mode;Otherwise, judge the thing Whether the part circulatory system enters dormant state.If it is determined that the event loop system enters dormant state, then the event is followed Tm is set as 0 at the time of loop system wakes up from suspend mode.As shown in Fig. 2, obtaining the event loop system single cycle mistake In journey after tm at the time of wake-up in suspend mode, period ctm-tms of the moment tm apart from current time ctm is calculated.If described Moment tm is not equal to 0 and ctm-tm >=interim card activation threshold value, it is determined that the target process is in interim card state.
In conjunction with the above-mentioned description to being detected in the prior art using interim card method, it is found that due to detecting whether to occur The starting time of interim card is the stage 5 in Fig. 1, and the end time is the stage 4 in Fig. 1, and entire detection process has ignored the stage 4 and arrives At least there are following two problems in the waiting period in stage 5:
First, in a typical application scenarios, for certain Nanjing user during using certain APP, the user is at 1 point Ceaselessly browsing pictures in clock, and the download of picture needs to send network request to server, then the client of the user exists In this 1 minute period ceaselessly network request is sent to server.It can be found that the user is in the normal use APP, But if using detection in the prior art using the method for interim card, it is likely that determine the APP within this 1 minute period Interim card occurs.If (access page when being such as back to historical time point of taking emergency measures is arranged after determining that interim card occurs for APP Face), it will be very bad experience for users.
With reference to above application scene explanation, problem existing for interim card is applied in detection in the prior art.As shown in Figure 1, It listens to after client in the stage 3 sends out network request (i.e. source1 events), event loop system will skip phase 4 With the stage 5, then execute stage 6 the step of.Problems with will so be will appear:If being waken up from suspend mode in the record stage 5 Moment is tm, and hereafter, event loop system listens to the network request (i.e. source1 events) that client is sent out incessantly, During then handling network request in the stage 6, stage 4 and stage 5 will not all be performed always.If at this point, using existing It is more than interim card activation threshold value that technical method, which can be calculated and wake up period ctm-tms of the moment tm apart from current time ctm, Judgment rule according to fig. 2 then erroneously determines that interim card occurs for subject thread.But there is no occur for the actually described subject thread Interim card, the subject thread are steadily run from stage 3 to the stage 6 always.
Second, interim card detection in the prior art has ignored the sleep procedure in stage 4 to stage 5, but in a practical situation, During between stage 4 to the stage 5, event loop system is not constantly in dormant state.Fig. 4 is thing in the prior art The part circulatory system is in work flow diagram when sleep procedure, as shown in figure 4, working as the event loop system in a dormant state When, it can monitor and default interface operation event whether occurs be handled described pre- if listening to the default interface operation event If interface operation event.After the event loop system has handled the default interface operation event, restore to dormant state. Pass through the flow chart described in Fig. 4, it is found that although the default interface operation event cannot by the event loop system from It is waken up in dormant state, but the event loop system handles the default interface operation event in sleep procedure really. So, event is handled in sleep procedure it can also happen that interim card, and interim card detection method in the prior art has ignored event The circulatory system handles the process of event in sleep procedure, thus may omit the part interim card fallen in the event loop system The detection of phenomenon.
It is directed to the phenomenon that above-mentioned interim card for applying interim card detection method to occur in the prior art is judged by accident, interim card is failed to judge, this Application proposes a kind of detection method using interim card, can accurately judge to apply whether interim card occurs.It is right below in conjunction with the accompanying drawings It is described herein to be described in detail using the detection method of interim card.Fig. 5 is the detection provided by the present application using interim card A kind of method flow schematic diagram of embodiment of method.Although this application provides such as following embodiments or methods shown in the drawings Operating procedure, but may include either more or less operation in the method without performing creative labour based on routine Step.In the step of causality is not present in logicality, the execution sequence of these steps is not limited to the embodiment of the present application and carries Confession executes sequence.It, can be according to reality in the detection process using interim card of the method in practice or when device executes Applying example, either method shown in the drawings sequence executes or parallel executes (such as the ring of parallel processor or multiple threads Border).
A kind of a kind of embodiment of specific detection method using interim card provided by the present application is as shown in figure 5, the side Method may include:
S1:The event loop system for obtaining subject thread executes the first moment of deliberate action in single cycle, described Deliberate action is to execute action in the event loop system circulation implementation procedure.
In the present embodiment, the subject thread can be the main thread of intended application, in other embodiments, the target Thread can also be the sub-line journey of the main thread, and the application is not limited herein.In the present embodiment, the single cycle It is corresponding that one wake-up trigger event (such as source1) is executed with the event loop system.Two can be extracted in the present embodiment A material time point, including the first moment, first moment may include the event loop for obtaining the subject thread At the time of system executes deliberate action in the single cycle.The deliberate action can meet following conditions:
The deliberate action is in the cycle implementation procedure of the event loop system;
And the deliberate action is that necessity executes action in event loop systematic procedure.
The execution action of the execution flow chart of event loop system as shown in Figure 1, stage in stage 2- 6 is in the event In the cycle implementation procedure of the circulatory system, wherein stage 2, stage 3 are that necessity executes action, and the stage in stage 4- 6 is inessential holds Action is made, and is touched because whether the action in stage in stage 4- 6 can execute needs according to whether event loop system listens to wake-up Hair event (such as source1 events) determines.In the present embodiment, by necessity in the event loop system circulation implementation procedure Execution action is used as deliberate action, and obtain at the time of execute the deliberate action, then, it is described to execute the deliberate action Moment can execute the deliberate action as the initial time of the event loop system circulation process recycle next time in Moment can contain as the end time of last cyclic process, the period of the initial time to the end time The execution time of entire cyclic process, compared with the existing technology in method, in the present embodiment, by execute the deliberate action when The initial time as event loop system circulation process is carved, the sleep procedure between stage 4 to the stage 5 will not be ignored, in turn The application interim card occurred between stage 4 to the stage 5 will not be ignored.
S2:First period of first moment apart from reference instant is calculated, and using first period as the thing Interim card period of the part circulatory system in the single cycle.
It is described that the event loop system is calculated described according to first moment in one embodiment of the application The interim card period in single cycle may include:
SS:The period of the first reference instant of the first moment distance is calculated, and is followed the period as the event Interim card period of the loop system in the single cycle.
First reference instant may include at the time of executing the calculating, and first reference instant can also be rank In section 6 at the time of start to process wake-up trigger event, the application is not limited herein.As described above, in the present embodiment, will execute The initial time at the time of deliberate action as event loop system circulation process will not be ignored between stage 4 to the stage 5 Sleep procedure, and then the period that the first reference instant of the first moment distance is calculated can accurately express the thing The interim card time of part circulatory system cyclic process.
The application also provides the another embodiment for calculating the interim card period, and Fig. 6 is calculating card provided by the present application Immediately the method flow diagram of a kind of embodiment of section, as shown in fig. 6, the calculating event loop system is followed in the single The interim card period in ring may include:
S61:Judge whether the event loop system is waited for;
S62:If the result judged is yes, obtains the event loop system and enter not in the single cycle Second moment of dormancy state;
S63:The first period of the second reference instant of the first moment distance, second moment are calculated apart from described Second period of two reference instants, second reference instant are later than second moment;
S64:Using the difference of second period and first period as the event loop system in the single The interim card period in cycle.
As the above analysis, between the stage 4- stages 5 shown in FIG. 1, the event loop system may execute institute Default interface event is stated, then thering is event loop system described in partial period to be waited between the stage 4- stages 5 (i.e. dormant state), another part period are in processing state-event and therefore during calculating the interim card period, need Except the period that event loop system is waited between the stage in stage 4- 5.In the present embodiment, the thing can be first determined whether Whether the part circulatory system is waited for, if the judging result is yes, obtains the event loop system in the list Enter the second moment of dormant state in secondary cycle.Second moment can be used for calculating the event loop system in the stage 4 and the stage 5 in period for being waited for.
The embodiment method of above-mentioned S61-S64 is illustrated below by a specific scene, it is possible, firstly, to judge institute State whether event loop system is waited for, if the result judged is waited for as the event loop system, It can determine the wait state that the event loop system was between stage 4 and stage 5.Determining the event loop system After being waited for, first period (b-a) of first moment a apart from the second reference instant b can be calculated, it is described First period (b-a) is determined for the event loop system from the initial time of the single cycle apart from described second Total period of reference instant.The second period (b-c) of the second reference instant of the second moment c distance b is calculated, when described second Section (b-c) is determined for the waiting period of the event loop system between stage 4 and stage 5.It should be noted that The second reference instant b is later than the second moment a, and in one embodiment of the application, the reference instant b can be At the time of executing the calculating, in other embodiments, the reference instant b can also be to be later than appointing for the second moment a It anticipates the moment, this is not restricted by the application.It is then possible to by the difference of first period (b-a) and second period (b-c) It is worth the interim card period of (b-a)-(b-c) as the event loop system in the single cycle.In another of the application In embodiment, if the result judged is not in wait state as the event loop system, the event can be determined The processing that the circulatory system was between stage 4 and stage 5 presets the state of interface event or handles default wake up in the stage 6 The state of trigger event, not above-mentioned waiting period, at this point, then regarding first period (b-a) as the event loop Interim card period of the system in the single cycle.
In the present embodiment, when the event loop system is waited for, the event loop system can be existed Dormancy time between stage 4 and stage 5 is removed from cycle total time, when more accurate interim card can be calculated in this way Section avoids because of interim card erroneous judgement caused by the interim card period being calculated is bigger than normal.
In the present embodiment, the event loop system can be obtained described by way of monitoring event loop system Enter the second moment of dormant state in single cycle, Fig. 7 is the side provided by the present application that monitoring is executed to event loop system Method flow chart, as shown in figure 5, described obtain the event loop system in the single cycle into the second of dormant state Moment includes:
S71:Monitoring is executed to the event loop system of the subject thread, and judge the event loop system whether into Enter dormant state;
S72:If the determination result is YES, the second moment that the event loop system enters dormant state is obtained.
In the present embodiment, monitoring can be executed to the event loop system of the subject thread, in the present embodiment, in order to carry High execution efficiency can be arranged another thread and execute the monitoring action.After entering snoop procedure, the event is obtained At the time of the circulatory system executes the deliberate action in single cycle.Hereafter, the event loop system can be monitored whether Into dormant state, in one embodiment of the application, it can be determined that whether the event loop system enters dormant state. If the result judged is yes, the second moment that the event loop system enters dormant state is obtained.It needs to illustrate It is that, when the event loop system to the subject thread starts to execute and monitor, the event loop system can be set and entered The initial time of dormant state is 0.
In one embodiment of the application, setting can be monitored by being executed to the event loop system of the subject thread At:
If listen to the subject thread correspondence application is more than the second predetermined threshold value without operation time period, it is arranged every pre- If the period executes primary monitor to the event loop system of the subject thread.
As shown in figure 3, in the prior art, cycle monitoring is carried out to the event loop system, the wake-up moment is clear After zero, the event loop system can be executed and be monitored next time.To the event loop system of the subject thread not between It monitors disconnectedly, the watcher thread may be caused to influence the interim card of the subject thread, even result in the card of the subject thread .Therefore, can be while monitoring the event loop system in the present embodiment, the action event at monitoring users interface, If user interface is more than the second predetermined threshold value without operation time period, thing of the every preset time period to the subject thread is set The part circulatory system executes primary monitor.
In one embodiment of the application, second predetermined threshold value can be 10 seconds.In the present embodiment, in iOS, Watchdog modules are during monitoring, and when the interim card time of application being more than 10 seconds, watchdog modules can force to disconnect The process of the application.In the present embodiment, if user interface in 10 seconds without action event, at this point, the application may be located In idle state, it is also possible to be forced to disconnect by watchdog modules.Therefore, it sets the second predetermined threshold value to 10 seconds, not only may be used To reduce the resource consumption in applying, reduce the influence to subject thread interim card to the monitoring of event loop system, it can also be with The interim card time threshold that iOS system monitors module matches.
In another embodiment of the application, the preset time period can be configured to and first predetermined threshold value If the first predetermined threshold value of the interim card triggering that matches is set as 5 seconds, in the present embodiment, when can also be arranged described default Between section be 5 seconds.The preset time period is arranged to match with first predetermined threshold value, on the one hand reduces the money in application Source consumes, on the other hand reducing influence of the monitoring to event loop system to subject thread interim card will not postpone to the mesh Graticule journey interim card detects.
S3:If the interim card period is more than the first predetermined threshold value, it is determined that the subject thread is in interim card state.
In the present embodiment, if detecting, the interim card period is more than the first predetermined threshold value, it is determined that at the subject thread In interim card state.Subsequent, as shown in figure 8, after determining that the subject thread is in interim card state, the method can be with Including:
S81:The historical action for obtaining the subject thread correspondence application executes record;
S82:Record is executed according to the historical action, determines that lead to the subject thread interim card executes action.
In the present embodiment, record can be executed according to the historical action of acquisition, determination leads to the subject thread interim card Execute action.The historical action executes the allocating stack that record can be the application, and the allocating stack can be used for remembering That records the subject thread executes action.Executing record according to the historical action and can analyze to obtain leads to the subject thread The reason of interim card, such as subject thread deadlock, frequent input/output operations, a large amount of interface drafting of execution or calculating are appointed Business, subject thread send when network request transfers data to server and are abnormal situation etc..Application developer can be to institute State that cause the execution of subject thread interim card to act for statistical analysis, obtain frequently result in subject thread interim card execute action, And resource adjustment is carried out to respective application for execution action.In a specific example, if the target process passes through Often since frequent input/output operations cause interim card, then it can increase the concurrent quantity of thread of the application, to reduce The burden of the input/output interface of application is stated, the follow-up probability that interim card occurs is reduced.
Detection method provided by the present application using interim card can be followed according to the event loop system of subject thread in single In ring at the time of execution deliberate action, into the initial time of dormant state, the event loop system is calculated described The interim card period in single cycle.The application method can solve two technical problems in the prior art, the reason is as follows that:It is described Execute deliberate action at the time of as the event loop system single cycle initial time, then next time recycle in It can come from entire cycle implementation procedure as the end time of last cyclic process at the time of executing the deliberate action It sees, the period of the initial time to end time includes the period that entire cycle executes.Relative to prior technique, The interim card period that the present embodiment method is calculated is more accurate, will not ignore and be executed in sleep procedure between stage 4 to the stage 5 The period of task, because of the application interim card without occurring between stage described in missing inspection 4 to the stage 5.
Illustrate the present embodiment method below by a specific application scenarios, in order to clearly show the thin of this programme Section, therefore without limitation by the Runloop systems operational mechanisms that Event Loop mechanism constructions are iOS in the application, still, One of skill in the art will understand that the Event Loop mechanism of this programme can be any logical based on event loop technology With or special operating mechanism.When the Runloop systems of the main thread of application A are activated, the main thread is in as shown in Figure 1 Event loop system in, until event loop terminates when EXIT message (such as receive).Usually, the main thread can be with A variety of events using A are handled, such as send network request, image procossing, file transmission, phonetic incepting, gesture identification Deng.But in above-mentioned event only have partial event need main thread to be continually monitored, such as send network request, file transmission, The events such as phonetic incepting.It is the source1 events to need the event that main thread constantly monitors, as described above, source1 things Part can wake up the Runloop systems from dormant state.In this scene, can it is described using A in create new line Journey 1, for carrying out monitoring and interim card detection to the Runloop systems.For example, in the single of the main thread using A After event loop process, the thread 1 is recorded the main thread execution and notifies observer and execute the readjustment step of timer 1 T1 is 35 minutes and 23.754 seconds 14 points of on November 11st, 2016 at the time of (i.e. stage 2).At this point, the thread 1 may determine that it is described Whether Runloop systems are waited for, and if the determination result is YES, then can determine that the Runloop systems are in the stage 4 Dormant state between the stage 5, in this scene, the thread 1 is recorded Runloop systems and is entering the dormant state (stage 4) t2 is 35 minutes and 28.949 seconds 14 points of on November 11st, 2016 at the time of.It is 2016 that current time t3, which is also recorded, in the thread 1 35 minutes and 29.006 seconds 14 points of on November 11, then, first periods 5.252 second of the current time t3 apart from moment t1 is from institute State total execution periods of the initial time t1 apart from current time of single cycle.When current time t3 is apart from the second of moment t2 Section 0.057 second be dormancy time section of the Runloop systems between stage 4 and stage 5.By the dormancy time section of the second period It is removed from the first period, poor 5.195 seconds of the first period and the second period that are calculated are in this single cycle The period of interim card occurs for Runloop systems.If interim card threshold value is 5 seconds, 5.195 seconds periods since interim card occurs are more than card Threshold value of pausing 5 seconds, then can determine that interim card has occurred in this single cycle in the main thread of Runloop systems.It is subsequent, it is described Thread 1 may call upon the allocating stack using A, and what the allocating stack can be used for recording the main thread executes action. It can analyze to obtain the reason of leading to the main thread interim card according to the allocating stack using A, such as subject thread deadlock, Frequent input/output operations execute a large amount of interface drafting or calculating task, subject thread transmission network request transmission number Situation etc. is abnormal when according to server.
On the other hand the application also provides a kind of detection device using interim card, Fig. 9 is provided by the present application using interim card The modular structure schematic diagram of a kind of embodiment of detection device, as shown in figure 9, described device may include:
First moment acquiring unit 91, the event loop system for obtaining subject thread execute default in single cycle First moment of action, the deliberate action are to execute action in the event loop system circulation implementation procedure;
Interim card period computing unit 92, for calculating the event loop system in the single according to first moment The interim card period in cycle;
Interim card determination unit 93, if being more than the first predetermined threshold value for the interim card period, it is determined that the subject thread In interim card state.
Detection device provided by the present application using interim card can be followed according to the event loop system of subject thread in single In ring at the time of execution deliberate action, into the initial time of dormant state, the event loop system is calculated described The interim card period in single cycle.The application method can solve two technical problems in the prior art, the reason is as follows that:It is described Execute deliberate action at the time of as the event loop system single cycle initial time, then next time recycle in It can come from entire cycle implementation procedure as the end time of last cyclic process at the time of executing the deliberate action It sees, the period of the initial time to end time includes the period that entire cycle executes.Relative to prior technique, The interim card period that the present embodiment method is calculated is more accurate, will not ignore and be executed in sleep procedure between stage 4 to the stage 5 The period of task, because of the application interim card without occurring between stage described in missing inspection 4 to the stage 5.
In one embodiment of the application, the interim card period computing unit 92 can be also used for:
The period of the first reference instant of the first moment distance is calculated, and using the period as the event loop system It unites the interim card period in the single cycle.
In one embodiment of the application, Figure 10 is a kind of implementation of interim card period computing unit 92 provided by the present application The modular structure schematic diagram of example, as shown in Figure 10, the interim card period computing unit 92 includes:
Judging unit 101 is waited for, for judging whether the event loop system is waited for;
Second moment acquiring unit 102 obtains the event loop system and exists if being yes for the result judged Enter the second moment of dormant state in the single cycle;
Period computing unit 103, for calculate the second reference instant of the first moment distance the first period, described Second period of two moment apart from second reference instant, second reference instant are later than second moment;
Period difference computational unit 104, for using the difference of second period and first period as the thing Interim card period of the part circulatory system in the single cycle.
Although mentioning the event loop system in embodiment in teachings herein to monitor, execute monitoring to event loop system Be configured, data judge or the like data decryptor, setting, processing description, still, the application be not limited to must be Full the case where meeting data displaying, processing described in industry programming language design standard or embodiment.Certain Pages Design languages Embodiment modified slightly can also carry out that above-described embodiment is identical, equivalent or phase on the basis of speech or embodiment description The implementation result closely or after deformation being anticipated that.Certainly, even if not by the way of upper data processing, judgement, as long as meeting this Shen Please the various embodiments described above data decryptor, data setting and information judgment mode, identical application still may be implemented, herein not It repeats again.
Although this application provides the method operating procedure as described in embodiment or flow chart, based on conventional or noninvasive The means for the property made may include more or less operating procedure.The step of being enumerated in embodiment sequence is only numerous steps A kind of mode in execution sequence does not represent and unique executes sequence.It, can when device or client production in practice executes With according to embodiment, either method shown in the drawings sequence is executed or parallel executed (such as at parallel processor or multithreading The environment of reason).
Unit that above-described embodiment illustrates, device can specifically realize by computer chip or entity, or by having certain The product of function is planted to realize.For convenience of description, it is divided into various modules when description apparatus above with function to describe respectively.When So, the function of each module is realized can in the same or multiple software and or hardware when implementing the application.Certainly, originally A certain unit module described in application can also will realize the module of same function by the combination of multiple submodule or submodule It realizes.
It is also known in the art that other than realizing controller in a manner of pure computer readable program code, it is complete Entirely can by by method and step carry out programming in logic come so that controller with logic gate, switch, application-specific integrated circuit, programmable The form of logic controller and embedded microcontroller etc. realizes identical function.Therefore this controller is considered one kind Hardware component, and the structure that the device for realizing various functions that its inside includes can also be considered as in hardware component.Or Person even, can will be considered as either the software module of implementation method can be hardware again for realizing the device of various functions Structure in component.
The application can describe in the general context of computer-executable instructions executed by a computer, such as program Module.Usually, program module includes routines performing specific tasks or implementing specific abstract data types, program, object, group Part, data structure, class etc..The application can also be put into practice in a distributed computing environment, in these distributed computing environments, By executing task by the connected remote processing devices of communication network.In a distributed computing environment, program module can With in the local and remote computer storage media including storage device.
As seen through the above description of the embodiments, those skilled in the art can be understood that the application can It is realized by the mode of software plus required general hardware platform.Based on this understanding, the technical solution essence of the application On in other words the part that contributes to existing technology can be expressed in the form of software products, the computer software product It can be stored in a storage medium, such as ROM/RAM, magnetic disc, CD, including some instructions are used so that a computer equipment (can be personal computer, mobile terminal, server either network equipment etc.) executes each embodiment of the application or implementation Method described in certain parts of example.
Each embodiment in this specification is described by the way of progressive, same or analogous portion between each embodiment Point just to refer each other, and each embodiment focuses on the differences from other embodiments.The application can be used for crowd In mostly general or special purpose computing system environments or configuration.Such as:Personal computer, server computer, handheld device or Portable device, laptop device, multicomputer system, microprocessor-based system, set top box, programmable electronics set Standby, network PC, minicomputer, mainframe computer include the distributed computing environment etc. of any of the above system or equipment.
Although depicting the application by embodiment, it will be appreciated by the skilled addressee that the application there are many deformation and Variation is without departing from spirit herein, it is desirable to which the attached claims include these deformations and change without departing from the application's Spirit.

Claims (10)

1. a kind of detection method using interim card, which is characterized in that the method includes:
The event loop system for obtaining subject thread executes the first moment of deliberate action, the deliberate action in single cycle To execute action in the event loop system circulation implementation procedure;
Interim card period of the event loop system in the single cycle is calculated according to first moment;
If the interim card period is more than the first predetermined threshold value, it is determined that the subject thread is in interim card state.
2. according to the method described in claim 1, it is characterized in that, described calculate the event loop according to first moment Interim card period of the system in the single cycle include:
The period of the first reference instant of the first moment distance is calculated, and is existed the period as the event loop system The interim card period in the single cycle.
3. according to the method described in claim 1, it is characterized in that, described calculate the event loop according to first moment Interim card period of the system in the single cycle include:
Judge whether the event loop system is waited for;
If the result judged is yes, the event loop system is obtained in the single cycle into dormant state Second moment;
When calculating the first period of the second reference instant of the first moment distance, second moment apart from second benchmark The second period carved, second reference instant are later than second moment;
Using the difference of second period and first period as the event loop system in the single cycle The interim card period.
4. according to the method described in claim 3, it is characterized in that, the acquisition event loop system is followed in the single Include into the second moment of dormant state in ring:
Monitoring is executed to the event loop system of the subject thread, and judges whether the event loop system enters suspend mode shape State;
If the determination result is YES, the second moment that the event loop system enters dormant state is obtained.
5. according to the method described in claim 4, it is characterized in that, the event loop system to the subject thread executes Monitoring is configured to:
If listen to the subject thread correspondence application is more than the second predetermined threshold value without operation time period, it is arranged when default Between section primary monitor is executed to the event loop system of the subject thread.
6. according to the method described in claim 5, it is characterized in that, the preset time period is configured to preset with described first Threshold value matches.
7. according to the method described in claim 1, it is characterized in that, after determining that the subject thread is in interim card state, The method further includes:
The historical action for obtaining the subject thread correspondence application executes record;
Record is executed according to the historical action, determines that lead to the subject thread interim card executes action.
8. a kind of detection device using interim card, which is characterized in that described device includes:
First moment acquiring unit, the event loop system for obtaining subject thread execute deliberate action in single cycle First moment, the deliberate action are to execute action in the event loop system circulation implementation procedure;
Interim card period computing unit, for calculating the event loop system in the single cycle according to first moment The interim card period;
Interim card determination unit, if being more than the first predetermined threshold value for the interim card period, it is determined that the subject thread is in card State.
9. device according to claim 8, which is characterized in that the interim card period computing unit is additionally operable to:
The period of the first reference instant of the first moment distance is calculated, and is existed the period as the event loop system The interim card period in the single cycle.
10. device according to claim 8, which is characterized in that the interim card period computing unit includes:
Judging unit is waited for, for judging whether the event loop system is waited for;
Second moment acquiring unit obtains the event loop system in the list if being yes for the result judged Enter the second moment of dormant state in secondary cycle;
Period computing unit, for the first period for calculating the second reference instant of the first moment distance, second moment The second period apart from second reference instant, second reference instant are later than second moment;
Period difference computational unit, for using the difference of second period and first period as the event loop system It unites the interim card period in the single cycle.
CN201710083350.2A 2017-02-16 2017-02-16 A kind of detection method and device using interim card Pending CN108446199A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710083350.2A CN108446199A (en) 2017-02-16 2017-02-16 A kind of detection method and device using interim card

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710083350.2A CN108446199A (en) 2017-02-16 2017-02-16 A kind of detection method and device using interim card

Publications (1)

Publication Number Publication Date
CN108446199A true CN108446199A (en) 2018-08-24

Family

ID=63190557

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710083350.2A Pending CN108446199A (en) 2017-02-16 2017-02-16 A kind of detection method and device using interim card

Country Status (1)

Country Link
CN (1) CN108446199A (en)

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109324977A (en) * 2018-10-31 2019-02-12 北京微播视界科技有限公司 Detection method, device and the electronic equipment of application program Caton
CN109783217A (en) * 2019-01-22 2019-05-21 无锡华云数据技术服务有限公司 Shut down determination method, apparatus, electronic equipment and the storage medium of period
CN109902011A (en) * 2019-02-28 2019-06-18 深圳乐信软件技术有限公司 A kind of software Caton monitoring method, device, equipment and storage medium
CN110837420A (en) * 2019-11-12 2020-02-25 Oppo广东移动通信有限公司 Resource scheduling method, device, terminal and storage medium
CN110908864A (en) * 2019-11-11 2020-03-24 腾讯科技(深圳)有限公司 Equipment blocking processing method, device, equipment and medium
CN111045926A (en) * 2019-11-05 2020-04-21 北京字节跳动网络技术有限公司 Application program jamming detection method, device, medium and electronic equipment
CN111274086A (en) * 2020-01-15 2020-06-12 湖北工程学院 Computer software fault monitoring system
CN112559839A (en) * 2019-09-10 2021-03-26 北京国双科技有限公司 Data acquisition method and device, computer equipment and storage medium
CN112764959A (en) * 2021-01-27 2021-05-07 北京字节跳动网络技术有限公司 Method, device and equipment for monitoring application program jamming problem and storage medium
CN113453076A (en) * 2020-03-24 2021-09-28 中国移动通信集团河北有限公司 User video service quality evaluation method and device, computing equipment and storage medium
CN113835985A (en) * 2021-09-27 2021-12-24 北京基调网络股份有限公司 Method, device and equipment for monitoring and analyzing cause of stuck

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7069476B1 (en) * 2002-08-15 2006-06-27 Network Appliance, Inc. Method and apparatus to release a serial bus from a suspended state
CN104991855A (en) * 2015-06-16 2015-10-21 广州华多网络科技有限公司 Processing method and device for interface lag
EP2980697A1 (en) * 2014-08-01 2016-02-03 Kaspersky Lab, ZAO System and method for altering a functionality of an application
CN105589783A (en) * 2014-11-18 2016-05-18 广州市动景计算机科技有限公司 Application program lag problem data obtaining method and device
CN105930248A (en) * 2016-04-20 2016-09-07 南京酷派软件技术有限公司 Application performance prompting method and system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7069476B1 (en) * 2002-08-15 2006-06-27 Network Appliance, Inc. Method and apparatus to release a serial bus from a suspended state
EP2980697A1 (en) * 2014-08-01 2016-02-03 Kaspersky Lab, ZAO System and method for altering a functionality of an application
CN105589783A (en) * 2014-11-18 2016-05-18 广州市动景计算机科技有限公司 Application program lag problem data obtaining method and device
CN104991855A (en) * 2015-06-16 2015-10-21 广州华多网络科技有限公司 Processing method and device for interface lag
CN105930248A (en) * 2016-04-20 2016-09-07 南京酷派软件技术有限公司 Application performance prompting method and system

Cited By (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109324977A (en) * 2018-10-31 2019-02-12 北京微播视界科技有限公司 Detection method, device and the electronic equipment of application program Caton
CN109783217A (en) * 2019-01-22 2019-05-21 无锡华云数据技术服务有限公司 Shut down determination method, apparatus, electronic equipment and the storage medium of period
CN109783217B (en) * 2019-01-22 2019-09-13 无锡华云数据技术服务有限公司 Shut down determination method, apparatus, electronic equipment and the storage medium of period
CN109902011A (en) * 2019-02-28 2019-06-18 深圳乐信软件技术有限公司 A kind of software Caton monitoring method, device, equipment and storage medium
CN112559839A (en) * 2019-09-10 2021-03-26 北京国双科技有限公司 Data acquisition method and device, computer equipment and storage medium
CN112559839B (en) * 2019-09-10 2024-05-03 北京国双科技有限公司 Data acquisition method, device, computer equipment and storage medium
CN111045926B (en) * 2019-11-05 2023-04-14 北京字节跳动网络技术有限公司 Application program jamming detection method, device, medium and electronic equipment
CN111045926A (en) * 2019-11-05 2020-04-21 北京字节跳动网络技术有限公司 Application program jamming detection method, device, medium and electronic equipment
CN110908864A (en) * 2019-11-11 2020-03-24 腾讯科技(深圳)有限公司 Equipment blocking processing method, device, equipment and medium
CN110908864B (en) * 2019-11-11 2024-05-10 腾讯科技(深圳)有限公司 Equipment jamming processing method, device, equipment and medium
CN110837420A (en) * 2019-11-12 2020-02-25 Oppo广东移动通信有限公司 Resource scheduling method, device, terminal and storage medium
CN111274086A (en) * 2020-01-15 2020-06-12 湖北工程学院 Computer software fault monitoring system
CN111274086B (en) * 2020-01-15 2023-06-13 湖北工程学院 Computer software fault monitoring system
CN113453076A (en) * 2020-03-24 2021-09-28 中国移动通信集团河北有限公司 User video service quality evaluation method and device, computing equipment and storage medium
CN112764959A (en) * 2021-01-27 2021-05-07 北京字节跳动网络技术有限公司 Method, device and equipment for monitoring application program jamming problem and storage medium
CN113835985A (en) * 2021-09-27 2021-12-24 北京基调网络股份有限公司 Method, device and equipment for monitoring and analyzing cause of stuck
CN113835985B (en) * 2021-09-27 2023-09-29 北京基调网络股份有限公司 Method, device and equipment for monitoring and analyzing jamming reason

Similar Documents

Publication Publication Date Title
CN108446199A (en) A kind of detection method and device using interim card
US10298469B2 (en) Automatic asynchronous handoff identification
CN100432949C (en) Method and device for storing user data on computer when software crashing
US10713107B2 (en) Detecting a possible underlying problem among computing devices
CN109558308A (en) Application program method for detecting memory leakage, device, electronic equipment and storage medium
US10230611B2 (en) Dynamic baseline determination for distributed business transaction
US20150220417A1 (en) Monitoring user activity and performance of computerized devices
US9727394B2 (en) Establishing causality order of computer trace records
CN112346834A (en) Database request processing method and device, electronic equipment and medium
CN114978883B (en) Network wakeup management method and device, electronic equipment and storage medium
CN113393213A (en) Method for creating group, computer equipment and storage medium
CN113238815B (en) Interface access control method, device, equipment and storage medium
CN114184885A (en) Fault detection method, device and storage medium
WO2024078494A1 (en) Thread management method and apparatus, electronic device, and storage medium
CN106911784B (en) Method and device for executing asynchronous event
CN113190427A (en) Caton monitoring method and device, electronic equipment and storage medium
CN113760491A (en) Task scheduling system, method, equipment and storage medium
CN114554110B (en) Video generation method, device, electronic equipment and storage medium
CN113835835B (en) Method, device and computer readable storage medium for creating consistency group
CN109359009A (en) Display control method, electronic device and computer readable storage medium
US11036551B2 (en) Durable program execution
CN114913649A (en) Display state monitoring method, device, equipment and computer readable storage medium
EP3059656B1 (en) System and method for managing display-related resources
CN113573080B (en) Live broadcast recording method and device, electronic equipment and storage medium
CN103870225B (en) A kind of response method and electronic equipment

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20180824

RJ01 Rejection of invention patent application after publication