Home php教程 php手册 PHP垃圾收集器和程序员的幽默

PHP垃圾收集器和程序员的幽默

Jun 06, 2016 pm 08:14 PM
composer php Rubbish humor programmer

Composer是一个深受程序员喜欢的PHP依赖关系管理工具。最近它的源代码上的一处改动引起了大家热烈的讨论。改动其实只是增加了一行代码: gc_disable(); ,但为什么要增加这行代码的原因却让人很费解。 估计普通的PHP程序员对这行代码并不知道是干嘛的。但单

Composer是一个深受程序员喜欢的PHP依赖关系管理工具。最近它的源代码上的一处改动引起了大家热烈的讨论。改动其实只是增加了一行代码:gc_disable();,但为什么要增加这行代码的原因却让人很费解。

估计普通的PHP程序员对这行代码并不知道是干嘛的。但单从语义的字面意思上可以猜出,它是要禁止PHP的垃圾收集器。没错,就是这个意思。

给那些想寻求技术解释的人说明一下,在Composer里,PHP的垃圾收集器浪费了大量的CUP资源,它试图收集由于Composer在解决程序依赖问题时候产生的成千上万的对象(这些对象是Composer用来表达依赖包内部规则的)。对象在不断的生产,它就一遍又一遍的收集,但事实上它什么都没收集到,但每次对象的生产都会触发它再次收集。

禁止PHP的垃圾收集器虽然阻止了PHP的高级功能,但却释放了大量的内存,这样,Composer有足够的内存来做自己的事情,而不是让它们浪费在什么垃圾都收集不到的活动中。经过这样的修改后,很多人都报告内存使用量大幅度下降。

为什么这个问题这么久了才被人发现?看起来原因是性能优化工具无法检测到垃圾收集器的工作。很显然,这是性能优化工具的问题,期望以后后有所改进。但大多数情况下,这PHP的这个特征并不会成为一个问题,我不建议你们都在自己的项目中禁止垃圾收集器的工作。 在大多数情况下,PHP的垃圾收集器是非常有用的,只是在我们的Composer工具里它出现了问题。

上面的这段话是这段代码的修改人Seldaek在Hacker News上给大家的解释。

说的很清楚明白,消除了大家的疑惑,但这不是本文的重点,本文要说的重点是大家对这一重大修改的反应,全部体现在了Github的评论里。太欢乐了。你会发现程序员是最幽默的,下面选几个例子:

网友clemherreman评论:

Before: Memory usage: 163.66MB (peak: 403.82MB), time: 246.25s
After: Memory usage: 163.34MB (peak: 350.36MB), time: 99.55s
Copy after login

网友martindines评论:

Before: Memory usage: 152.71MB (peak: 335.9MB), time: 195.99s
After: Memory usage: 164MB (peak: 308.02MB), time: 104.06s
Copy after login

网友eXtreme评论:

Before: Memory usage: 217.37MB (peak: 631.42MB), time: 313.4s
After: Memory usage: 174.62MB (peak: 495.42MB), time: 152.3s
After latest commit: Memory usage: 174.88MB (peak: 495.1MB), time: 67.73s
Copy after login

网友j0k3r评论:

Memory usage: 385.05MB (peak: 910.03MB), time: 138.81s
Memory usage: 384.93MB (peak: 863.22MB), time: 26.12s
Copy after login

网友youbs评论:

Before:
Memory usage: 2194.78MB (peak: 3077.39MB), time: 1324.69s
After:
Memory usage: 4542.54MB (peak: 4856.12MB), time: 232.66s
Copy after login

网友johnpbloch评论:

Before: Memory usage: 43.34MB (peak: 69.12MB), time: 26.57s
After: Memory usage: 43.67MB (peak: 60.27MB), time: 7.01s
Copy after login

网友o评论:

Our builds are now faster than ever!
Copy after login

网友oscherler评论:

Before: Memory usage: 272.95MB (peak: 898.45MB), time: 144.32s
After:  Memory usage: 257.05MB (peak: 608.25MB), time: 24.34s
Copy after login

网友raphaelstolt评论:

Memory usage: 94.01MB (peak: 163.47MB), time: 11.24s
Memory usage: 87.91MB (peak: 123.66MB), time: 3.38s
Copy after login

网友malaney评论:

Before:
Memory usage: 207.13MB (peak: 705.58MB), time: 762.59s
After:
Memory usage: 164.42MB (peak: 469.22MB), time: 53.98s
Copy after login

哦,太多了….

你是不是也乐了,这些搞技术的人是多么有趣一群人呀,生活中虽然有些寡言少语,但在工作中,在技术问题上,他们幽默、好学、欢闹的性格才真正的体现出来。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles