Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109959 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 15672 invoked from network); 2 May 2020 02:57:08 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 May 2020 02:57:08 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7473B1804C2 for ; Fri, 1 May 2020 18:31:11 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8075 40.64.0.0/10 X-Spam-Virus: No X-Envelope-From: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-oln040092003084.outbound.protection.outlook.com [40.92.3.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 1 May 2020 18:31:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dzygOn2apP8eyEZR+RdJScs1+T8qox3hWul9qchE7Hr9wWuqI711qq9lmwOh9jXVbXqQMUtwmEJNoCbeFFETw2iBdcFAg3Yci1xqDBb/9l31+8E1WAEh8H9zvFOjQOB39JPGUV2IEVN1QGSl+ama588l2XfRa0uNWH+5ifad7cZCbJQv+aX/VXFFQTY120Ng0kSKX87b0vRb+3w5b5nH5u2/iiY56+6d58sB7J/W6iIJpnaqiziXj0Ga3ew+MTEcwiCv7cNGcFzpDO04DLs5Smsa95wtwP7YDHzrb3HZA8Thup6LRnG+QzDzYCwuYnz2DDvJ7dhxUFYMMcfBNYhYMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t/zs/ICOPzXb1EzSNaQiUp5Xbc6LmVUlBm6goTCquX0=; b=JOodRT+j2GJBUWTmk4jKOmXF4INuhOEbHrRFRmxCli8FWdec8Pg+GHF8JqytjnrTV6QjwYjeQ8pcQ1BALHiNOGkb2o2eAKOCcKJG7i6Lyi8Y9ZF9iZ8p/QHDEZNwqBdXjaCR/5MnaxDqpye+PxVIc5OtZEvV2oRn4AimUeFMAQiT6lJhcMtJYOzZM6MaRfi53eN0dy+zSeLrNz+dktIDSglWzoCyF051gVE2tYgA9wXVPyrk45bL+caLJI8EHd3uBhjgcIElE6egpLbR+W+d7rDPzSj9fpqf7qa4t4XAXuGdb4VQbvRMagjjd5O+7WG+WBh/CmhMxFc77wF/Ul9PWg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t/zs/ICOPzXb1EzSNaQiUp5Xbc6LmVUlBm6goTCquX0=; b=dtNite5RATtP0GaoCbEKtiaUA1dTvJL1A5cy9I//1l6w8GkPL78OY6rsF0wfokWz+SdL8i8rux6dJw0Vi7PazucVzObJfV/5E0D/7C4NB2BECuCpRFxgleppc9gNeix+en/aJKkhCavKU/cecJnKzeEfzIGtWmT9bLR4gckgcmrtHa3oBCp0+pw1/88qLcjC71b9aMHHnJe8OWn/mJWbOVOuU8GguH0grDT2l1eBi+4aN+MCeFp5kj9EkELS1DnkKDef3ezEDTvVP2CrGc2L5ATF+noKwGkJkF2PWl+X198qbOAfkzRe4QvS85jm3KbwwEPlLNHv0anfL5jRD8iLsw== Received: from BL2NAM02FT045.eop-nam02.prod.protection.outlook.com (10.152.76.60) by BL2NAM02HT191.eop-nam02.prod.protection.outlook.com (10.152.77.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.19; Sat, 2 May 2020 01:31:09 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:7e46::4d) by BL2NAM02FT045.mail.protection.outlook.com (2a01:111:e400:7e46::272) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.27 via Frontend Transport; Sat, 2 May 2020 01:31:09 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::e553:b74f:bf64:30c5]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::e553:b74f:bf64:30c5%4]) with mapi id 15.20.2958.027; Sat, 2 May 2020 01:31:09 +0000 To: "internals@lists.php.net" Thread-Topic: opcache.no_cache prototype: Opcode optimization without caching Thread-Index: AQHWIBy08PSXTztOe0qZL2sLDSo6BQ== Date: Sat, 2 May 2020 01:31:09 +0000 Message-ID: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:55C29B6774818E6AB79F6461BB2A465ECED4F167BBEC2B25F693673A53FF18D9;UpperCasedChecksum:98AE06A65359538D8B544130AC2F82954577AC74AF1EDED96A1C0FA1BB4007CC;SizeAsReceived:6913;Count:42 x-tmn: [Z3R/Lfm23fsP7zsPgKg4uhedn/8mGRG1qoBpnsuSOACC8J+6S0Rd9V5MsWaUYe6l] x-ms-publictraffictype: Email x-incomingheadercount: 42 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: ba787404-5cd1-4076-2bc0-08d7ee387dec x-ms-traffictypediagnostic: BL2NAM02HT191: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: lG9Zq3AYl5TNeFTkiLttFYJytcbXEUJHP7SQzLNYbqmgYI1abN/h0M/9LfbNFwceFc7RepGFzyAO7WDLG6LK7dpu4etUVfq2FHb/tc9O4W7kG+p4H8o/lP6Zy3pN7LrFq9l8xttfAslsbpFzYroFukaXhKVn6nCRmr79T9uNVMDO8SNwWrSrdH/hjk74bNDpRnA8GVHy44aCiU6FScJASXTWmw1h/jXv6XNk7HGJFiGCpEVpnamk4BMhOFZINyH7 x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR07MB6618.namprd07.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; x-ms-exchange-antispam-messagedata: 6IxGCdCR/C3ANvq0w7Hn3kgjrzWZOE+ObEN3svaGNCGgZoLTz6KAwWS2lT+XobRbfnSvYJfY6K+zLiKnUvZTgJWjwwalppFkarFErW+F48efYwnH65kCww56WyvYvpgdlQ8f6/aex/lTq1qyU3B+67mV6YBrC465ncVoARBsfGgJU5AJrrklZl02lJ90FfFKJOZjOcrF+6V8wdUosbml0g== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: ba787404-5cd1-4076-2bc0-08d7ee387dec X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 May 2020 01:31:09.2644 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2NAM02HT191 Subject: opcache.no_cache prototype: Opcode optimization without caching From: tysonandre775@hotmail.com (tyson andre) Hi internals,=0A= =0A= Currently, it isn't possible to enable optimizations without enabling cachi= ng.=0A= They should be orthogonal features - it's already possible to cache without= =0A= optimization passes (`opcache.optimization_level=3D0`)=0A= =0A= I have a prototype implementing this at https://github.com/php/php-src/pull= /5504 .=0A= Conceptually, this behaves like opcache.file_cache_only in that it optimize= s and doesn't use any shared memory, but doesn't actually save or load file= s.=0A= I wanted to measure interest in an RFC to add this to PHP, and on what form= this should take.=0A= (I've heard PR discussion is supposed to be for implementation details, so = I'm also creating an email thread)=0A= =0A= Being forced to either enable caching or file_cache_only causes these probl= ems:=0A= =0A= - For file_cache_only, users would be forced to manage the file cache,=0A= and users may not be confident in properly handling all potential edge ca= ses.=0A= =0A= (Running out of disk space, need to clear stale entries, concerns about o= pcode=0A= corruption not being fixed after restarting a process, etc)=0A= - The shared memory block uses up a lot of RAM when individual PHP processe= s=0A= are known to be long-lived and don't have a common memory address space.= =0A= (e.g. multiple long-lived php scripts managed by something that is not=0A= a php script (e.g. `supervisord`, daemons, tools run in the background in= =0A= IDEs, etc). Typical web server uses such as apache share a process space,= and would not use no_cache)=0A= =0A= The opcodes are duplicated in shmem, which wastes memory in use cases=0A= where they're stored in the cache but never retrieved.=0A= =0A= The default for opcache.memory_consumption is 128M.=0A= Even when this isn't used, the virtual memory to track the shared=0A= memory(shmem) segment seems to add 2MB extra per **independent** php proc= ess in=0A= "shared memory" segments (depending on OS settings?), reducing the free R= AM available for other processes.=0A= =0A= (starting a large number of php CLI scripts that sleep() in a loop,=0A= `free` (linux program to report free memory) reports that `shared`=0A= increases by 2MB per process without opcache.no_cache, but barely increas= es=0A= with opcache.no_cache=3D1=0A= =0A= On an unrelated PR https://github.com/php/php-src/pull/5097#issuecomment-57= 6421941=0A= Dmitry Stogov mentioned that=0A= =0A= > Also, it would be great to move optimizer and JIT into core, to make them= =0A= > available even without opcode caching.=0A= =0A= On the PR itself, Nikita Popov wrote https://github.com/php/php-src/pull/55= 04#issuecomment-622295467=0A= =0A= > I like the idea of having optimization without caching,=0A= > but the way to go about this is definitely moving the optimizer into Zend= =0A= > and making it available completely independently of the opcache extension= .=0A= > This has been "planned" for a long time, but never actually happened.=0A= =0A= - I think that creating a new setting along the lines of opcache.no_cache w= ould have a use case before and after such a refactoring,=0A= providing the benefits I mentioned for the use cases in the PR descriptio= n.=0A= This would continue to be have a use case even if the caching parts of op= cache.so moved into php's core=0A= (e.g. if that was done, and the caching module were loaded in php.ini=0A= as zend_extension=3Dopcache.so, there'd still be a use case for a configu= ration setting to override that default=0A= to disable caching for running individual programs)=0A= =0A= Users may strongly prefer for `opcache.enable`, `opcache.enable_cli`, and= `opcache.optimization_level` to continue controlling whether optimizations= are performed=0A= (so setting the combination of `opcache.enable=3D1`, `opcache.enable_cli= =3D1`, and a setting such as `opcache.no_cache=3D1` to optimize without cac= hing would make sense there)=0A= - If nobody's currently planning to work on moving the optimizer into Zend = (i.e. into php's core),=0A= then it may be several minor releases before it's possible to have optimi= zation without caching.=0A= - There may be unforeseen objections to moving the optimizer into Zend from= creators/users of profiling tools, debuggers, code coverage tools, etc.=0A= Hopefully not, but that'd depend on the proposed implementation details.= =0A= =0A= Thanks,=0A= - Tyson=