Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126581 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 qa.php.net (Postfix) with ESMTPS id A1CD11A00BC for ; Wed, 5 Mar 2025 16:55:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741193580; bh=/vOjlH/cQrzmajuwXx+Zl2rC5H+yH+HAk6NtGWjCtt8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=K+wJ3JHoFh9RgB9z7Wlp4mS92peCoC7lv8wwEwCnOA/VOPxHhTkHZdMsRZfitOLu9 azF6tE5nWAhEk+Ri/WXV0wW8/ebL7GMDOWxYHfIsxz/l65+NxKjbBCmowWRQ0R4N0X geZ8Glc2OH/Z4fhFnYbR4ELbYI0EAKPysE2YjBHkqjVGWVBxO93ALxfK8Dk1AzjxYq v0upTLE/324B1zGyc9er9DXPGtVtfGuH52oHp9MbysRVJZzqtvR3oK9nfD/HPTLMcX xUs/thkwcVkF+KnpNIITUBSPZhKGM4MYvdRPBmX93uskNCufYNXknZehDxZ4m7+RAg ZwPv6sg+f7PPg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 87B3E18004B for ; Wed, 5 Mar 2025 16:52:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: * X-Spam-Status: No, score=1.1 required=5.0 tests=BAYES_40,DMARC_NONE, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) (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 ; Wed, 5 Mar 2025 16:52:59 +0000 (UTC) Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-2b1a9cbfc8dso1812141fac.2 for ; Wed, 05 Mar 2025 08:55:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741193734; x=1741798534; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/vOjlH/cQrzmajuwXx+Zl2rC5H+yH+HAk6NtGWjCtt8=; b=QM6fte0pZGk78uLYDzYQ3ZFJhdsF4SOx5ADZ0XvZ57zhWhDljMT3AVUroDiup+5NA1 RVinAk/986JJefBJjyBDwlQcBSCVIOy5hIMSMfxs0tiN/NuXBNQnxcCiyKT8YXqmnmxN zZS5Waibjz/xvIKpgEuWUzCUCzm2GTHRmms0Okqktdc5mIV7K+p/AXsFcnRaQUFCP1YI WwH8HKG3dxlml/dUucD6jNOFPsjhAbpkl1GaEE25EtAPzNtXBTPe8me5FSZggY712oVY fJZVEuyrzqBOLjGkLlqgWBILHvSxFunSMafBhH8oLmfcFNfHNEB/7nRebddnI9Ckqjq8 C0Xg== X-Gm-Message-State: AOJu0YyD5CuCn+OHT43mCUYXP9OIMlTP1SZmS6LmGsBAUCIEuUKHrWFy FjO8yYUY+9F5S6o3MGwGtRvDdgNFIVStdcpmVMs+AFLTerB6jobnlhjagWreMZMF0L4C2IR9A5d 8mS2Pi4w+DfOa0qcKgPOazOI0AOD32A== X-Gm-Gg: ASbGncud/WbFl92o+dwC5j7/5jk6nxPX/eYB8X6JbF0i8Y87ld8vJs9tbtPL8JqQeW3 ghSe1XwXC7YNvos4hA+tzw9O1kthKscwWCnNzSK1+smfYicX5fBty+K2rw7g8gX5cjvihW1B4ID LttVuXm+jil0PReVxpmCZc1Kgf4g== X-Google-Smtp-Source: AGHT+IHXHw5u3ltb7Qu3bIb3WmhtcZw24SsB0aGB6CIslMmolR/siOR0U8dWTuyyss4KOL5ZV9S1Qob0PC8QZ3tut4c= X-Received: by 2002:a05:687c:3385:b0:2c2:3a7f:e702 with SMTP id 586e51a60fabf-2c23a7ff295mr351281fac.11.1741193734510; Wed, 05 Mar 2025 08:55:34 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 5 Mar 2025 17:55:23 +0100 X-Gm-Features: AQ5f1JqmdK2rieAW1OyXqCqIrhN8IdNtjy3Y7whdt7EJPowDs02xcU6Cv1M-FAo Message-ID: Subject: Re: [PHP-DEV] PHP True Async RFC To: Edmond Dantes Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="00000000000007e3aa062f9b421e" From: bukka@php.net (Jakub Zelenka) --00000000000007e3aa062f9b421e Content-Type: text/plain; charset="UTF-8" Hi, > > > I thought about this quite a bit and I think we should first try to > clarify the primary design that we want to go for. > > What I mean is whether we would like to ever support a true concurrency > (threads) in it. > > If we think it would be worth it (even thought it wouldn't be initially > supported), then we should take it into the account from the beginning and > add restrictions to prevent race conditions. > > > > If you mean multitasking, i.e., executing coroutines in different OS > threads, then this feature is far beyond the scope of this RFC and would > require significant changes to the PHP core (Memory manager first). > You might want to look to parallel extension as it's already dealing with that and mostly works - of course combination with coroutines will certainly complicate it but the point is that memory is not shared. > And even if we imagine that such changes are made, eliminating data races > without breaking the language is, to put it mildly, a questionable task > from the current perspective. > That's exactly what I meant is to make sure that there won't be any data races - it means use only channel communication (more below). > > Although this RFC raises the question of whether a concurrent version > without multitasking is worth implementing at all, my opinion is positive. > For PHP, this could be sufficient as a language primarily used in the > context of asynchronous I/O, whereas a multitasking version may never > happen. > > I didn't really mean to introduce it as part of this RFC. What I meant is to design the API so there is still possibility to add it in the future without risking various race condition in the code. It means primarily to put certain restrictions that will prevent it like limited access to global and passing anything by reference (including objects) to the running tasks. Regards Jakub --00000000000007e3aa062f9b421e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,<= /div>

>
>=C2=A0
I thought about this quite = a bit and I think we should first try to clarify the primary design that we= want to go for.
> What I mean is whether we would like to ever supp= ort a true concurrency (threads) in it.
> If we think it would be wo= rth it (even thought it wouldn't be initially supported), then we shoul= d take it into the account from the beginning and add restrictions to preve= nt race conditions.
>

If you mean multitasking, i.e., executing = coroutines in different OS threads, then this feature is far beyond the sco= pe of this RFC and would require significant changes to the PHP core (Memor= y manager first).

You might wan= t to look to parallel extension as it's already dealing with that and m= ostly works - of course combination with coroutines will certainly complica= te it but the point is that memory is not shared.
=C2=A0
And ev= en if we imagine that such changes are made, eliminating data races without= breaking the language is, to put it mildly, a questionable task from the c= urrent perspective.=C2=A0

That&= #39;s exactly what I meant is to make sure that there won't be any data= races - it means use only channel communication (more below).
= =C2=A0

Although this RFC raises the question of whether a = concurrent version without multitasking is worth implementing at all, my op= inion is positive. For PHP, this could be sufficient as a language primaril= y used in the context of asynchronous I/O, whereas a multitasking version m= ay never happen.=C2=A0


I didn't really mean to introduce it as part of this RFC. What I= meant is to design the API so there is still possibility to add it in the = future without risking various race condition in the code. It means primari= ly to put certain restrictions that will prevent it like limited access to = global and passing anything by reference (including objects) to the running= tasks.

Regards

Jakub
=C2=A0
--00000000000007e3aa062f9b421e--