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

Create a checksum of the config file in memory #34146

Closed

Conversation

ativarsoft
Copy link

This fixes a massive performance bug when opcache is enabled.

Signed-off-by: Mateus de Lima Oliveira mateus@ativarsoft.com

Signed-off-by: Mateus de Lima Oliveira <mateus@ativarsoft.com>
Check if config file exists before trying to read it.

Signed-off-by: Mateus de Lima Oliveira <mateus@ativarsoft.com>
* config file data has been changed therefore all the other
* code that depend on the the config file opcode will not
* be recompiled. */
$data = var_export($this->cache, true);

Check failure

Code scanning / Psalm

TaintedHtml

Detected tainted HTML
* config file data has been changed therefore all the other
* code that depend on the the config file opcode will not
* be recompiled. */
$data = var_export($this->cache, true);

Check failure

Code scanning / Psalm

TaintedHtml

Detected tainted HTML
@szaimen szaimen added the 3. to review Waiting for reviews label Sep 21, 2022
@szaimen szaimen modified the milestones: Nextcloud 25, Nextcloud 26 Sep 21, 2022
Changed comment style to make the linter like it.

Signed-off-by: Mateus de Lima Oliveira <mateus@ativarsoft.com>
@kesselb
Copy link
Contributor

kesselb commented Sep 21, 2022

As reference: #34099

Thanks for creating a new version of your pull request 👍

Our usual workflow is that pull request target master as branch.
If necessary a patch is backported to the stable* branches (if possible by a bot).

Please don't forget to add the logging output (as requsted in the old pull request) to figure out what the actual issue is. The configuration file is only rewritten (and the opcache cleared) when a change is detected:

if (!isset($this->cache[$key]) || $this->cache[$key] !== $value) {
// Add change
$this->cache[$key] = $value;
return true;
}
return false;

Copy link
Contributor

@kesselb kesselb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Target branch: master

@ativarsoft
Copy link
Author

@kesselb

The log is empty, Daniel.

@kesselb
Copy link
Contributor

kesselb commented Sep 21, 2022

Hey, when you change the target branch you may need to rebase your pull request. Right now all commits from stable24 which are not in master are also referenced.

@ativarsoft ativarsoft changed the base branch from master to stable24 September 21, 2022 17:58
@ativarsoft
Copy link
Author

@kesselb, I have no idea how to resolve those rebase conflicts.

@kesselb
Copy link
Contributor

kesselb commented Sep 21, 2022

It depends a bit on your local setup.

When people are working with a fork they usually add another remote "upstream".

git remote add upstream git@github.com:nextcloud/server.git

Then run git fetch upstream.

Afterwards rebase your local branch with the upstream changes git rebase -i upstream/master.

GitHub documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks

$data = var_export($this->cache, true);
$currentChecksum = crc32($data);

if ($this->getLastChecksum() == $currentChecksum)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will never be true, the checksum computed from file use the whole file content while the current one use only the data.

@blizzz blizzz mentioned this pull request Feb 1, 2023
@skjnldsv skjnldsv mentioned this pull request Feb 23, 2023
@blizzz blizzz mentioned this pull request Mar 7, 2023
@blizzz blizzz removed this from the Nextcloud 26 milestone Mar 9, 2023
@blizzz
Copy link
Member

blizzz commented Mar 9, 2023

Any reason this PR is against stable24? Do we have a equivalent for master?

@kesselb kesselb closed this Mar 9, 2023
@kesselb
Copy link
Contributor

kesselb commented Mar 9, 2023

Closing the pull request due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants