php / php/php-src

Typed property assign should be optimized more

未关闭
#13,100 10 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Feature Status: Needs Triage
主要语言
C
星标
40.4k
派生
8.1k
平均合并
2 天 13 小时
30 天内合并 PR
96

描述

Description

Classes are very often used as a simple data holding structure which is created and destroyed millions times per script lifecycle/run.

In https://3v4l.org/CMktE/rfc#vgit.master I have discovered a "class like struct" is slower than an array. This is something not fully surprising on the first sight.

However, https://3v4l.org/hSSFJ/rfc#vgit.master, same demo with propoted properties only, with empty constructor, is not (much if any) faster.

Initially I thought the interpreted code in the constructor will contribute the most to the total run time. This seems to be not true, it seems the most of the time is spent in object allocation and release. If an object has no cycles, it should be fast. I hope there is a room to optimize the object allocation/release more and make this core part of php faster.

let's focus on typed property assign performance solely here

repro: https://3v4l.org/FGeEf

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 3v4l.org/FGeEf 的复现开始,并针对当前 PHP 解释器对类型化属性赋值案例进行性能分析。在提出优化方案之前,确定哪个分配或赋值路径占主导;完成的标准是在不改变语义的情况下取得经过测量的改进,并在项目提供此类检查时由有针对性的回归或性能检查提供支持。

由索引模型根据 Issue 内容生成。

评估

技术栈
c, php
领域
backend, performance
Issue 类型
重构
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。