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

Do not extract embedded app on every execution #488

Merged
merged 4 commits into from
Jan 21, 2024

Conversation

pierredup
Copy link
Contributor

When embedding a large app (in my case around ~700mb), the app checksum is calculated and the tar is extracted on every execution of the binary.

This slows down the execution (running php-cli takes around ~8 seconds) since this process needs to run every time. Instead, we can extract the app only once and re-use the same files for every execution.

Another drawback of the current process, is that when the web-server is running (using php-server), and you want to run a cli command, then it would remove and re-extract the tar while the webserver is still running.

The PR adds the following changes:

  • Calculate the checksum at build-time instead of runtime, and embed the checksum in the binary
  • Only untar the archive if it doesn't exist already on the filesystem

Copy link
Owner

@dunglas dunglas left a comment

Choose a reason for hiding this comment

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

Good idea!

Could we also try to cleanup outdated directories after an upgrade?

embed.go Outdated Show resolved Hide resolved
embed.go Outdated Show resolved Hide resolved
@pierredup
Copy link
Contributor Author

Could we also try to cleanup outdated directories after an upgrade?

The directory name should probably then also contain the app name (or some other unique identifier). If we just clear all the frankenphp_* folders in the temp directory, then we might clear the files of a different FrankenPHP app.

@dunglas
Copy link
Owner

dunglas commented Jan 20, 2024

Ok, it's more complex. Let's let the OS do the cleanup for now.

@dunglas dunglas merged commit 6f108a4 into dunglas:main Jan 21, 2024
28 checks passed
@dunglas
Copy link
Owner

dunglas commented Jan 21, 2024

Thank you!

@pierredup pierredup deleted the embedded-app-startup-performance branch January 21, 2024 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants