Skip to content

Commit

Permalink
fix(xsnap): take snapshot without impact on GC #3607
Browse files Browse the repository at this point in the history
Moddable reworked the chunk allocator to always use a single memory block for chunk storage.

The change is implemented in `xsnapPlatform.c`. The implementation uses `mmap`/`mprotect` (`VirtualAlloc` on Windows) to reserve and to commit memory pages. 

To get this fix, we add an `xsnap-native` submodule that replaces `xsnap.c` and friends.
The submodule includes a few tweaks: https://github.com/agoric-labs/xsnap-pub/tree/endo-submodule

fixes #3577
fixes #3139 , bringing us back to stock XS.
fixes #2469 - Moddable reviewed the code well enough to substantially re-work it.
  • Loading branch information
dckc authored Aug 14, 2021
2 parents a861c78 + 66f9cde commit 85b252c
Show file tree
Hide file tree
Showing 24 changed files with 347 additions and 2,449 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ jobs:
run: echo "GIT_REVISION=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Save SDK_VERSION
run: echo "SDK_VERSION=$(jq -r .version package.json)" >> $GITHUB_ENV
- name: Save MODDABLE_COMMIT_HASH, MODDABLE_URL
- name: Save commit hash, url of submodules to environment
run: |
git submodule status packages/xsnap/moddable | \
sed -ne 's/^.\([^ ]*\).*/MODDABLE_COMMIT_HASH=\1/p' >> $GITHUB_ENV
sed -ne 's!^.*url = \(https://.*moddable\.git\).*!MODDABLE_URL=\1!p' .gitmodules >> $GITHUB_ENV
node packages/xsnap/src/build.js --show-env >> $GITHUB_ENV
- name: Build SDK image
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: agoric/agoric-sdk
dockerfile: packages/deployment/Dockerfile.sdk
buildargs: MODDABLE_COMMIT_HASH,MODDABLE_URL,GIT_REVISION
buildargs: MODDABLE_COMMIT_HASH,MODDABLE_URL,XSNAP_NATIVE_COMMIT_HASH,XSNAP_NATIVE_URL,GIT_REVISION
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
snapshot: true
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "packages/xsnap/moddable"]
path = packages/xsnap/moddable
url = https://github.com/agoric-labs/moddable.git
[submodule "packages/xsnap/xsnap-native"]
path = packages/xsnap/xsnap-native
url = https://github.com/agoric-labs/xsnap-pub
10 changes: 7 additions & 3 deletions packages/deployment/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ SS := ../cosmic-swingset/
VERSION := $(shell node -e 'console.log(require("../../package.json").version)' 2>/dev/null)

TAG := $(if $(VERSION),$(VERSION),latest)
MODDABLE_COMMIT_HASH := $(shell git submodule status ../xsnap/moddable | \
sed -ne 's/^.\([^ ]*\).*/\1/p')
MODDABLE_URL := $(shell sed -ne 's!^.* = \(https://.*moddable\.git\).*!\1!p' ../../.gitmodules)
GIT_REVISION := $(shell hash=$$(git rev-parse --short HEAD); \
dirty=`git diff --quiet || echo -dirty`; \
echo "$$hash$$dirty")
Expand All @@ -18,6 +15,9 @@ else
DONT_PUSH_LATEST := $(if $(findstring -,$(TAG)),:,)
endif

submodule.env: ../xsnap/moddable/src/build.js
node ../xsnap/moddable/src/build.js --show-env >$@

docker-show-fat:
date > show-fat-bust-cache.stamp
docker build --file=Dockerfile.show-fat ../..
Expand All @@ -28,6 +28,8 @@ docker-build: docker-build-sdk docker-build-solo \
docker-build-sdk:
docker build --build-arg=MODDABLE_COMMIT_HASH=$(MODDABLE_COMMIT_HASH) \
--build-arg=MODDABLE_URL=$(MODDABLE_URL) \
--build-arg=XSNAP_NATIVE_COMMIT_HASH=$(XSNAP_NATIVE_COMMIT_HASH) \
--build-arg=XSNAP_NATIVE_URL=$(XSNAP_NATIVE_URL) \
--build-arg=GIT_REVISION=$(GIT_REVISION) \
-t $(REPOSITORY_SDK):$(TAG) --file=Dockerfile.sdk ../..
docker tag $(REPOSITORY_SDK):$(TAG) $(REPOSITORY_SDK):latest
Expand Down Expand Up @@ -73,3 +75,5 @@ docker-push-solo:
docker-push-deployment:
$(DONT_PUSH_LATEST) docker push agoric/deployment:latest
docker push agoric/deployment:$(TAG)

-include submodule.env
2 changes: 1 addition & 1 deletion packages/xsnap/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/** The version identifier for our meter type.
* TODO Bump this whenever there's a change to metering semantics.
*/
export const METER_TYPE = 'xs-meter-9';
export const METER_TYPE = 'xs-meter-10';

export const ExitCode = {
E_UNKNOWN_ERROR: -1,
Expand Down
9 changes: 9 additions & 0 deletions packages/xsnap/doc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
See also [xsnap documentation][1] including:

- [XS Metering][2]
- [XS Snapshots][3]


[1]: https://github.com/agoric-labs/xsnap-pub/blob/endo-submodule/xsnap/documentation/
[2]: https://github.com/agoric-labs/xsnap-pub/blob/endo-submodule/xsnap/documentation/XS%20Metering.md
[3]: https://github.com/agoric-labs/xsnap-pub/blob/endo-submodule/xsnap/documentation/XS%20Snapshots.md
144 changes: 0 additions & 144 deletions packages/xsnap/doc/XS Metering.md

This file was deleted.

135 changes: 0 additions & 135 deletions packages/xsnap/doc/XS Snapshots.md

This file was deleted.

9 changes: 0 additions & 9 deletions packages/xsnap/makefiles/lin/makefile

This file was deleted.

Loading

0 comments on commit 85b252c

Please sign in to comment.