https://github.com/staabm/blackfire-regex
https://github.com/staabm/blackfire-regex
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/staabm/blackfire-regex
- Owner: staabm
- Created: 2023-10-21T05:13:11.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-21T08:05:00.000Z (over 2 years ago)
- Last Synced: 2025-03-05T11:39:13.054Z (over 1 year ago)
- Language: PHP
- Size: 75.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# blackfire-regex
## find 1
simple script which runs memory efficient without blackfire, but takes a huge amount of memory when profilling.
my feeling is, this script reproduces a problem I had over and over again, when profilling the PHPStan codebase, in which case blackfire reported too much memory used - especially in Nette/Strings::match() (regex matching)
### repro
checkout https://github.com/staabm/blackfire-regex/commit/10b34994f6873f4b30f33b2f53c115b65a8af91d
### run without blackfire
php nette.php
Used memory: 4 MB
### run with blackfire
blackfire run php nette.php
Used memory: 4.3 GB
## find 2
running this very similar script takes 1.4 GB when PCRE is involved and only 370 MB with plain addcslashes() - both when running with blackfire.
it takes the very same amount of memory when running without blackfire - just 2 MB
### repro
https://github.com/staabm/blackfire-regex/commit/e1d0071398fe933b182a96cd81f89f68a816c358
```
➜ blackfire-regex git:(main) ✗ php nette.php
Used memory: 2 MB
➜ blackfire-regex git:(main) ✗ php plain.php
Used memory: 2 MB
➜ blackfire-regex git:(main) ✗ blackfire run php nette.php
Used memory: 1.43 GB
➜ blackfire-regex git:(main) ✗ blackfire run php plain.php
Used memory: 370 MB
```
## Setup
```
php -v
PHP 8.2.11 (cli) (built: Sep 26 2023 11:11:58) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.11, Copyright (c) Zend Technologies
with blackfire v1.86.3~mac-x64-non_zts82, https://blackfire.io, by Blackfire
blackfire -V
Blackfire version 2.22.0 (c) 2014-2023 Platform.sh (2023-09-28T09:21:28+0000 - dev)
```
running latest macos on a M1 Pro.