Skip to content

Remove remainder of support for external startup data #1758

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

Merged
merged 3 commits into from
May 16, 2023

Conversation

ptomato
Copy link
Contributor

@ptomato ptomato commented Apr 19, 2023

Description

As per NativeScript/NativeScript#8926, external startup data is no longer supported. We can gain a small amount of size savings by building V8 with support for external startup data switched off.

Without the machinery to load an external snapshot from a file, nothing is using MemoryMappedFile any longer, so we can remove it. File::Exists has one remaining usage, but that usage is redundant, so we can remove it as well.

As you can see in this PR, the V8 libraries get slightly larger (30–40 kb depending on architecture) because they now include the snapshot internally. But the total size of an APK shrinks, because we don't need to link the external startup data into the runtime. I tested with a hello world app, and got -564 kb for debug, -23 kb for release.

We also don't need to separately commit snapshot_blob.h to this repo anymore, which makes the process for modifying V8 slightly easier.

The V8 artifacts added in this PR were built from my fork of v8-buildscripts, with commits from NativeScript/v8-buildscripts#2 ported to all the Android branches. Unfortunately I had to delete and recreate my fork in order to open the PR (I guess because I forked it when the repo was private?) so the jobs that created those artifacts are gone. In order to establish provenance for the artifacts, what I'd recommend is to review and merge NativeScript/v8-buildscripts#2 first and port it to the other Android branches, then we can rebuild all 4 of them and I'll update this PR with the resulting artifacts from those jobs.

Related Pull Requests

Does your pull request have unit tests?

No tests; all functionality should be unchanged, except that the heapSnapshotScript and snapshot.blob config options should now be ignored completely.

@cla-bot cla-bot bot added the cla: yes label Apr 19, 2023
ptomato added 3 commits May 5, 2023 13:13
As per NativeScript/NativeScript#8926, this
isn't supported. "heapSnapshotScript" and "heapSnapshotBlob" keys in
package.json will be ignored, but I believe this isn't a breaking change
because I think they were already nonfunctional.

The V8 library is updated with a build configured with
v8_use_external_startup_data=false, and we can remove the snapshot_blob.h
files because the snapshot data no longer needs to be compiled into the
runtime.

The V8 artifacts were built using NativeScript/v8-buildscripts and GitHub
Actions, with the following provenance:

arm64: commit 0368bca, job https://github.com/NativeScript/v8-buildscripts/actions/runs/4895461273
arm: commit b074e10, job https://github.com/NativeScript/v8-buildscripts/actions/runs/4895462464
x86_64: commit a9bf41b, job https://github.com/NativeScript/v8-buildscripts/actions/runs/4895463287
x86: commit e7aa7ed, job https://github.com/NativeScript/v8-buildscripts/actions/runs/4895464030
This was primarily used by the heap snapshot code which is now removed.

It was also used internally in File::ReadBinary(), but that wasn't
necessary, as fopen() also handles the file not existing.

In new code, it's probably a good idea to perform operations without
checking if the file exists first anyway, as otherwise it can lead to race
conditions if the file is deleted.
This was only used by the snapshot code, which is now removed.
@ptomato
Copy link
Contributor Author

ptomato commented May 5, 2023

I've updated the artifacts with information on how they were built using NativeScript/v8-buildscripts. This is ready for review/merge now.

@triniwiz triniwiz merged commit 016041e into NativeScript:main May 16, 2023
@ptomato ptomato deleted the rm-snapshot branch May 16, 2023 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants