Comments (9)
Yes, it saves opcache shared memory. The memory load for each PHP file is reduced by the number of bytes of comments in the file, iiuc. I agree that it's not necessary to implement without reflecting on comments but I think it's desirable.
We cannot in general quantify the benefit of setting opcache.save_comments=0
since it depends entirely on the project. But I can offer some general qualitative observations...
- Lots of comments is rather common these days. For example, the libs we depend on often document themselves entirely with comments. So it could be a significant fraction of total SHM demand.
- Your README offers performance as a selling point while it impacts the SHM load of all code in that opcache.
- I assume opcache offers the config option because it can yield real operational benefit.
- Portable, runtime-independent code is nice.
- Comment reflection is a bit, how should I put it diplomatically?, not what you might expect a modern software textbook to recommend as "good practice".
from markdown.
@cebe, yes I'm sure it can. It can be solved also with conventional programming.
But the issue with opcache is actually small enough. Allocate enough memory to opcache and stop worrying about it.
In my case the problem has gotten smaller with time as I use fewer comments. With type hints and good names for functions and parameters, comments can be redundant.
from markdown.
does opcache.save_comments=0
really safe some resources or improve speed? In general composition of markdown features could be implemented in a different way, but I do not think it is really necessary.
from markdown.
Fwiw, OPcache stats from my servers currently show
- number of scripts 1430
- 11 of them under cebe/markdown
- 36.3 MiB without comments
- 39.6 MiB with comments, about 9% more
Not a huge difference but it's not insignificant.
from markdown.
Nothing much changed. Detailed opcache status below shows server A and B have almost identical opcache use (no surprise, they have almost identical load). The only important difference is used_memory which is ~10% more with with comments. (This opcache has been up for just over a month.)
stat | A | B |
---|---|---|
opcache_enabled | true | true |
cache_full | false | false |
restart_pending | false | false |
restart_in_progress | false | false |
memory_usage | ||
used_memory | 39580576 | 43352104 |
free_memory | 77943056 | 73007632 |
wasted_memory | 16694096 | 17857992 |
current_wasted_percentage | 12.43807077407837 | 13.305240869522095 |
interned_strings_usage | ||
buffer_size | 8388608 | 8388608 |
used_memory | 3365656 | 3353072 |
free_memory | 5022952 | 5035536 |
number_of_strings | 60879 | 60802 |
opcache_statistics | ||
num_cached_scripts | 1614 | 1613 |
num_cached_keys | 2225 | 2226 |
max_cached_keys | 16229 | 16229 |
hits | 2904881093 | 3074112339 |
start_time | 1535933633 | 1535720837 |
last_restart_time | 0 | 0 |
oom_restarts | 0 | 0 |
hash_restarts | 0 | 0 |
manual_restarts | 0 | 0 |
misses | 99128 | 160821 |
blacklist_misses | 53734850 | 60452796 |
blacklist_miss_ratio | 1.8161549426196841 | 1.928487429157587 |
opcache_hit_rate | 98.18049468407227 | 98.0663822659208 |
from markdown.
Thank you for the detailed stats!
from markdown.
I'm interested in to see if there is any development in this issue.
Ubuntu, Debian and oenrej/php
PHP packages have default configuration opcache.save_comments=1
, but I personally turn it off save some opcache space. This is my only blocker that prevents me using this awesome package.
Thank you.
from markdown.
If you want to use this lib without comments, you could extend the markdown flavor class you want to use and override the following method:
Lines 254 to 285 in eeb1bf6
if you hardcode the array of markers and function names it should all work with opcache.save_comments=0
.
I might add some docs about it and possibly also add a configuration option for it...
from markdown.
this can be solved in PHP 8 by using attributes: https://wiki.php.net/rfc/attributes_v2
from markdown.
Related Issues (20)
- Php 7 compatibility
- Inline HTML support with <details> and <summary> in Github flavored markdown HOT 6
- ListTrait looping through all lines HOT 2
- Code block with empty newline does not working HOT 2
- Inconsistent behavior of multiple backticks HOT 29
- Potential XSS in link rendering HOT 2
- GFM: Line break using a backslash HOT 1
- Difference traditional and GitHub markdown HOT 3
- Can this be used to pretty print Markdown? HOT 4
- Definition list is not rendered HOT 2
- Get all headings for table of contents HOT 6
- Support for PHP source directory HOT 7
- Tags separated by spaces are rendered together HOT 1
- Table without body at the end of markdown not detected
- Confirm (modified) PSR2 coding standard HOT 3
- renderLink() breaks URLs with query params HOT 1
- h is singled out in parsing
- [FEATURE] Header links HOT 8
- Getting Fatal error Out of memory on ReflectionClass HOT 2
- Maintenance status? HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from markdown.