Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129232 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 1EDF31A00BC for ; Sat, 15 Nov 2025 14:41:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1763217691; bh=bHjYrWf8KNq/9rrTb3Z+I+fgLoJ2Yd/Xdm8UGpbwChI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=lm1xiFefP4xZoyBnqWn1XyAojn+lsxm9L3A2nLLXMywKfw9YvFvQ5PbChqb3TeTPx PE/cYvN1nLwHT4nrkUiIi0i8ItDshLNBhQMmqOYoE3/yWX0Jzuh9jMSNL8pfwYvdFn jrbcCXYqT4Zaz3CpH0HRyYNXMgRfuzB8RZtg9Y+xfiVZIiMuOblJXgdEo14XnScgb+ DF1LpvcDCiWCTta62WNlF1B7nUR74BWJO0coMuCYI/L/V7CAe3SoIcr9Yi+8RdlMaL xWIvp2tst2S9whlwX6C8zwOBANikpU1373ZND87Aoef48hGK3Vt2ZUB+WdE9RU29Zs XRrBZ+JIrnvaQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DD67F1804BC for ; Sat, 15 Nov 2025 14:41:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-vs1-f51.google.com (mail-vs1-f51.google.com [209.85.217.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 15 Nov 2025 14:41:27 +0000 (UTC) Received: by mail-vs1-f51.google.com with SMTP id ada2fe7eead31-5dfc2a9b79fso750269137.0 for ; Sat, 15 Nov 2025 06:41:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763217682; x=1763822482; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=SlYSYLB1wE8bx3c90tJdhxqTUAE0k/gVsFQznRkbXOc=; b=TMZgY98PykNH/BXH3CjougvYS90EMY70Lh/tilPhoRWLVdhyswIrd0eZF+5hTj8L0i wMMJjQv24SU7lTeTapXKXO1ienckFU1Uy1q15awHlvzb7tR/V7SheV6B5cj8T89NDkmX el1/VWQiGyivtl7+X/obA8AYAZyQZlki+7imyrZtGc0V4W7Xg2qAQfSaNl9owkTacSFQ II/G2+WmCl3UN7O5dI8ePrDG9FIUSrkN8nh7RtZh3dNm7gKoVX7JCPYgcfuGd6K94lCS y9QvWe5+owaavvWmigmFtcSNz+sDC6sik3YMm4knzsYe5tVF8roz3AwkjnUAVrGE3f1V qhcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763217682; x=1763822482; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=SlYSYLB1wE8bx3c90tJdhxqTUAE0k/gVsFQznRkbXOc=; b=bKN4PsJtWLaa86PruMYlxNrs8rBPGbXztQS0CxwGfx7F2sx0GORuoxaLj+GN417gAD 0ukNB/NQzsiDe859ttryZEzE8quGtF4hwfdHclt72r7Qj7n3y/NALKngG4vcRZBhaUBZ cBATtvHsRjjsrYCauK63W5eTsSPVN1aNP8kK9hMKBeQm9n9jp1X1YmsIl5BQ6JzcI4s4 S0h+QTPYguFmeLXrx+TNCAw4VPoYIUTEBnpUFF7V/NnZimD8R8G7Sq52GnIeL/D5EXAK V0VZA2zbMbswACM79Ef0qHwwugcKSVPoRPh225sKffQzLomA+wEZj70u8sE6nwhglZVw zj2A== X-Gm-Message-State: AOJu0Yyt4QsxxqO3RQhNbkbgTNMFV1Ir+fDoFJyCN6pXGM/KQyJaMzs5 VueNKP13pOlPhG1gTRKyfHPXorDfcQ9wi+JA2OI33g4K+4Q51Ab+NsU62U6A+q+nyB5zN/17ugJ 2GoP92zETN81TobCt63++c/palMNslAU= X-Gm-Gg: ASbGncvnJeOHwuMYEw/gQqSkBXngdvPLUzTJJUlBg/CPANmXItTbxvtr7TcxoqlUPdE z5IOCEMY6X3z4E59OHgKSWKLj9ybC3bAcIDX0IJYt4TMQkb5Xb8RZesYPLoSzKnYJZxSbFaMZkG XHRRWtPdF4wNZmjErdVXx4CyCCkOZ68R2I3+0dbhlcoFWe0L+u0I1q6JDUhGeKJ9NSTIVWyianX W8Fqy8dv/bemiAZVXt+3LI/qpOmwOD8zCu5+yrWL9dTkFjaqD74EIByikUvzFXz9hwEvtM8KL+p 75cqXf7i1D0liOz2PIkrE2ijqCo= X-Google-Smtp-Source: AGHT+IE16jlXSaRxPK2N3n5hT8A5vvKlFKADnMBThvr9kJQEssWr+vfaubnQqdyEYEPszuqLholeSVhrD7NVDAj9u/E= X-Received: by 2002:a05:6102:26d1:b0:5dd:84f1:b51a with SMTP id ada2fe7eead31-5dfc5b99ed7mr2481423137.43.1763217681752; Sat, 15 Nov 2025 06:41:21 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <6618a91c-5393-4f40-88b5-b5041ee09deb@app.fastmail.com> <3e0cf0a1-c1a3-4e05-97ba-0eeb7f559a53@app.fastmail.com> In-Reply-To: <3e0cf0a1-c1a3-4e05-97ba-0eeb7f559a53@app.fastmail.com> Date: Sat, 15 Nov 2025 16:41:11 +0200 X-Gm-Features: AWmQ_bnrefZzYrqU8JlR3uQ8V8-hRrU7zPSI4Dy8r3O3mXIOwUj9qVelsDFjW9Y Message-ID: Subject: Re: [PHP-DEV] Re: PHP True Async RFC Stage 5 To: Rob Landers Cc: php internals , Jakub Zelenka , Larry Garfield Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: edmond.ht@gmail.com (Edmond Dantes) Hello. > Based on the conversation so far, I=E2=80=99d imagine the list to look so= mething like: Yes, that=E2=80=99s absolutely correct. When a programmer uses an operation that would normally block the entire thread, control is handed over to the Scheduler instead. The suspend function is called inside all of these operations. > If that=E2=80=99s the intended model, it=E2=80=99d help to have that spel= led out directly; it makes it immediately clear which functions can or will= suspend and prevents surprises. In the Async implementation, it will be specified which functions are suppo= rted. > I also think the RFC needs at least minimal wording about scheduler guara= ntees, even if the details are implementation-specific. The Scheduler guarantees that a coroutine will be invoked if it is in the q= ueue. > For example, is the scheduler run-to-suspend? FIFO or round-robin wakeup= ? And non-preemptive behaviour only appears here in the thread. It isn=E2= =80=99t mentioned in the RFC itself. In Go, for example, when it was still cooperative, these details were also not part of any public contract. The only guarantee Go provided was that a coroutine would not be interrupted arbitrarily. The same applies to this RFC: coroutines are interrupted only at designated suspension points. However, neither Go nor any other language exposes the internal details of the Scheduler as part of a public contract, because those details may change without notice. > That=E2=80=99s important for people writing long, CPU-bound loops, since = nothing will interrupt them unless they explicitly yield. Hypothetically, in the future it may become possible to interrupt loops, just like Go eventually did. This would likely require an additional RFC. PHP does have the ability to interrupt a loop at any point, but most likely only for terminating execution. This RFC does nothing of the sort. > Lastly, cancellation during a syscall is still unclear. If a coroutine is= cancelled while something like fwrite() or a DB write is in progress, what= should happen? > Does fwrite() still return the number of bytes written? Does it throw? Fo= r write-operations in particular, this affects whether applications can mai= ntain a consistent state. If the write operation is interrupted, the function will return an error according to its contract. In this case, it will return false. > Clarifying these points would really help people understand how to reason= about concurrency with this API. This is described in the document. There is, of course, a nuance regarding extended error descriptions, but at the moment no such changes are planned.