mirror of
https://github.com/curl/curl.git
synced 2026-08-26 11:03:33 +03:00
cf-socket: make socket data_pending a nop
Eliminating the socket readability check in the socket connection filters for the 'data_pending' callback. Improves performance of handling of transfers, up to ~30%, depending on parallelism and response size. Whatever `data_pending()` once was, its semantics are now: "Is there anything buffered in the connection filters that needs receive?" Any checks of the socket's readability are done via `multi_wait()` and friends. Fix the one place in HTTP/1 proxy code that checked `data_pending()` and did an early return if false. Remove that check and actually try to receive data every time. Closes #17785
This commit is contained in:
parent
a487a4e4bd
commit
21ecc7e376
5 changed files with 116 additions and 85 deletions
|
|
@ -108,6 +108,28 @@ class RunProfile:
|
|||
f'stats={self.stats}]'
|
||||
|
||||
|
||||
class DTraceProfile:
|
||||
|
||||
def __init__(self, pid: int, run_dir):
|
||||
self._pid = pid
|
||||
self._run_dir = run_dir
|
||||
self._proc = None
|
||||
|
||||
def start(self):
|
||||
args = [
|
||||
'sudo', 'dtrace',
|
||||
'-x', 'ustackframes=100',
|
||||
'-n', f'profile-97 /pid == {self._pid}/ {{ @[ustack()] = count(); }} tick-60s {{ exit(0); }}',
|
||||
'-o', f'{self._run_dir}/curl.user_stacks'
|
||||
]
|
||||
self._proc = subprocess.Popen(args, text=True, cwd=self._run_dir, shell=False)
|
||||
assert self._proc
|
||||
|
||||
def finish(self):
|
||||
if self._proc:
|
||||
self._proc.terminate()
|
||||
|
||||
|
||||
class RunTcpDump:
|
||||
|
||||
def __init__(self, env, run_dir):
|
||||
|
|
@ -467,7 +489,8 @@ class CurlClient:
|
|||
timeout: Optional[float] = None,
|
||||
silent: bool = False,
|
||||
run_env: Optional[Dict[str, str]] = None,
|
||||
server_addr: Optional[str] = None):
|
||||
server_addr: Optional[str] = None,
|
||||
with_dtrace: bool = False):
|
||||
self.env = env
|
||||
self._timeout = timeout if timeout else env.test_timeout
|
||||
self._curl = os.environ['CURL'] if 'CURL' in os.environ else env.curl
|
||||
|
|
@ -476,6 +499,7 @@ class CurlClient:
|
|||
self._stderrfile = f'{self._run_dir}/curl.stderr'
|
||||
self._headerfile = f'{self._run_dir}/curl.headers'
|
||||
self._log_path = f'{self._run_dir}/curl.log'
|
||||
self._with_dtrace = with_dtrace
|
||||
self._silent = silent
|
||||
self._run_env = run_env
|
||||
self._server_addr = server_addr if server_addr else '127.0.0.1'
|
||||
|
|
@ -784,6 +808,9 @@ class CurlClient:
|
|||
profile = RunProfile(p.pid, started_at, self._run_dir)
|
||||
if intext is not None and False:
|
||||
p.communicate(input=intext.encode(), timeout=1)
|
||||
if self._with_dtrace:
|
||||
dtrace = DTraceProfile(p.pid, self._run_dir)
|
||||
dtrace.start()
|
||||
ptimeout = 0.0
|
||||
while True:
|
||||
try:
|
||||
|
|
@ -797,6 +824,8 @@ class CurlClient:
|
|||
ptimeout = 0.01
|
||||
exitcode = p.returncode
|
||||
profile.finish()
|
||||
if self._with_dtrace:
|
||||
dtrace.finish()
|
||||
log.info(f'done: exit={exitcode}, profile={profile}')
|
||||
else:
|
||||
p = subprocess.run(args, stderr=cerr, stdout=cout,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue