Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87733 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86670 invoked from network); 12 Aug 2015 21:16:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Aug 2015 21:16:10 -0000 Authentication-Results: pb1.pair.com header.from=ericsten@microsoft.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ericsten@microsoft.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain microsoft.com designates 65.55.169.127 as permitted sender) X-PHP-List-Original-Sender: ericsten@microsoft.com X-Host-Fingerprint: 65.55.169.127 mail-bl2on0127.outbound.protection.outlook.com Solaris 7 Received: from [65.55.169.127] ([65.55.169.127:48460] helo=na01-bl2-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 39/A1-03000-897BBC55 for ; Wed, 12 Aug 2015 17:16:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=x8MIe0ufA5umxuMA73dNKTuELWsX90TXfTCrMklzndw=; b=kgu4xMsjTOAV6wJW9iRvVSJRwVSWxG0lIRz7rbcwfAo8bY6BXVmEl7BfVigKtyeGPCe+g7U9FYVTkyNJCHiRd0PDiiZoQaOuMWlpf8sVWUlJNXdZ+7fvHMeNXLt3183e5wWTvo3Ns0U8/Ots7IfnJg9e2vb31PuHxS2y2m6V+1g= Received: from BN1PR03MB105.namprd03.prod.outlook.com (10.255.201.11) by BN1PR03MB107.namprd03.prod.outlook.com (10.255.201.17) with Microsoft SMTP Server (TLS) id 15.1.225.19; Wed, 12 Aug 2015 21:16:03 +0000 Received: from BN1PR03MB105.namprd03.prod.outlook.com ([169.254.8.122]) by BN1PR03MB105.namprd03.prod.outlook.com ([169.254.8.122]) with mapi id 15.01.0225.018; Wed, 12 Aug 2015 21:16:03 +0000 To: PHP Internals Thread-Topic: Q: Caching IS_REFERENCE zvals in PHP7? Thread-Index: AdDVQ5XEEy+IW8XTQFua/9jwxxIl7Q== Date: Wed, 12 Aug 2015 21:16:03 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=ericsten@microsoft.com; x-originating-ip: [2001:4898:80e8:5::20f] x-microsoft-exchange-diagnostics: 1;BN1PR03MB107;5:tKhH60MfaJoplm/lT/O2MeBwEL2u7GeUXCpQlwVrZY0GslFsN2mzmuc8PW585OcQsXYV3Szcx2m3mtuDt6OqXWHv2C+BOid7Ls6SWP844p5GzkC+7EDmADTeT2XTju3gpZNBt5HKSYoBd0Nobndebw==;24:d8wERnUksajc4GIg342iMfyQBYXiD8vXPrtPFT8DbwKx4fviq9xX3CxIaizGLDwacFsAPTwXMeyO458Xz9wDvsx4Q4avJIS4Xutku9xZWdw=;20:VuQRnXNv86Q/TTmmr39cjIS11QIq3mOQYHJiB14iVMJPM3G591HNCdybt2raPSwhHHM6UvfYOAW3ywAo4kn+wA== x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN1PR03MB107; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401001)(5005006)(3002001);SRVR:BN1PR03MB107;BCL:0;PCL:0;RULEID:;SRVR:BN1PR03MB107; x-forefront-prvs: 0666E15D35 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(199003)(189002)(86612001)(122556002)(106356001)(74316001)(105586002)(99286002)(46102003)(33656002)(2656002)(87936001)(50986999)(54356999)(5001960100002)(2900100001)(107886002)(5001830100001)(64706001)(110136002)(5001860100001)(102836002)(68736005)(97736004)(10290500002)(229853001)(101416001)(4001540100001)(81156007)(86362001)(10400500002)(5005710100001)(8990500004)(62966003)(189998001)(450100001)(76576001)(77156002)(5002640100001)(10090500001)(5003600100002)(40100003)(92566002)(3826002);DIR:OUT;SFP:1102;SCL:1;SRVR:BN1PR03MB107;H:BN1PR03MB105.namprd03.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Aug 2015 21:16:03.3088 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR03MB107 Subject: Q: Caching IS_REFERENCE zvals in PHP7? From: ericsten@microsoft.com (Eric Stenson) Good Morning, PHP Internals Folks! I have a design question about caching of IS_REFERENCE zval values, and wan= t to understand the most correct way to implement a memory Cache for zvals = in PHP7. Background: ----------- WinCache's user cache does a 'deep copy' of zvals into a shared memory segm= ent that can start at different offsets in the processes which share the me= mory segment. This means that all internal pointers must be converted into= offsets relative to the starting address of the shared memory segment. Fu= rther, flags are altered such that the cached zval is considered immutable = and not ref counted. So, for example, with an IS_STRING zval, a zval in shared memory is created= (zv_cached), the zend_string is cached, and then the Z_STR_P(zv_cached) is= set to the offset of the cached zend_string. =20 When the user fetches the cached IS_STRING zval, the reverse is performed: = a zval is created in request-temporary memory (zv_fetched), and initialized= from zv_cached. Z_STR_P(zv_fetched) is translated back into a pointer (to= the cached zend_string) which is correct in the current process. The call= er won't attempt to free or modify the cached zend_string since the type fl= ags were modified when it was cached. For IS_REFERENCE objects, I'm not clear on what I should do. Should I cache= the zend_reference struct, with its included zval? Or should I "flatten" = the IS_REFERENCE, and just convert it to the zval that's in the zend_refere= nce struct? Consider the following: &$bar, 'black2' =3D> &$bar ); wincache_ucache_add('foo', $arr2); $fetched_arr =3D wincache_ucache_get('foo'); ?> The $fetched_arr won't have the internal references between elements (e.g. = $fetched_arr['black'] and $fetched_arr['black2'] won't point at the same ac= tual value). Questions: ---------- * How should one persist/intern an IS_REFERENCE zval? * Is it acceptable to "flatten" IS_REFERENCE zvals when persisting/internin= g them? If not, what's the reason for not doing so? * If IS_REFERENCE zvals have to be maintained, does that mean that the zend= _reference will need to be copied out of the shared memory cache each time = it's fetched? * Is there an example of a PHP7 extension which is doing something similar?= APC doesn't appear to have been updated for PHP7. Thx! --E. =20