Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103860 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 40383 invoked from network); 28 Jan 2019 12:43:51 -0000 Received: from unknown (HELO mail-io1-f47.google.com) (209.85.166.47) by pb1.pair.com with SMTP; 28 Jan 2019 12:43:51 -0000 Received: by mail-io1-f47.google.com with SMTP id r200so12832376iod.11 for ; Mon, 28 Jan 2019 01:22:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TmVDCCIG9VQB9bPFBkrI/XRoHFyeaWj8Ae4h/1GaDqI=; b=vg0c+VHjKAMpJfzcKxzse0IdXuCTwLkN4Z21RzJxy3AjJrbFadbWVynR5391JtFosz LoA4CymG6NF2jBBtnzu4f2dXa9ZmEntONWDQryZHLfcHh6vYkUlxWzvWrS13b3nlN/qd DZzRuieIonpSjxIbleAehBx/zk56xyd6rU6K/+oG59aDX+ZShMxRVAjt7mscflg3MVbN TIE0e6lbMT06GOx6og/ggTRyCimrn2do/7F1e61vQy10Q8QCaEZYn5kA3WKka4SZkrzX OQ46Szp3Na76YzZ1I3C8l4garQ9hSAfw1U/uENf8qLp1mWJxrOVg5kJpUGUQUgNA9CyX eAGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TmVDCCIG9VQB9bPFBkrI/XRoHFyeaWj8Ae4h/1GaDqI=; b=JmMe3KwnANKf1QmRBVGVCIJm1xiQTWk3l/Tcz9uQGmI13S24TV4UPfH0tJbJjPlzL1 QDG6PxCvi/vKdv4rmo3f4D2X2K6TFwdxsmgA8arCo+xTbCM7GpnmF4o+fSQbOX/un7ew VBMByfp5I6gB/htDdfaUfSy3FeQyp2Umbvxsh+YsbyXYemOuStcj6QmN7GfqqQKlZP+R +9fBiTEgRIyp5xl31dA3/noderhr3/5kcaXN0Bc1Sm/DjxPtU2rfSwqiACb5gFXvuSIt p0CZqs4yrCdbUeySZYkb7qDW4bSFY1qVQl/2cwkTnSXCs4JPt8lYymod3xEQHNIiXfLh 9vQg== X-Gm-Message-State: AHQUAuYOHAU3Dtje8Dak1SRXGE9GiMIFAUCqGvTQw4yPgyCEgL7qzE99 +M4Bsa3piFAB1usWPWxZ95a0FUDXOVkxAy8WHpY= X-Google-Smtp-Source: AHgI3IZw1fHL9e2UMo5AUnJY7vuJZ8zRcwQP1WZ5dkSC7T16xFls3FwIwiEJF1waR7vcZqNGOLLaYl2nYzEvN2HBRhA= X-Received: by 2002:a6b:5804:: with SMTP id m4mr11884255iob.47.1548667377188; Mon, 28 Jan 2019 01:22:57 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 28 Jan 2019 10:22:41 +0100 Message-ID: To: Nicolas Grekas Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000e483c3058081386e" Subject: Re: [PHP-DEV] [RFC] Reflection for references From: nikita.ppv@gmail.com (Nikita Popov) --000000000000e483c3058081386e Content-Type: text/plain; charset="UTF-8" On Tue, Jan 15, 2019 at 1:42 PM Nikita Popov wrote: > On Tue, Jan 15, 2019 at 1:09 PM Nicolas Grekas < > nicolas.grekas+php@gmail.com> wrote: > >> About using "int" as return type for getId(): >> >> > * Can the `getId()` return type be restricted to either `int` or >>> > `string`? Why is it a union type right now? Technical limitation? >>> >>> To allow changes in the future. The real return value here is an int, but >>> the size increase due to hashing makes it a string. If we find a way to >>> avoid that (or decided that we don't care about leaking addresses), we >>> could change this to a (faster) int-based API. >>> >> >> spl_object_hash() uses a XOR to hide internal addresses - so they're >> already "leaking". >> we also added spl_object_id() which proved much better in term of memory >> usage - not only CPU. >> >> Mixing both arguments/approaches, what about returning a XORed int? Are >> we OK with that? It'd be a welcome storage/CPU optimization from my pov. >> > > A XORed int is not much better than returning the address directly -- it > will scramble the base address, but for example not the offsets between the > references (if the XOR key is the same). > > If people think that this is good enough for us, then of course it's > better to go with the int for performance reasons. I've picked the sha1 > here to be conservative. How performance critical is this API? > > Nikita > I'd like to move forward with the RFC as is -- I'm uncomfortable with switching this to a simple XOR for security reasons. I think we should start off with the current implementation, with the option of switching to an integer return value at a later time. Nikita --000000000000e483c3058081386e--