mirror of
https://github.com/curl/curl.git
synced 2026-08-25 19:53:32 +03:00
lib: keep timestamp in easy handle
Use `data->progress.now` as the timestamp of proecssing a transfer. Update it on significant events and refrain from calling `curlx_now()` in many places. The problem this addresses is a) calling curlx_now() has costs, depending on platform. Calling it every time results in 25% increase `./runtest` duration on macOS. b) we used to pass a `struct curltime *` around to save on calls, but when some method directly use `curx_now()` and some use the passed pointer, the transfer experienes non-linear time. This results in timeline checks to report events in the wrong order. By keeping a timestamp in the easy handle and updating it there, no longer invoking `curlx_now()` in the "lower" methods, the transfer can observer a steady clock progression. Add documentation in docs/internals/TIME-KEEPING.md Reported-by: Viktor Szakats Fixes #19935 Closes #19961
This commit is contained in:
parent
425a2aa1af
commit
2de22a00c7
67 changed files with 598 additions and 458 deletions
|
|
@ -33,6 +33,7 @@
|
|||
#include "multiif.h"
|
||||
#include "curlx/timeval.h"
|
||||
#include "multi_ev.h"
|
||||
#include "progress.h"
|
||||
#include "select.h"
|
||||
#include "uint-bset.h"
|
||||
#include "uint-spbset.h"
|
||||
|
|
@ -480,7 +481,8 @@ static struct easy_pollset *mev_get_last_pollset(struct Curl_easy *data,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static CURLMcode mev_assess(struct Curl_multi *multi, struct Curl_easy *data,
|
||||
static CURLMcode mev_assess(struct Curl_multi *multi,
|
||||
struct Curl_easy *data,
|
||||
struct connectdata *conn)
|
||||
{
|
||||
struct easy_pollset ps, *last_ps;
|
||||
|
|
@ -536,7 +538,8 @@ CURLMcode Curl_multi_ev_assess_conn(struct Curl_multi *multi,
|
|||
}
|
||||
|
||||
CURLMcode Curl_multi_ev_assess_xfer_bset(struct Curl_multi *multi,
|
||||
struct uint32_bset *set)
|
||||
struct uint32_bset *set,
|
||||
struct curltime *pnow)
|
||||
{
|
||||
uint32_t mid;
|
||||
CURLMcode result = CURLM_OK;
|
||||
|
|
@ -544,8 +547,10 @@ CURLMcode Curl_multi_ev_assess_xfer_bset(struct Curl_multi *multi,
|
|||
if(multi && multi->socket_cb && Curl_uint32_bset_first(set, &mid)) {
|
||||
do {
|
||||
struct Curl_easy *data = Curl_multi_get_easy(multi, mid);
|
||||
if(data)
|
||||
if(data) {
|
||||
Curl_pgrs_now_at_least(data, pnow);
|
||||
result = Curl_multi_ev_assess_xfer(multi, data);
|
||||
}
|
||||
} while(!result && Curl_uint32_bset_next(set, mid, &mid));
|
||||
}
|
||||
return result;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue