Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: The OPcache interned strings buffer is nearly full #31223

Closed
5 of 8 tasks
ghost opened this issue Feb 16, 2022 · 142 comments · Fixed by #31267, nextcloud/docker#1702 or #36278
Closed
5 of 8 tasks

[Bug]: The OPcache interned strings buffer is nearly full #31223

ghost opened this issue Feb 16, 2022 · 142 comments · Fixed by #31267, nextcloud/docker#1702 or #36278
Assignees
Labels
2. developing Work in progress enhancement pending documentation This pull request needs an associated documentation update

Comments

@ghost
Copy link

ghost commented Feb 16, 2022

⚠️ This issue respects the following points: ⚠️

  • This is a bug, not a question or a configuration/webserver/proxy issue.
  • This issue is not already reported on Github (I've searched it).
  • Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • I agree to follow Nextcloud's Code of Conduct.

Bug description

The OPcache interned strings buffer is nearly full. To assure that repeating strings can be effectively cached, it is recommended to apply opcache.interned_strings_buffer to your PHP configuration with a value higher than 8.

image

Steps to reproduce

  1. Server Overview

Expected behavior

NA

Installation method

Manual installation

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.0

Web server

Apache (supported)

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Updated to a major version (ex. 22.2.3 to 23.0.1)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "1.1.1.14",
            "cloud.next.com"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "23.0.2.1",
        "overwrite.cli.url": "https:\/\/cloud.next.com",
        "htaccess.RewriteBase": "\/",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "simpleSignUpLink.shown": false,
        "trashbin_retention_obligation": "auto,30",
        "versions_retention_obligation": "auto,1",
        "skeletondirectory": "",
        "default_phone_region": "US",
        "allow_local_remote_servers": true,
        "mail_smtpmode": "smtp",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_sendmailmode": "smtp",
        "mail_smtpport": "587",
        "mail_smtpauthtype": "LOGIN",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpsecure": "tls",
        "mail_smtpauth": 1,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "twofactor_enforced": "true",
        "twofactor_enforced_groups": [],
        "twofactor_enforced_excluded_groups": [],
        "maintenance": false,
        "updater.release.channel": "stable",
        "theme": "",
        "loglevel": 2,
        "updater.secret": "***REMOVED SENSITIVE VALUE***"
    }
}

List of activated Apps

Enabled:
  - accessibility: 1.9.0
  - activity: 2.15.0
  - admin_audit: 1.13.0
  - bruteforcesettings: 2.3.0
  - cloud_federation_api: 1.6.0
  - comments: 1.13.0
  - contactsinteraction: 1.4.0
  - dashboard: 7.3.0
  - dav: 1.21.0
  - federatedfilesharing: 1.13.0
  - federation: 1.13.0
  - files: 1.18.0
  - files_external: 1.15.0
  - files_pdfviewer: 2.4.0
  - files_rightclick: 1.2.0
  - files_sharing: 1.15.0
  - files_trashbin: 1.13.0
  - files_versions: 1.16.0
  - files_videoplayer: 1.12.0
  - firstrunwizard: 2.12.0
  - groupfolders: 11.1.2
  - logreader: 2.8.0
  - lookup_server_connector: 1.11.0
  - nextcloud_announcements: 1.12.0
  - notifications: 2.11.1
  - oauth2: 1.11.0
  - officeonline: 1.1.2
  - password_policy: 1.13.0
  - photos: 1.5.0
  - previewgenerator: 4.0.0
  - privacy: 1.7.0
  - provisioning_api: 1.13.0
  - ransomware_protection: 1.12.0
  - recommendations: 1.2.0
  - sendent: 1.2.10
  - serverinfo: 1.13.0
  - settings: 1.5.0
  - sharebymail: 1.13.0
  - socialsharing_email: 2.4.0
  - spreed: 13.0.3
  - support: 1.6.0
  - survey_client: 1.11.0
  - suspicious_login: 4.1.0
  - systemtags: 1.13.0
  - text: 3.4.0
  - theming: 1.14.0
  - twofactor_admin: 3.2.0
  - twofactor_backupcodes: 1.12.0
  - twofactor_totp: 6.2.0
  - updatenotification: 1.13.0
  - user_status: 1.3.1
  - viewer: 1.7.0
  - weather_status: 1.3.0
  - workflowengine: 2.5.0
Disabled:
  - circles: 22.1.1
  - encryption
  - user_ldap

Nextcloud Signing status

No response

Nextcloud Logs

No response

Additional info

.

@ghost ghost added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Feb 16, 2022
@szaimen
Copy link
Contributor

szaimen commented Feb 16, 2022

cc @MichaIng

@ghost
Copy link
Author

ghost commented Feb 16, 2022

I did a sudo service apache2 restart and it went away but then comes back after a while

@MichaIng
Copy link
Member

MichaIng commented Feb 16, 2022

@andyxheli
Why do you think this is a bug, or was it just the best issue template you found? This shows up when the available OPcache interned strings buffer size is more than 90% filled. You have a relatively long list of enabled apps, in which case this seems to be not too unexpected. We had one more such report, and another one where Nextcloud was not the only web application running on the same PHP (and hence OPcache) pool.

On Debian with PHP8.0, I suggest to raise it with an own override config module, doubling it to 16 MiB:

# Create an own PHP module with highest priority
cat << '_EOF_' > /etc/php/8.0/mods-available/local-opcache.ini
; Raise OPcache interned strings buffer for Nextcloud
; priority=99
opcache.interned_strings_buffer=16
_EOF_
# Enable the module
phpenmod local-opcache
# Restart Apache2 to apply the new module
systemctl restart apache2

I did a sudo service apache2 restart and it went away but then comes back after a while

This makes sense since the OPcache as well as its interned strings buffer are filled on demand by default, i.e. each script is loaded once requested the first time. When you restart Apache2, the OPcache instance is destroyed and it the buffer is filled while you using the Nextcloud web interface and the individual apps.

Since this seems to be not as rare as I expected, it makes sense that we add this explicitly to the docs: https://docs.nextcloud.com/server/latest/admin_manual/installation/server_tuning.html#enable-php-opcache
Also I see a link to the docs from the admin panel is missing. I'll add this as well now that docs and admin panel recommendations match.

Not sure whether it breaks the scope of the docs, but I could also add the steps like above to add a config override, the IMHO preferred way since no package files are touched, so that changes can be reverted easily and package manager upgrades can update the default configuration files without interactive confirmation and loosing customisations. In case, does anyone know whether phpenmod/phpdismod is specific to Debian/Ubuntu/APT or whether these commands are available on other distros, RPM and AUR based ones, and upstream PHP builds as well?

@ghost
Copy link
Author

ghost commented Feb 16, 2022

@MichaIng Sorry I searched everywhere for something regarding this and nothing came up for me I even check the docs and I didn't see anything about a recommended opcache.interned_strings_buffer=16. so I though to submit a bug. I should change my settings from 8 to 16 ?

@MichaIng
Copy link
Member

MichaIng commented Feb 16, 2022

Okay, no problem, I asked just in case it showed something wrong, e.g. you raised the value already or verified that in fact the buffer is not so full.

I didn't see anything about a recommended opcache.interned_strings_buffer=16.

And this makes sense as it depends on the enabled apps and in case other PHP applications running on the same PHP/OPcache instance. In most cases, the default 8 MiB are sufficient, in rare cases, as far we could see, 16 MiB are required to keep everything stored in cache. But it wouldn't make sense to recommend this to everyone when the additional 8 MiB reserved in total OPcache was just empty in most cases 😉. So the warnings do now show up based on actual current cache usage.

But as I said, it makes sense to mention it in the docs and link that docs section from within the admin panel warnings. I'll raise a PR the next days.

I should change my settings from 8 to 16?

This I would recommend, using e.g. the commands I provided above. Note that this is not mandatory, it just assures that all strings present in Nextcloud's PHP scripts stay cached and hence speeds up access performance a bit. The interned strings buffer is quite a clever implementation which stores repeating strings across all cached scripts just a single time in shared memory and additionally persistent for future requests (which doesn't seem to be the default according to some readings).

@toxpal
Copy link

toxpal commented Feb 17, 2022

All my NC installations were working fine for years, but right after upgrading to 23.0.2 I get these errors on every single installation.

@ghost
Copy link

ghost commented Feb 17, 2022

I have the same problem, wenn i raise it to 16 it sayy raise it higher, wenn i raise it to 32 it says raise it higher

@toxpal
Copy link

toxpal commented Feb 17, 2022

I have the same problem, wenn i raise it to 16 it sayy raise it higher, wenn i raise it to 32 it says raise it higher

Exactly the same. No matter how high I set new limits, error re-appears again and again.

@MichaIng
Copy link
Member

All my NC installations were working fine for years

And it still does. Note that the admin panel warnings/recommendations are nothing mandatory, just a hint what may be improved according to how far Nextcloud is able to check it. But warnings may be wrong or not apply in a particular case, e.g. I keep ignoring warnings about missing imagick (I do not, and do not want to use ImageMagic and Nextcloud works very well with GD), missing bcmath and gmp (I do not use WebAuthn, and those are not required for anything else) and about the missing X-Download-Options header (I do not use Internet Explorer, nor does any other user of my instance). I however understand that one usually wants to have the admin panel free of warnings, which is why I was already requesting to solve the bcmath and gmp recommendations differently, embedding them right into the WebAuthn settings, keep observing the discussion about getting rid of imagick (which is known to have potential security issues with SVG embedded code) and cannot await #20855 to be fully done.

Back to topic: I cannot imagine that one Nextcloud instance is able to use an interned strings buffer of more than 16 MiB, so @Copiis @toxpal are you running only a single Nextcloud instance on that webserver/PHP pool or are there other web applications (which do use PHP)? If it is really just one Nextcloud, can you show your occ app:list, please?

@fantasya-pbem
Copy link

I cannot imagine that one Nextcloud instance is able to use an interned strings buffer of more than 16 MiB

My little Nextcloud has the same issue, too. I used opcache before, but immediately after upgrade from 22 to 23 a couple of days ago I got this opcache warning, too. I tried to get rid of it by doubling interned_strings_buffer from 8 to 16 and now 32, but this warning still exists. It feels like a newly introduced bug. Is there a possibility to roughly estimate the needed buffer space NC needs?

@MichaIng
Copy link
Member

MichaIng commented Feb 17, 2022

Same as for the others, if Nextcloud is really the only website/application running on that webserver and PHP instance, please post the output of occ app:list so we may find a similarity between your apps which might cause this.

Is there a possibility to roughly estimate the needed buffer space NC needs?

The admin panel does exactly this. It looks how much of the available interned strings buffer is in fact used, and when >90% of available size, it prints the recommendation. If Nextcloud is really the only website, then obviously it requires that much interned strings buffer in your particular case, at least when you want to assure that all strings are kept in cache.

@fantasya-pbem
Copy link

The admin panel does exactly this. It looks how much of the available interned strings buffer is in fact used, and when >90% of available size, it prints the recommendation.

So this check is a new NC 23 feature?

@MichaIng
Copy link
Member

NC v23.0.1 to be precise.

@ghost
Copy link

ghost commented Feb 17, 2022

Back to topic: I cannot imagine that one Nextcloud instance is able to use an interned strings buffer of more than 16 MiB, so @Copiis @toxpal are you running only a single Nextcloud instance on that webserver/PHP pool or are there other web applications (which do use PHP)? If it is really just one Nextcloud, can you show your occ app:list, please?

On the webserver is one Nextcloud an one Friendica instalation

  • accessibility: 1.9.0
    • activity: 2.15.0
    • breezedark: 23.2.0
    • calendar: 3.0.6
    • circles: 23.0.1
    • cloud_federation_api: 1.6.0
    • comments: 1.13.0
    • contacts: 4.0.7
    • contactsinteraction: 1.4.0
    • dashboard: 7.3.0
    • dav: 1.21.0
    • documentserver_community: 0.1.12
    • federatedfilesharing: 1.13.0
    • federation: 1.13.0
    • files: 1.18.0
    • files_pdfviewer: 2.4.0
    • files_rightclick: 1.2.0
    • files_sharing: 1.15.0
    • files_trashbin: 1.13.0
    • files_versions: 1.16.0
    • files_videoplayer: 1.12.0
    • firstrunwizard: 2.12.0
    • integration_twitter: 1.0.2
    • logreader: 2.8.0
    • lookup_server_connector: 1.11.0
    • nextcloud_announcements: 1.12.0
    • notifications: 2.11.1
    • oauth2: 1.11.0
    • onlyoffice: 7.3.0
    • password_policy: 1.13.0
    • photos: 1.5.0
    • privacy: 1.7.0
    • provisioning_api: 1.13.0
    • recommendations: 1.2.0
    • serverinfo: 1.13.0
    • settings: 1.5.0
    • sharebymail: 1.13.0
    • spreed: 13.0.3
    • support: 1.6.0
    • survey_client: 1.11.0
    • systemtags: 1.13.0
    • talk_matterbridge: 1.23.2
    • tasks: 0.14.2
    • text: 3.4.0
    • theming: 1.14.0
    • twofactor_backupcodes: 1.12.0
    • updatenotification: 1.13.0
    • user_status: 1.3.1
    • viewer: 1.7.0
    • weather_status: 1.3.0
    • workflowengine: 2.5.0
      Disabled:
    • admin_audit
    • encryption
    • files_external
    • user_ldap

@MichaIng
Copy link
Member

MichaIng commented Feb 17, 2022

an one Friendica instalation

Okay, in this case it is not so unexpected that the default is insufficient. Not sure how large Friendica is. You can btw monitor OPcache usage via opcache-gui which allows to browse and search through all cached scripts, see their size in cache etc. Sadly the interned strings buffer cannot be listed like that, and I'm not sure about any way to further analyse its content.

E.g. I have a server with phpBB, Wordpress, Matomo and some own pages and it uses ~150 MiB interned strings buffer (I set it to 256 MiB, giving 192 MiB effective space, always 75%) and up to 400 MiB overall OPcache size. My private Nextcloud instance uses 3.5 MiB/32 MiB, so the ratio between interned strings buffer and overall OPcache usage (the letter includes the first) is quite different depending on which application is used, and in Nextcloud obviously depending on used apps. In case of phpBB and Wordpress they both create large (up to 1 MiB) temporary PHP scripts as some own cache layer, which probably plays a role, especially when those are not evicted on removal (which would be basically a bug), but I haven't analysed it further for now.

@ghost
Copy link
Author

ghost commented Feb 17, 2022

you also also use CLI https://github.com/gordalina/cachetool

@MichaIng
Copy link
Member

Ah nice, I didn't know that one. Also good for the docs as alternative.

@ghost
Copy link
Author

ghost commented Feb 17, 2022

Here a website that lists all the recommended monitoring options
https://haydenjames.io/php-performance-opcache-control-panels/

@ghost
Copy link
Author

ghost commented Feb 17, 2022

image

@MichaIng
Copy link
Member

MichaIng commented Feb 17, 2022

To not only see the tool's own PHP/OPcache instance, AFAIK such needs to be passed:

--fcgi=/run/php/php8.0-fpm.socket

But this is for PHP-FPM. In case Apache2 with mod_php is used, instead this may work:

--web-path=/path/to/your/document/root --web-url=https://my.domain.org

@gmeks
Copy link

gmeks commented Feb 18, 2022

The value of 8 also seems to be the default in docker images. And im getting the same warning running of nextcloud:apache

@MichaIng
Copy link
Member

8 MiB is the PHP default: https://www.php.net/manual/opcache.configuration.php

@MichaIng MichaIng linked a pull request Feb 18, 2022 that will close this issue
@masterwishx
Copy link

image

Also have this warning after added redis cache to last version of server:

memcache.distributed' => '\OC\Memcache\Redis',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => [
'host' => '192.168.0.199',
'port' => 6379,
'dbindex' => 1,
'password' => 'password',
],

@MichaIng
Copy link
Member

Redis and transactional file locking is completely unrelated to OPcache and the interned strings buffer. Simply follow the recommendation if you want to max performance.

@vgnmnky
Copy link

vgnmnky commented Feb 19, 2022

I have this error as well. Unfortunately, I'm very new to Docker (partly jumping in as a learning exercise), and so I don't know much yet about where the settings for associated services are or where (host, various containers) I'm supposed to enter commands, and I'm finding it difficult to find out.

I have a stack with Nextcloud (23.0.1, from new), MariaDB and Nginx Proxy Manager. I fixed a few other errors, and it works, but please could someone give me an idea where to look to change the opcache settings.

Tried to get a list of installed apps too, as others have posted, but I don't seem to be able to use the occ command anywhere. I have spent a fair bit of time trouble-shooting Nextcloud and other containers, which is part of the learning experience, but though I'm not an IT or CLI noob, I'm finding the level of assumed knowledge to be above me, so some small pointers to help me on my way would be really appreciated.

@MichaIng
Copy link
Member

There is no way (I'm aware of) to configure PHP settings with the Docker container. It needs to be changed by the maintainer here (which still follows the old static recommendation): https://github.com/nextcloud/docker/blob/master/Dockerfile-alpine.template#L81-L86

The all-in-one appliance switched to opcache.interned_strings_buffer=16 already to cover more cases. With the default 128 MiB overall OPcache size, this is no problem since this is much more than enough. All other settings can be removed, matching PHP defaults anyway, opcache.revalidate_freq=1 is a performance decrease, should be either left at 2 (default) or even much higher. Especially in a container, one cannot simply edit Nextcloud scripts and expect changes to be effective within a second. config.php can be edited, but it should be more than sufficient to have changes taking effect within 5 seconds or longer, to decrease the amount of timestamp validations PHP does.

Ah, here it is already: nextcloud/docker#1702

@masterwishx
Copy link

Simply follow the recommendation if you want to max performance.

I'm using nextcloud Linux server docker for unraid,
so it's warning Becouse of update?
What exactly the recommendation you mean?
It's good idea to use redis for home server + APCu?

@ghost
Copy link

ghost commented Jan 20, 2023

Are you on latest Nextcloud 23/24/25 subversion?

Im on Z 25.0.3

@ghost
Copy link
Author

ghost commented Jan 20, 2023

Is there a way to enable a log to see what's taking so much space on OPcache usage? so we can see why this warning comes up ?

@MichaIng
Copy link
Member

MichaIng commented Jan 20, 2023

Is there a way to enable a log to see what's taking so much space on OPcache usage? so we can see why this warning comes up ?

=>

You can btw control this via above mentioned OPcache GUI or opcache_get_status, if you doubt that Nextcloud is obtaining the OPcache usage correctly.

=> #31223 (comment)

Im on Z 25.0.3

That is strange, I tested this up and down, and the logic is trivial. But what caught my eye even more is that you see a message which was never inside official Nextcloud code:

The OPcache cache for internal strings is almost full. To ensure that repeating strings can be cached effectively, it is recommended to apply opcache.interned_strings_buffer with a value higher than 2048 in your PHP configuration.

vs

The OPcache interned strings buffer is nearly full. To assure that repeating strings can be effectively cached, it is recommended to apply opcache.interned_strings_buffer to your PHP configuration with a value higher than X.

The wording in your version is also wrong, those strings are called "interned strings". Are you using an official Nextcloud version? If so, does it show integrity check errors (in case recheck via CLI), and which locale/language are you using?

@ghost
Copy link

ghost commented Jan 20, 2023

The wording in your version is also wrong, those strings are called "interned strings".

This is a translation from german

@MichaIng
Copy link
Member

This is a translation from german

Ah okay, I was already wondering 😄. Can you show how you added the values to your php.ini and in case verify via mentioned methods that these are the effective values? ( 2048 < 4096 / 4) is false, so the second warning must not be shown. Just to replicate the exact syntax of the code:

# php -r 'if ((false) || ((true) && (2048 < 4096 / 4))) { echo("true\n"); } else { echo("false\n"); }'
false

Ah, or there is really empty($status['interned_strings_usage']['free_memory']), i.e. zero free bytes in interned strings buffer. That should be visible in mentioned tools, if true. Not sure whether it is possible, so that a strings fulls exactly the last byte, but to cover such cases, the logic needs to be switched to check for 25% first and empty second. I'll open a PR for this.

@MichaIng
Copy link
Member

PR up: #36278
@Copiis could you apply these changes to your instance and check whether this hides the second warning?

@ghost
Copy link

ghost commented Jan 20, 2023

Let's get started, my php.ini entry for the Nexcloud domain looks like this.

apc.enable_cli = 1
opcache.save_comments = 1
opcache.revalidate_freq = 60
opcache.memory_consumption = 4096
opcache.interned_strings_buffer = 2048

Do I understand this correctly, the opcache.interned_strings_buffer should be a quarter of opcache.memory_consumption ?

@ghost
Copy link
Author

ghost commented Jan 20, 2023

this is what mine looks like not sure if it good ?

zend_extension=opcache.so
opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=512
opcache.max_accelerated_files=10000
opcache.memory_consumption=2048
opcache.save_comments=1
opcache.revalidate_freq=1

@ghost
Copy link

ghost commented Jan 20, 2023

@Copiis could you apply these changes to your instance and check whether this hides the second warning?

All right, after setting the interned_strings_buffer to a quarter of the memory_consumption, the only error message that appears in the Nextcloud message is that the memory_consumption is to low.
2023-01-20 22 54 05

@MichaIng
Copy link
Member

Do I understand this correctly, the opcache.interned_strings_buffer should be a quarter of opcache.memory_consumption ?

Not necessarily. But if it is a quarter or larger, it the second warning shouldn't show up. It was already a half so the warning shouldn't have shown up before, but there was this little loophole that it still did show up if there was really zero free space in the interned strings buffer.

All right, after setting the interned_strings_buffer to a quarter of the memory_consumption, the only error message that appears in the Nextcloud message is that the memory_consumption is to low.

This was after applying the patch, right? Leave it like that for a while, as the strings buffer is unlikely to full directly, but over time.

@andyxheli
Regarding the interned strings buffer yes.

@ghost
Copy link

ghost commented Jan 21, 2023

That is now the status quo.
This is what my php.ini looks like.

apc.enable_cli = 1
opcache.save_comments = 1
opcache.revalidate_freq = 60
opcache.memory_consumption = 64
opcache.interned_strings_buffer = 32

After I applied your patch > #36278 all OPcache warnings disappeared

@MichaIng
Copy link
Member

opcache.memory_consumption = 64
opcache.interned_strings_buffer = 32

With 64/16 it should work as well. However, the opcache.memory_consumption isn't showing up either? Do you run a single Nextcloud only on this server or other PHP applications as well? If so, I wonder why you needed to apply 4 GiB buffer 🤔. Was this kind of an iteration, increasing interned strings buffer, then needed to increase memory consumption, then again interned strings buffer or so? This is possible as the interned strings buffer size is reserved as part of the overall OPcache, so applying e.g. 32 MiB shows these 32 MiB as used in overall OPcache directly. The 32 MiB left for Nextcloud are sufficient in small instances, but may be too small if you have many apps enabled.

@ghost
Copy link

ghost commented Jan 21, 2023

opcache.memory_consumption isn't showing up either?

No
2023-01-21 13 40 26

Do you run a single Nextcloud only on this server or other PHP applications as well?

No, there is also a Wordpress installation and a Friendica installation running in parallel.

Was this kind of an iteration, increasing interned strings buffer, then needed to increase memory consumption, then again interned strings buffer or so?

I can't tell you that, I'm not that deep into the matter.

The 32 MiB left for Nextcloud are sufficient in small instances, but may be too small if you have many apps enabled.

These are my active apps

timestamp

@bcutter
Copy link

bcutter commented Jan 22, 2023

I still could not find any permanent solution for this. Had opcache.interned_strings_buffer set to a huge number like 272 before, warning still comes back after a few days. This warning seems to be misleadingly shown. Restarting PHP-FPM makes the warning disappear for some time, but that's just a workaround. No discovered impact by this warning - except the warning itself, bugging me for months (or almost a year? not even sure when it started).

@oemb1905
Copy link

I still could not find any permanent solution for this. Had opcache.interned_strings_buffer set to a huge number like 272 before, warning still comes back after a few days. This warning seems to be misleadingly shown. Restarting PHP-FPM makes the warning disappear for some time, but that's just a workaround. No discovered impact by this warning - except the warning itself, bugging me for months (or almost a year? not even sure when it started).

I encourage you to find my posted solution above. It continues to work in 10 Nextcloud production environments. In a few of them, I needed to update php version for some apps that required it. The recommendation came back, and I simply entered the configuration again, and went right away. There's sadly clutter on this page which detracts people from being able to solve this. Best, oemb1905.

@ghost
Copy link

ghost commented Jan 22, 2023

I still could not find any permanent solution for this.

Did you try this #36278
and this in the php.ini?

opcache.memory_consumption = 64
opcache.interned_strings_buffer = 32

@MichaIng
Copy link
Member

Tested with the patch up and down, and indeed was running also into the case where the interned strings buffer was exhausted up to the last byte, in which case the recommendation was kept being shown, with the patch not anymore.

@Copiis
Just to rule it out, since I am a little wondering that NC + Wordpress do not use more of the OPcache: Could you:

echo '<?php echo '\''<pre>'\''; print_r(opcache_get_status(false));' > /path/to/webroot/opcache.php

and point your browser to domain.org/opcache.php and paste the output?

@bcutter
Copy link

bcutter commented Jan 22, 2023

@oemb1905 there's no posted solution above cause there's no other post of you. Linking would help, searching didn't ;-)

I really tried all possible combinations, for the momentI'm just tired and gonna lean back looking forward to see #36278 arriving.

@MichaIng
Copy link
Member

MichaIng commented Jan 22, 2023

@bcutter
#31223 (comment)

I'd personally use:

opcache.memory_consumption = 64
opcache.interned_strings_buffer = 16

which gives more buffer to the overall OPcache, while the interned strings buffer warnings still won't show up anymore, as already a quarter of overall size (or more).

If you run more than Nextcloud on the same PHP server, in which case you may need to increase opcache.memory_consumption, increase opcache.interned_strings_buffer to keep the same ratio of 4:1 and the recommendation about opcache.interned_strings_buffer hence silent.

@ghost
Copy link

ghost commented Jan 23, 2023

Just to rule it out, since I am a little wondering that NC + Wordpress do not use more of the OPcache: Could you:

echo '<?php echo '\''<pre>'\''; print_r(opcache_get_status(false));' > /path/to/webroot/opcache.php

and point your browser to domain.org/opcache.php and paste the output?

Array
(
    [opcache_enabled] => 1
    [cache_full] => 
    [restart_pending] => 
    [restart_in_progress] => 
    [memory_usage] => Array
        (
            [used_memory] => 59835240
            [free_memory] => 5189720
            [wasted_memory] => 2083904
            [current_wasted_percentage] => 3.1052589416504
        )

    [interned_strings_usage] => Array
        (
            [buffer_size] => 6290992
            [used_memory] => 6290976
            [free_memory] => 16
            [number_of_strings] => 96730
        )

    [opcache_statistics] => Array
        (
            [num_cached_scripts] => 4708
            [num_cached_keys] => 8455
            [max_cached_keys] => 16229
            [hits] => 234168830
            [start_time] => 1674304755
            [last_restart_time] => 0
            [oom_restarts] => 0
            [hash_restarts] => 0
            [manual_restarts] => 0
            [misses] => 4813
            [blacklist_misses] => 0
            [blacklist_miss_ratio] => 0
            [opcache_hit_rate] => 99.997944687567
        )

    [jit] => Array
        (
            [enabled] => 
            [on] => 
            [kind] => 5
            [opt_level] => 4
            [opt_flags] => 6
            [buffer_size] => 0
            [buffer_free] => 0
        )

)

PS
I lookt today again and the opcache.memory_consumption message is back again

@MichaIng
Copy link
Member

($status['memory_usage']['used_memory'] / $status['memory_usage']['free_memory'] > 9)

59835240 / 5189720 = 11.53 > 9 hence the recommendation should now show up.

@ghost
Copy link

ghost commented Jan 23, 2023

The changes look like this
Bildschirmfoto vom 2023-01-23 11-53-20
Bit the message still popups, or again
2023-01-23 11 53 43

@MichaIng
Copy link
Member

MichaIng commented Jan 23, 2023

Yes, the message about the overall OPcache buffer shows up, which is correct as I calculated above.

What does not show up is the message about the interned strings buffer, which has only 16 bytes left free space. It didn't show up in this circumstance since a longer time, when being defined as quarter of overall OPcache or larger (I'm repeating myself, is it really that difficult to understand? 😅). But it did still show up if the interned strings buffer had exactly 0 bytes left free space, which is fixed with the patch.

Btw, your output shows that the interned strings buffer is set to 8 MiB (6 MiB usable) only, in which case, also the interned strings buffer message should show up, since (8 < 64 / 4). But you posted opcache.interned_strings_buffer = 16, so this does not match. Did you change something about the settings in the meantime?

@oemb1905
Copy link

oemb1905 commented Jan 24, 2023

@oemb1905 there's no posted solution above cause there's no other post of you. Linking would help, searching didn't ;-)

I really tried all possible combinations, for the momentI'm just tired and gonna lean back looking forward to see #36278 arriving.

A simple ctrl-f would do the job, so long as you expanded all historical posts with "Load more" - here ya go as a courtesy: #31223 (comment) ... the settings/values are for my use-case, the important part is the location imho. If it does not help, well best luck, but I've yet to have an instance of mine or others I help continue to complain since. Lmk either way, would love to know.

@hi-ko
Copy link

hi-ko commented Feb 5, 2024

I'm running nextcloud inside lxc container and had to limit the available memory to resolve this issue (server passed 64 GB memory to the container, now I limit on 8GB). Calculating based on 90% maybe not always best aproach.

@MichaIng
Copy link
Member

MichaIng commented Feb 5, 2024

How is the system memory allocated to the container related to the size and usage of the PHP instance's OPcache and interned strings buffer? The OPcache size is 128 MiB by default, and I never saw a (single) Nextcloud instance using more than that. And the Nextcloud admin panel warns only when the interned string buffer size is less than 25% than that (and above 90% filled), hence less than 32 MiB in this case. This is all some orders of magnitudes below the system/container memory sizes you are mentioning.

@hi-ko
Copy link

hi-ko commented Feb 5, 2024

Hi @MichaIng,
I found this issue by the Error message and

($status['memory_usage']['used_memory'] / $status['memory_usage']['free_memory'] > 9)

gave me the idea it may be worth a try to modify free_memory by reducing container's memory.
Maybe I'm totally missleaded but at least the error message went away 🤷‍♂️

@MichaIng
Copy link
Member

MichaIng commented Feb 5, 2024

This is data from the PHP OPcache, not the system memory. And reducing RAM size of course reduces free memory, which would increase the chance for the panel recommendation to show up, instead of reducing it 😉. Moreover the particular line you are quoting is not about the interned strings buffer (topic here), but about the overall OPcache memory. This is completely unrelated to host or container system memory. The reason why you do not see the admin panel recommendation currently, is because it takes a while before it reappears, as the interned strings buffer is filled slowly.

Since it is known that in some circumstances for unknown reasons, the interned strings buffer is filled slowly unlimited, we adjusted the setup check to not warn anymore when interned strings buffer is 25% of overall OPcache size already. Hence, if your OPcache size is 128 MiB (default), then set the interned strings buffer size to 32 MiB, and all is good. This has been mentioned allover above. Always good to reach through issues and review the attached pull requests, before drawing false conclusions 😉.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress enhancement pending documentation This pull request needs an associated documentation update
Projects
None yet