CN106550042A - Multithreading method for down loading and device and computing device - Google Patents

Multithreading method for down loading and device and computing device Download PDF

Info

Publication number
CN106550042A
CN106550042A CN201611048274.3A CN201611048274A CN106550042A CN 106550042 A CN106550042 A CN 106550042A CN 201611048274 A CN201611048274 A CN 201611048274A CN 106550042 A CN106550042 A CN 106550042A
Authority
CN
China
Prior art keywords
thread
download
size
new thread
multithreading
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.)
Granted
Application number
CN201611048274.3A
Other languages
Chinese (zh)
Other versions
CN106550042B (en
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 China Co Ltd
Original Assignee
Guangzhou Youshi Network Technology 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 Guangzhou Youshi Network Technology Co Ltd filed Critical Guangzhou Youshi Network Technology Co Ltd
Priority to CN201611048274.3A priority Critical patent/CN106550042B/en
Publication of CN106550042A publication Critical patent/CN106550042A/en
Application granted granted Critical
Publication of CN106550042B publication Critical patent/CN106550042B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/06Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • H04L67/1074Peer-to-peer [P2P] networks for supporting data block transmission mechanisms
    • H04L67/1078Resource delivery mechanisms
    • H04L67/108Resource delivery mechanisms characterised by resources being split in blocks or fragments
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • H04L67/1074Peer-to-peer [P2P] networks for supporting data block transmission mechanisms
    • H04L67/1078Resource delivery mechanisms
    • H04L67/1085Resource delivery mechanisms involving dynamic management of active down- or uploading connections

Abstract

The invention discloses a kind of file multithreading method for down loading and device and computing device.Methods described includes:Set up thread and judge step, in the case of exiting for corresponding downloading task being completed in a thread, judge whether that meeting new thread sets up condition;Step is opened with new thread, in response to judging that meeting the new thread sets up condition, opens a new thread and redistributes thread downloading task.Using the multithreading method for down loading and device and computing device of the present invention, by setting up new thread in appropriate circumstances, it is fewer and feweri and reduce speed of download so as to the Thread Count that completes to cause is downloaded when solving the problems, such as that multithreading is different, so that reasonably keeping original Thread Count to carry out multithreading download as far as possible, so as to realize that speed of download is maximized, and while keep speed of download stable.

Description

Multithreading method for down loading and device and computing device
Technical field
Present invention relates in general to file download technical field, more particularly to one kind reasonably keep original line as far as possible Method and apparatus and computing device that number of passes is downloaded.
Background technology
Speed of download is one of the basic property index in file download field.Netowrk tape is used in order to optimize to a greater degree Thus wide and server resource reaches speed of download maximization, is generally segmented download mechanism using multithreading at present.That is, open multiple Thread go parallel simultaneously request download file, each thread be responsible for download specified file partial content, when all threads all When completing to download, the full content of whole file is just downloaded and is completed.
However, this segmentation algorithm of prior art can be realized downloading speed only in the case where network condition is ideal The maximization of degree.In fact, due to when the network environment on line and operation the internal memory performance of client it is uncontrollable, can cause every The speed of download of individual segmentation thread is different, and thus some threads first can complete to download, and some complete to download after the meeting.
And, file to be downloaded is bigger or the network bandwidth is less, downloads situation about completing more obvious when each thread is different. This can cause, and as the carrying out of downloading process, the Thread Count that actual participation is downloaded are fewer and feweri, cause speed of download reduction Situation.
Accordingly, it would be desirable to one kind can solve the problem that the problems referred to above, enabling realize speed of download maximize, while keep download Speed stable file fragmentation download mechanism.
The content of the invention
It is an advantage of the invention to provide a kind of multithreading download for reasonably keeping original Thread Count as far as possible is excellent Change mechanism so that the network bandwidth and server resource can be made full use of in whole file download process, under thus reaching Carry speed to maximize, lift the downloading experience of user.
To achieve these goals, multithreading method for down loading of the invention and device so that whenever a thread is completed down During load, constraint judgement is carried out according to correlative factor, and a new thread is opened in the case where condition is met, and utilization should New thread does not currently complete the part downloading task of the thread downloaded to undertake.
According to an aspect of the invention, there is provided a kind of multithreading method for down loading of file, wherein file to be downloaded quilt N number of paper interval is divided into, each described paper interval corresponds to download thread Ti, and wherein i=1N, N are more than 1, the multithreading method for down loading includes:
Set up thread and judge step, in the case of exiting for corresponding downloading task being completed in a thread, judge Whether meet new thread and set up condition;With
New thread opens step, in response to judging that meeting the new thread sets up condition, opens a new thread simultaneously Redistribute thread downloading task.
Using this method, when solving multithreading segmentation download, different threads go out because of factors such as network condition, internal memory performances Download when existing different and complete, the Thread Count of actual participation download is fewer and feweri and reduce down in the remaining download time caused Carry the problem of speed so that reasonably keep original Thread Count to carry out multithreading download as far as possible, be achieved in speed of download Maximize, and while keep speed of download stable.
In one embodiment of the invention, it is described judge whether to meet the step of new thread sets up condition include:According to Specified conditions factor, judges whether that meeting new thread sets up condition, wherein the specified conditions factor include it is following in appoint The combination of one or more:It is remaining to download size Lm;All N bars threads average speed of download Sv within a specified time;And The time-consuming Cv of average connection of all N bars threads when network connection is asked.
In one embodiment of the invention, it is described judge whether to meet the step of new thread sets up condition also include:Obtain The respective current residual of thread for taking all unfinished downloading tasks downloads size;Determine that current residual downloads the most line of size Journey Tm;And the corresponding current residuals of the thread Tm by determined by are downloaded and are sized to remaining download size Lm.
In one embodiment of the invention, the new thread condition of setting up includes any one of following or multinomial:It is surplus Remaining size Lm that carries is more than weight fragmentation threshold Lt;Accelerate duration Cs more than theoretical minimum with theoretical residue download time Ct, wherein, The theoretical residue download time Ct=residue downloads average speed of download Sv of size Lm/, and the theory is minimum to accelerate duration Cs Cv time-consuming to average connection is related.
In the present embodiment, it is contemplated that open the junction loss and/or speed-raising threshold value of new thread, it is to avoid in remaining download Amount is less and/or opens new thread in the case that remaining download time is shorter so that long actual on the contrary extend because connection is time-consuming Overall download time.
In one embodiment of the invention, one new thread of the unlatching the step of redistribute thread downloading task Including:The part downloading task that current residual downloads the most thread Tm of size is distributed to into the new thread.
It is in further embodiment of the present invention, described that the part that current residual downloads the most thread Tm of size is downloaded The step of task distributes to the new thread includes:Calculating averagely connects time-consuming Cv for reserved size Ls=of the new thread × average speed of download Sv;With set downloading task for the new thread as (Lm-Ls)/2, and correspondingly adjust the line The download of journey Tm is interval.
In one embodiment of the invention, the multithreading method for down loading also includes:Thread is set up described in repeating Judge that step and the new thread open step, the whole file to be downloaded is completed until downloading.
According to another aspect of the present invention, there is provided a kind of multithreading download apparatus of file, wherein file to be downloaded N number of paper interval is divided into, each described paper interval corresponds to download thread Ti, and wherein i=1N, N are big In 1, the multithreading download apparatus includes:Thread judging unit is set up, and is configured to corresponding download times be completed in a thread Business and in the case of exiting, judge whether that meeting new thread sets up condition;With new thread opening unit, it is configured in response to judging Meet the new thread and set up condition, open a new thread and redistribute thread downloading task.
In one embodiment of the invention, the thread judging unit of setting up is configured to according to specified conditions Factor, judges whether that meeting new thread sets up condition, wherein the specified conditions factor include it is following in any one or it is many Individual combination:It is remaining to download size Lm;All N bars threads average speed of download Sv within a specified time;And all N bars lines The time-consuming Cv of average connection of the journey when network connection is asked.
In one embodiment of the invention, the thread judging unit of setting up also includes:It is remaining to download acquiring size mould Block, the respective current residual of thread for being configured to obtain all unfinished downloading tasks download size;Subject thread determining module, It is configured to determine that current residual downloads the most thread Tm of size;And it is remaining download size determining module, be configured to by really The corresponding current residuals of fixed thread Tm are downloaded and are sized to remaining download size Lm.
In one embodiment of the invention, the new thread condition of setting up includes any one of following or multinomial:It is surplus Remaining size Lm that carries is more than weight fragmentation threshold Lt;Accelerate duration Cs more than theoretical minimum with theoretical residue download time Ct, wherein, The theoretical residue download time Ct=residue downloads average speed of download Sv of size Lm/, and the theory is minimum to accelerate duration Cs Cv time-consuming to average connection is related.
In one embodiment of the invention, the new thread opening unit includes:Weight segmentation module, being configured to will be current The remaining part downloading task for downloading the most thread Tm of size distributes to the new thread.
In further embodiment of the present invention, the heavy segmentation module includes:Reserved size computing module, is configured to meter Calculation averagely connects time-consuming Cv × average speed of download Sv for reserved size Ls=of the new thread;Mould is set with downloading task Block, is configured to set the downloading task for being directed to the new thread as (Lm-Ls)/2, and correspondingly adjusts the download of the thread Tm It is interval.
In one embodiment of the invention, the multithreading download apparatus also includes:Repeat enabling unit, be configured to make Thread judging unit and the new thread opening unit repetitive operation are set up described in obtaining, completes whole described to be downloaded until downloading File.
According to a further aspect of the invention, there is provided a kind of computing device, including:Network interface, the network interface The computing device is downloaded via the multithreading that one or more networks carry out file;Memorizer, by the net The file that network interface is downloaded is stored in which memory;And one or more processors, with the network interface and described Memorizer is connected, and one or more of processors are configured to for file to be downloaded to be divided into multiple paper intervals, each institute Paper interval is stated corresponding to a download thread, and performs following operation:Corresponding downloading task is completed in a thread and is moved back In the case of going out, judge whether that meeting new thread sets up condition;Set up condition with the new thread being met in response to judgement, open One new thread simultaneously redistributes thread downloading task.
Using the multithreading method for down loading and device and computing device of the present invention so that whenever a thread completes to download When, constraint judgement is carried out according to correlative factor, and a new thread is opened in the case where condition is met, and it is new using this Thread does not currently complete the part downloading task of the thread downloaded to undertake, and downloads and complete to make when thus solving multithreading difference Into Thread Count it is fewer and feweri and reduce the problem of speed of download so that reasonably keep original Thread Count to carry out as far as possible Multithreading is downloaded, and so as to realize that speed of download is maximized, and while keeps speed of download stable.
Description of the drawings
Disclosure illustrative embodiments are described in more detail by combining accompanying drawing, the disclosure above-mentioned and its Its purpose, feature and advantage will be apparent from, wherein, in disclosure illustrative embodiments, identical reference number Typically represent same parts.
Fig. 1 shows the structured flowchart of computing device according to an embodiment of the invention.
Fig. 2 shows the general flow chart of file multithreading method for down loading according to an embodiment of the invention.
Fig. 3 shows the functional block diagram of file multithreading download apparatus according to an embodiment of the invention.
Specific embodiment
The preferred implementation of the disclosure is more fully described below with reference to accompanying drawings.Although the disclosure is shown in accompanying drawing Preferred implementation, however, it is to be appreciated that may be realized in various forms the disclosure and the embodiment party that should not be illustrated here Formula is limited.Conversely, these embodiments are provided so that the disclosure is more thorough and complete, and can be by the disclosure Scope intactly conveys to those skilled in the art.
As it was previously stated, the downloading experience in order to lift speed of download and user, the multithreading download optimization machine of the present invention System so that when a thread completes to download, constraint judgement is carried out according to correlative factor, and is meeting the situation of condition One new thread of lower unlatching, and using the new thread undertaking the current part downloading task for not completing the thread downloaded, thus The Thread Count for completing to cause is downloaded when solving the problems, such as that multithreading is different fewer and feweri and reduce speed of download so as to the greatest extent may be used Original Thread Count can be reasonably kept to carry out multithreading download.
Embodiments of the invention are specifically described below with reference to Fig. 1 to Fig. 3.Fig. 1 is showed according to the present invention one The structured flowchart of the computing device 100 of embodiment.The part of the computing device 100 includes but is not limited to network interface 110, storage Device 120 and one or more processors 130.Processor 130 is connected with network interface 110 and memorizer 120.In the present invention One embodiment in, the miscellaneous part not shown in above-mentioned and Fig. 1 of computing device 100 can also be connected to each other, example Such as pass through bus.It should be appreciated that the computing device structured flowchart shown in Fig. 1 is solely for the purpose of illustration, rather than to this The restriction of invention scope.Those skilled in the art can increase or replace miscellaneous part as needed.
Computing device 100 can be any kind of static or mobile computing device, including mobile computer or mobile meter Calculation equipment (for example, tablet PC, personal digital assistant, laptop computer, notebook, net book etc.), movement Phone (for example, smart mobile phone), wearable computing device (for example, intelligent watch, intelligent glasses etc.) or other kinds of shifting Dynamic equipment, or the static computing device of such as desk computer or PC.Computing device 100 can also be portable or state type Server.
Network interface 110 enables computing device 100 via one or more network services.The example bag of these networks Include the combination of the communication network of LAN (LAN), wide area network (WAN), Personal Area Network (PAN) or such as the Internet.Network interface 110 Can be all including one or more in wired or wireless any kind of network interface (for example, NIC (NIC)) As IEEE 802.11 WLAN (WLAN) wave points, worldwide interoperability for microwave accesses (Wi-MAX) interface, Ethernet connect Mouth, USB (universal serial bus) (USB) interface, cellular network interface, blue tooth interface, near-field communication (NFC) interface, etc..
The file downloaded by network interface 110 is stored in the specified location in memorizer 120.Memorizer 120 may include One or more in any kind of storage device of the content of storage file form or other forms, including magnetic hard disk drives Device, solid-state hard disk driver, semiconductor memory apparatus, flash memory, or being capable of storage program instruction or any other calculating of digital information The readable writable storage media of machine.
File to be downloaded can be divided into N number of paper interval by processor 130, and wherein N is the natural number more than 1, and is made Obtain each paper interval and correspond to download thread Ti, wherein i=1N.
Although it is pointed out that in practice would generally be by file to be downloaded decile, each paper interval for being divided Size it is not necessarily impartial, the size of the corresponding paper interval of each bar download thread can be adjusted as needed.
It may also be noted that the Thread Count N that segmentation is downloaded not is the bigger the better.N is bigger, and performance cost is also bigger, network Connection is time-consuming also more, actually can not necessarily realize the maximization of speed of download.In practice, network rings can be considered The factors such as border, internal memory performance determine the Thread Count N that segmentation is downloaded.
Processor 130 is reasonably set up the process of thread and may refer to Fig. 2.Fig. 2 is shown according to one embodiment of the invention File multithreading method for down loading 200 overview flow chart.File multithreading method for down loading 200 is downloaded in certain thread and completes right The paper interval answered simultaneously is performed after exiting.
Method 200 starts from setting up thread and judges step, specifically, processor 130 a thread complete it is corresponding under Load task and in the case of exiting, judge whether that meeting new thread sets up condition.
In one embodiment of the invention, processor 130 can be configured to according to specified conditions factor, judge be It is no to meet new thread and set up condition.Specified conditions factor designated herein includes the group of any one or more in following factor Close:It is remaining to download size Lm;All N bars threads average speed of download Sv at the appointed time in (for example, 10 seconds);And it is all The time-consuming Cv of average connection of the N bars thread when network connection is asked.
In one embodiment of the invention, remaining size Lm of downloading can be identified below:First, all threads are traveled through Ti, i=1-N, download size with the respective current residual of the thread for obtaining all unfinished downloading tasks;It is then determined current It is remaining to download the most thread Tm of size;Finally, the corresponding current residuals of the thread Tm by determined by are downloaded and are sized to institute State remaining download size Lm.
As shown in Fig. 2 in step S210, processor 130 judges whether remaining download size Lm of thread Tm is more than and divides again Section threshold value Lt.In the case where Lm no more than Lt are judged (the "No" branch in step S210), then 200 (step of method is exited S290).In one example, Lt can be set as 1Mb.That is, if the remaining download file size of each thread is all less than 1Mb, Preferably it is not recommended that carrying out segment processing again, with avoid segmentation again itself loss so that overall download time prolong on the contrary It is long.
It will be recognized by those of ordinary skill in the art that weight fragmentation threshold Lt is set to 1Mb merely for the sake of illustration here Purpose, be not meant to the restriction of counterweight fragmentation threshold.Those skilled in the art can set the threshold value according to actual needs.
If judging in step S210, Lm is more than Lt (the "Yes" branch in step S210), as shown in Fig. 2 in step In S230, judge whether theoretical residue download time Ct accelerates duration Cs more than theoretical minimum.Judging the Ct no more than feelings of Cs Under condition (the "No" branch in step S230), then method 200 (step S290) is exited.
Here, average speed of download Sv of remaining download size Lm/ of theoretical remaining download time Ct=, and theoretical minimum acceleration Duration Cs Cvs time-consuming to average connection is related.Specifically, Cs=Cv+Cm, Cm is speed-raising threshold value here, for meeting on theory of representation Produce the most short download time of speed-increasing effect.In one example, Cm can be set as 5 seconds.In other words, open one in theory New thread, at least will can download more than 5 seconds, can just begin with speed-increasing effect.
In the present embodiment, it is contemplated that open the junction loss and/or speed-raising threshold value of new thread, it is to avoid in remaining download Amount is less and/or opens new thread in the case that remaining download time is shorter so that long actual on the contrary extend because connection is time-consuming Overall download time.
If judging in step S230, Ct is more than Cs (the "Yes" branch in step S230), as shown in Fig. 2 method 200 is entered Enter new thread and open step S250.That is, processor 130 in response to judging to meet new thread and set up condition, it is determined that open one it is new Thread.
Such as the step of Fig. 2 shown in S270, processor 130 determines the download paper interval of new thread, and adjusts also in execution The download paper interval of other threads of downloading task.
In one embodiment of the invention, processor 130 is downloaded the part of the most thread Tm of size by current residual Downloading task is reassigned to new thread.Specifically, the latter half of the remaining downloading task of Tm is distributed to into new thread.
In further embodiment of the present invention, processor 130 can be configured to calculate for the reserved big of new thread Little Ls=averagely connects time-consuming Cv × average speed of download Sv.Reserved size Ls refers to that opening new thread in theory carries out network In the time-consuming process of request, former thread Tm still is continuing to download, and Ls is exactly the file size downloaded in this period in theory.
Then, processor 130 sets downloading task as (Lm-Ls)/2 for new thread, and correspondingly adjusts thread Tm's Download interval.
After execution of step S270, method 200 is downloaded in response to another thread and completes and return to step S210, Continuing above-mentioned thread of setting up and judging that step and new thread open step, whole file to be downloaded is completed until downloading, method 200 is tied Beam.
In order to more clearly from illustrate the principle of the present invention, the multi-thread of the present invention is described below with reference to an instantiation Journey download mechanism realizes process.
Assume that file to be downloaded size is 300Mb, divide three sections of threads T1, T2 and T3 to be downloaded, each self-corresponding download Interval is A [0-100Mb], B [100Mb-200Mb] and C [200Mb-300Mb] respectively.
Step 1, the network request connection of record thread T1, T2 and T3 is time-consuming respectively, and calculates the time-consuming Cv of average connection.Point Other record thread T1, T2 and T3 speed of download at the appointed time in (for example, 10 seconds), and calculate average speed of download Sv.For It is easy to explanation, assume in this example that Cv=1s (second), Sv=1Mb/s (million/second).
Step 2, when a certain thread (for example, T2) download is completed, enters segment logic again.Traversal T1, T2 and T3's Sets of threads, determines that current residual downloads most that root thread of size, it is assumed that for T3, and the current residual of T3 is downloaded size It is defined as Lm, it is assumed here that Lm=56Mb.
Step 3, judges that Lt, whether more than Lt, is set as 1Mb by remaining size Lm in this example.If it is determined that Lm is not more than 1Mb, then exit the segment logic again of the present invention.If it is determined that Lm is more than 1Mb, then logic proceeds to step 4.
Step 4, calculates average speed of download Sv of remaining download size Lm/ of theoretical residue download time Ct=.
Step 5, calculates theoretical minimum acceleration duration Cs=and averagely connects time-consuming Cv+ speed-raisings threshold value Cm.In this example, Cm can To be set as 5 seconds.Therefore, in this example, theoretical minimum acceleration duration Cs=1s+5s=6s (second).
Step 6, judges whether theoretical residue download time Ct accelerates duration Cs more than theoretical minimum, i.e. 6 seconds.If it is determined that Ct is not more than 6 seconds, then exit the segment logic again of the present invention.If it is determined that Ct is more than 6 seconds, then proceed to step 7.
Step 7, calculates reserved size Ls=and averagely connects time-consuming Cv × average speed of download Sv.In this example, Ls=1s × 1Mb/s=1Mb.
Step 8, open new thread T4, and determine new thread download be (Lm-Ls)/2=(56Mb-6Mb)/2= 25Mb.It is then determined the download interval of new thread T4 is D [275-300Mb], while the download for adjusting thread T3 is interval for C ' [200Mb-275Mb]。
Step 9, continues waiting for another thread download and completes, then return to step 2, sequentially repeat above-mentioned steps 2-8, the download until completing whole file.
Using this method, when solving multithreading segmentation download, different threads go out because of factors such as network condition, internal memory performances Download when existing different and complete, the Thread Count of actual participation download is fewer and feweri and reduce down in the remaining download time caused Carry the problem of speed so that reasonably keep original Thread Count to carry out multithreading download as far as possible, be achieved in speed of download Maximize, and while keep speed of download stable.
Fig. 3 has gone out the functional block diagram of file multithreading download apparatus according to an embodiment of the invention 300.Multithreading is downloaded The functional module of device 300 being implemented in combination in by hardware, software or the hardware and software for realizing the principle of the invention, for example Realized by the one or more processors 130 in the computing device 100 shown in Fig. 1.It will be appreciated by those skilled in the art that , the functional module described in Fig. 3 can combine or be divided into submodule, so as to realize the original of foregoing invention Reason.Therefore, description herein can support to functions described herein module it is any possible combination or divide or Further limit.
With reference to Fig. 3, in order to maximize speed of download, multithreading download apparatus 300 is configured to include setting up thread judgement Unit 310 and new thread opening unit 330.File to be downloaded is divided into N number of paper interval, and each paper interval corresponds to one Bar download thread Ti, wherein i=1N, N are the natural number more than 1.
Although it is pointed out that in practice would generally be by file to be downloaded decile, each paper interval for being divided Size it is not necessarily impartial, the size of the corresponding paper interval of each bar download thread can be adjusted as needed.
It may also be noted that the Thread Count N that segmentation is downloaded not is the bigger the better.N is bigger, and performance cost is also bigger, network Connection is time-consuming also more, actually can not necessarily realize the maximization of speed of download.In practice, network rings can be considered The factors such as border, internal memory performance determine the Thread Count N that segmentation is downloaded.
Set up the situation that thread judging unit 310 is configured to corresponding downloading task be completed and exited in a thread Under, judge whether that meeting new thread sets up condition.
In one embodiment of the invention, set up thread judging unit 310 to be configured to according to specified conditions Factor, judges whether that meeting new thread sets up condition.Specified conditions factor designated herein includes arbitrary in following factor Individual or multiple combination:It is remaining to download size Lm;All N bars threads average speed of download Sv within a specified time;And institute There is the time-consuming Cv of average connection of the N bars thread when network connection is asked.
In one embodiment of the invention, setting up thread judging unit 310 also includes:It is remaining to download acquiring size module 311, the respective current residual of thread for being configured to obtain all unfinished downloading tasks downloads size;Subject thread determining module 313, it is configured to determine that current residual downloads the most thread Tm of size;And remaining download size determining module 315, it is configured to The corresponding current residuals of the thread Tm by determined by are downloaded and are sized to remaining download size Lm.
In one embodiment of the invention, the new thread condition of setting up includes any one of following or multinomial:Under residue Size Lm is carried more than weight fragmentation threshold Lt;Accelerate duration Cs more than theoretical minimum with theoretical residue download time Ct, wherein, it is theoretical Remaining download time Ct=is remaining to download average speed of download Sv of size Lm/, and theoretical minimum accelerates duration Cs and is averagely connected consumption When Cv it is related.In one embodiment, theoretical minimum acceleration duration Cs is also related to speed-raising threshold value.
In the present embodiment, it is contemplated that open the junction loss and/or speed-raising threshold value of new thread, it is to avoid in remaining download Amount is less and/or opens new thread in the case that remaining download time is shorter so that long actual on the contrary extend because connection is time-consuming Overall download time.
Judge that meeting new thread sets up condition in response to setting up thread judging unit 310, new thread opening unit 330 is configured To open a new thread and redistributing thread downloading task.
In one embodiment of the invention, new thread opening unit 330 includes weight segmentation module 331, and being configured to ought The front remaining part downloading task for downloading the most thread Tm of size distributes to the new thread of unlatching.
In further embodiment of the present invention, weight segmentation module 331 includes:Reserved size computing module 333, is configured to Calculating averagely connects time-consuming Cv × average speed of download Sv for reserved size Ls=of new thread;With downloading task setup module 335, it is configured to set the downloading task for being directed to new thread as (Lm-Ls)/2, and it is interval correspondingly to adjust the download of thread Tm.
In one embodiment of the invention, multithreading download apparatus 300 also includes repeating enabling unit 350, is configured to So that setting up 330 repetitive operation of thread judging unit 310 and new thread opening unit, whole text to be downloaded is completed until downloading Part.
In sum, using the multithreading method for down loading and device and computing device of the present invention so that whenever a thread When completing to download, constraint judgement is carried out according to correlative factor, and a new thread is opened in the case where condition is met, and The part downloading task of the current thread for not completing and downloading is undertaken using the new thread, multithreading is thus solved different at present It is fewer and feweri and reduce the problem of speed of download that load completes the Thread Count that causes so that reasonably keeps original line as far as possible Number of passes carries out multithreading download, so as to realize that speed of download is maximized, and while keeps speed of download stable.
Additionally, the method according to the invention is also implemented as a kind of computer program, the computer program include for The computer program code instruction of the above steps limited in the said method for performing the present invention.Or, it is of the invention Method is also implemented as a kind of computer program, and the computer program includes computer-readable medium, in the meter It is stored with calculation machine computer-readable recording medium for performing the computer program of above-mentioned functions limited in the said method of the present invention.Ability Field technique personnel will also understand is that, the various illustrative logical blocks, module, circuit and algorithm with reference to described by disclosure herein Step may be implemented as the combination of electronic hardware, computer software or both.
Flow chart and block diagram in accompanying drawing shows the possibility reality of the system and method for multiple embodiments of the invention Existing architectural framework, function and operation.At this point, each square frame in flow chart or block diagram can represent module, a journey A part for sequence section or code, a part for the module, program segment or code are used to realize regulation comprising one or more The executable instruction of logic function.It should also be noted that in some are as the realization replaced, in square frame, the function of institute's labelling also may be used To occur with the order different from institute's labelling in accompanying drawing.For example, two continuous square frames can essentially be performed substantially in parallel, They can also be performed sometimes in the opposite order, and this is depending on involved function.It is also noted that block diagram and/or stream The combination of each square frame and block diagram and/or the square frame in flow chart in journey figure, can use function or the operation for performing regulation Special hardware based system realizing, or can be realized with the combination of specialized hardware and computer instruction.
It is described above various embodiments of the present invention, described above is exemplary, and non-exclusive, and It is not limited to disclosed each embodiment.In the case of the scope and spirit without departing from illustrated each embodiment, for this skill For the those of ordinary skill in art field, many modifications and changes will be apparent from.The selection of term used herein, purport Best explaining principle, practical application or the improvement to the technology in market of each embodiment, or make the art Other those of ordinary skill are understood that each embodiment disclosed herein.

Claims (15)

1. the multithreading method for down loading of a kind of file, wherein file to be downloaded are divided into N number of paper interval, each described file Interval to correspond to download thread Ti, wherein i=1N, N are more than 1, and the multithreading method for down loading includes:
Set up thread and judge step, in the case of exiting for corresponding downloading task being completed in a thread, judge whether Meet new thread and set up condition;With
New thread opens step, in response to judging that meeting the new thread sets up condition, opening a new thread again Distribution thread downloading task.
2. multithreading method for down loading according to claim 1, wherein, it is described to judge whether that meeting new thread sets up condition Step includes:
According to specified conditions factor, judge whether that meeting new thread sets up condition, wherein the specified conditions factor include with The combination of any one or more in lower:
It is remaining to download size Lm;
All N bars threads average speed of download Sv within a specified time;And
The time-consuming Cv of average connection of all N bars threads when network connection is asked.
3. multithreading method for down loading according to claim 2, wherein, it is described to judge whether that meeting new thread sets up condition Step also includes:
The respective current residual of thread for obtaining all unfinished downloading tasks downloads size;
Determine that current residual downloads the most thread Tm of size;And
The corresponding current residuals of the thread Tm by determined by are downloaded and are sized to remaining download size Lm.
4. multithreading method for down loading according to claim 3, wherein, the new thread condition of setting up include it is following in appoint One or more:
Remaining size Lm of downloading is more than weight fragmentation threshold Lt;With
Theoretical residue download time Ct accelerates duration Cs more than theoretical minimum, wherein, theoretical residue download time Ct=remains Remaining to carry average speed of download Sv of size Lm/, the theoretical minimum accelerates duration Cs Cvs time-consuming to average connection related.
5. the multithreading method for down loading according to claim 3 or 4, wherein, one new thread of the unlatching is simultaneously redistributed The step of thread downloading task, includes:
The part downloading task that current residual downloads the most thread Tm of size is distributed to into the new thread.
6. multithreading method for down loading according to claim 5, wherein, it is described that current residual is downloaded into the most thread of size The step of part downloading task of Tm distributes to the new thread includes:
Calculating averagely connects time-consuming Cv × average speed of download Sv for reserved size Ls=of the new thread;With
The downloading task for being directed to the new thread is set as (Lm-Ls)/2, and it is interval correspondingly to adjust the download of the thread Tm.
7. multithreading method for down loading according to any one of claim 1 to 4, also includes:
Repeat the thread of setting up and judge that step and the new thread open step, entirely described treating down is completed until downloading Published article part.
8. the multithreading download apparatus of a kind of file, wherein file to be downloaded are divided into N number of paper interval, each described file Interval to correspond to download thread Ti, wherein i=1N, N are more than 1, and the multithreading download apparatus includes:
Thread judging unit being set up, being configured to corresponding downloading task to be completed in a thread and in the case of exiting, judgement is It is no to meet new thread and set up condition;With
New thread opening unit, is configured in response to judging that meeting the new thread sets up condition, opens a new thread and lays equal stress on New distribution thread downloading task.
9. multithreading download apparatus according to claim 8, wherein, the thread judging unit of setting up is further configured Be, according to specified conditions factor, to judge whether that meeting new thread sets up condition, wherein the specified conditions factor include it is following In the combination of any one or more:
It is remaining to download size Lm;
All N bars threads average speed of download Sv within a specified time;And
The time-consuming Cv of average connection of all N bars threads when network connection is asked.
10. multithreading download apparatus according to claim 9, wherein, the thread judging unit of setting up also includes:
Remaining to download acquiring size module, the respective current residual of thread for being configured to obtain all unfinished downloading tasks is downloaded Size;
Subject thread determining module, is configured to determine that current residual downloads the most thread Tm of size;And
It is remaining to download size determining module, it is configured to the corresponding current residual downloads of the thread Tm by determined by and is sized to institute State remaining download size Lm.
11. multithreading download apparatus according to claim 10, wherein, the new thread condition of setting up include it is following in Any one is multinomial:
Remaining size Lm of downloading is more than weight fragmentation threshold Lt;With
Theoretical residue download time Ct accelerates duration Cs more than theoretical minimum, wherein, theoretical residue download time Ct=remains Remaining to carry average speed of download Sv of size Lm/, the theoretical minimum accelerates duration Cs Cvs time-consuming to average connection related.
The 12. multithreading download apparatus according to claim 10 or 11, wherein, the new thread opening unit includes:
Weight segmentation module, is configured to distribute to the part downloading task that current residual downloads the most thread Tm of size described new Thread.
13. multithreading download apparatus according to claim 12, wherein, the heavy segmentation module includes:
Reserved size computing module, is configured to calculate reserved size Ls=for the new thread and averagely connects time-consuming Cv × flat Equal speed of download Sv;With
Downloading task setup module, is configured to set the downloading task for being directed to the new thread as (Lm-Ls)/2, and correspondingly adjusts The download of the whole thread Tm is interval.
The 14. multithreading download apparatus according to any one of claim 8 to 11, also include:
Repeat enabling unit, be configured so that it is described set up thread judging unit and the new thread opening unit repetitive operation, The whole file to be downloaded is completed until downloading.
A kind of 15. computing devices, including:
Network interface, the network interface enable the computing device to carry out the multi-thread of file via one or more networks Journey is downloaded;
Memorizer, is stored in which memory by the file that the network interface is downloaded;And
One or more processors, are connected with the network interface and the memorizer, and one or more of processors are matched somebody with somebody It is set to and file to be downloaded is divided into into multiple paper intervals, each described paper interval corresponds to a download thread, and performs Hereinafter operate:
Corresponding downloading task is completed in a thread and in the case of exiting, judge whether that meeting new thread sets up condition;With
In response to judging that meeting the new thread sets up condition, opens a new thread and redistributes thread downloading task.
CN201611048274.3A 2016-11-23 2016-11-23 Multithreading method for down loading and device and calculating equipment Active CN106550042B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611048274.3A CN106550042B (en) 2016-11-23 2016-11-23 Multithreading method for down loading and device and calculating equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611048274.3A CN106550042B (en) 2016-11-23 2016-11-23 Multithreading method for down loading and device and calculating equipment

Publications (2)

Publication Number Publication Date
CN106550042A true CN106550042A (en) 2017-03-29
CN106550042B CN106550042B (en) 2019-08-23

Family

ID=58395755

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611048274.3A Active CN106550042B (en) 2016-11-23 2016-11-23 Multithreading method for down loading and device and calculating equipment

Country Status (1)

Country Link
CN (1) CN106550042B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108270871A (en) * 2018-01-29 2018-07-10 广东五科技股份有限公司 The file block method for down loading and device of a kind of client
CN108900638A (en) * 2018-08-08 2018-11-27 陈若天 A method of ensuring that full bandwidth uses in the case where not interrupting concurrent asynchronous connection
CN109857545A (en) * 2018-12-29 2019-06-07 华为技术有限公司 A kind of data transmission method and device
CN111787105A (en) * 2020-07-01 2020-10-16 深圳市有方科技股份有限公司 File transmission method and device, computer equipment and storage medium
CN114338657A (en) * 2022-03-15 2022-04-12 北京搜狐新动力信息技术有限公司 Video file downloading method and device, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120005244A1 (en) * 2010-01-29 2012-01-05 Code Systems Corporation Method and system for permutation encoding of digital data
CN103237049A (en) * 2013-03-18 2013-08-07 北京易华录信息技术股份有限公司 File transfer method and device
CN103631569A (en) * 2013-12-23 2014-03-12 百度在线网络技术(北京)有限公司 Download method and download device
CN103634383A (en) * 2013-11-21 2014-03-12 北京奇虎科技有限公司 Mobile terminal-based multi-link subsection downloading method and mobile terminal
CN107786583A (en) * 2016-08-24 2018-03-09 中兴通讯股份有限公司 A kind of document down loading method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120005244A1 (en) * 2010-01-29 2012-01-05 Code Systems Corporation Method and system for permutation encoding of digital data
CN103237049A (en) * 2013-03-18 2013-08-07 北京易华录信息技术股份有限公司 File transfer method and device
CN103634383A (en) * 2013-11-21 2014-03-12 北京奇虎科技有限公司 Mobile terminal-based multi-link subsection downloading method and mobile terminal
CN103631569A (en) * 2013-12-23 2014-03-12 百度在线网络技术(北京)有限公司 Download method and download device
CN107786583A (en) * 2016-08-24 2018-03-09 中兴通讯股份有限公司 A kind of document down loading method and device

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108270871A (en) * 2018-01-29 2018-07-10 广东五科技股份有限公司 The file block method for down loading and device of a kind of client
CN108900638A (en) * 2018-08-08 2018-11-27 陈若天 A method of ensuring that full bandwidth uses in the case where not interrupting concurrent asynchronous connection
CN109857545A (en) * 2018-12-29 2019-06-07 华为技术有限公司 A kind of data transmission method and device
CN109857545B (en) * 2018-12-29 2021-09-14 华为技术有限公司 Data transmission method and device
CN111787105A (en) * 2020-07-01 2020-10-16 深圳市有方科技股份有限公司 File transmission method and device, computer equipment and storage medium
CN114338657A (en) * 2022-03-15 2022-04-12 北京搜狐新动力信息技术有限公司 Video file downloading method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN106550042B (en) 2019-08-23

Similar Documents

Publication Publication Date Title
CN106550042A (en) Multithreading method for down loading and device and computing device
Yuan et al. Time-aware multi-application task scheduling with guaranteed delay constraints in green data center
JP2022515302A (en) Methods and equipment for training deep learning models, electronic devices, computer-readable storage media and computer programs
CN105260237B (en) The task scheduling system and its dispatching method of heterogeneous polynuclear platform
CN109144699A (en) Distributed task dispatching method, apparatus and system
WO2016107488A1 (en) Streaming graph optimization method and apparatus
CN106874094A (en) timed task processing method, device and computing device
Shokripour et al. New method for scheduling heterogeneous multi-installment systems
CN103593323A (en) Machine learning method for Map Reduce task resource allocation parameters
CN111274036A (en) Deep learning task scheduling method based on speed prediction
Wang et al. Joint server assignment and resource management for edge-based MAR system
CN105808341B (en) A kind of methods, devices and systems of scheduling of resource
Xin et al. A load balance oriented cost efficient scheduling method for parallel tasks
CN108986063A (en) The method, apparatus and computer readable storage medium of gradient fusion
CN110262847A (en) Application program launching accelerated method, device and machine readable storage medium
CN106325976B (en) A kind of rendering task scheduling processing method and server
CN106775949A (en) A kind of Application of composite feature that perceives migrates optimization method online with the virtual machine of the network bandwidth
CN113094159A (en) Data center job scheduling method, system, storage medium and computing equipment
WO2021115082A1 (en) Job scheduling method and job scheduling apparatus
Celik et al. A novel simulated annealing-based optimization approach for cluster-based task scheduling
US11531565B2 (en) Techniques to generate execution schedules from neural network computation graphs
CN110290228A (en) A kind of internet protocol address distribution method and device
Kang et al. Scheduling multiple divisible loads in a multi-cloud system
Ta FC 2: cloud-based cluster provisioning for distributed machine learning
Lu et al. Service deployment and scheduling for improving performance of composite cloud services

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
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20200901

Address after: 310052 room 508, floor 5, building 4, No. 699, Wangshang Road, Changhe street, Binjiang District, Hangzhou City, Zhejiang Province

Patentee after: Alibaba (China) Co.,Ltd.

Address before: 510627 Guangdong city of Guangzhou province Whampoa Tianhe District Road No. 163 Xiping Yun Lu Yun Ping square B radio tower 15 layer self unit 02

Patentee before: GUANGZHOU UC NETWORK TECHNOLOGY Co.,Ltd.

TR01 Transfer of patent right