Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/no-wasm-opt' into moc-inline-wit…
Browse files Browse the repository at this point in the history
…h-new-meter
  • Loading branch information
chenyan-dfinity committed Sep 15, 2023
2 parents f11b357 + d449128 commit 8feb431
Show file tree
Hide file tree
Showing 15 changed files with 128 additions and 164 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ APPS = dapps collections crypto pub-sub heartbeat motoko

all:
$(foreach test_dir,$(APPS),make -C $(test_dir) &&) true

25 changes: 4 additions & 21 deletions collections/Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
APP = collections
include ../*.mk

.PHONY: all motoko rust build perf
all: build perf

motoko:
set -e; \
cd motoko; \
envsubst < mops.template.toml > mops.toml; \
mops install; \
dfx canister create --all; \
dfx ledger fabricate-cycles --t 100 --canister $$(dfx identity get-wallet); \
dfx build; \
rm mops.toml; \
cd ..
$(call build_with_mops,motoko)

rust:
set -e; \
cd rust; \
dfx canister create --all; \
dfx ledger fabricate-cycles --t 100 --canister $$(dfx identity get-wallet); \
dfx build; \
cd ..
$(call build,rust)

build: motoko rust

perf:
set -e; \
mkdir -p ../_out/$(APP); \
cp README.md ../_out/$(APP); \
cd ../_out/$(APP); \
ic-repl ../../$(APP)/perf.sh
$(call perf,collections,perf.sh)
23 changes: 4 additions & 19 deletions crypto/Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
APP = crypto
include ../*.mk

.PHONY: all motoko rust build perf
all: build perf

motoko:
set -e; \
cd motoko; \
envsubst < mops.template.toml > mops.toml; \
mops install; \
dfx canister create --all; \
dfx build; \
rm mops.toml; \
cd ..
$(call build_with_mops,motoko)

rust:
set -e; \
cd rust; \
dfx canister create --all; \
dfx build; \
cd ..
$(call build,rust)

build: motoko rust

perf:
set -e; \
mkdir -p ../_out/$(APP); \
cp README.md ../_out/$(APP); \
cd ../_out/$(APP); \
ic-repl ../../$(APP)/perf.sh
$(call perf,crypto,perf.sh)
19 changes: 4 additions & 15 deletions dapps/Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
APP = dapps
include ../*.mk

.PHONY: all motoko rust build perf
all: build perf

motoko:
cd motoko; \
dfx canister create --all; \
dfx build; \
cd ..
$(call build,motoko)

rust:
cd rust; \
dfx canister create --all; \
dfx build; \
cd ..
$(call build,rust)

build: motoko rust

perf:
set -e; \
mkdir -p ../_out/$(APP); \
cp README.md ../_out/$(APP); \
cd ../_out/$(APP); \
ic-repl ../../$(APP)/basic_dao.sh; \
ic-repl ../../$(APP)/nft.sh
$(call perf_two,dapps,basic_dao.sh,nft.sh)
21 changes: 4 additions & 17 deletions heartbeat/Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
APP = heartbeat
include ../*.mk

.PHONY: all motoko rust build perf
all: build perf

motoko:
cd motoko; \
envsubst < mops.template.toml > mops.toml; \
mops install; \
dfx canister create --all; \
dfx build; \
rm mops.toml; \
cd ..
$(call build_with_mops,motoko)

rust:
cd rust; \
dfx canister create --all; \
dfx build; \
cd ..
$(call build,rust)

build: motoko rust

perf:
set -e; \
mkdir -p ../_out/$(APP); \
cp README.md ../_out/$(APP); \
cd ../_out/$(APP); \
ic-repl ../../$(APP)/perf.sh
$(call perf,heartbeat,perf.sh)
19 changes: 3 additions & 16 deletions motoko/Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
APP = motoko
include ../*.mk

.PHONY: all build perf
all: build perf

build:
envsubst < mops.template.toml > mops.toml; \
mops install; \
dfx canister create --all; \
dfx build; \
rm mops.toml; \
cd ..
$(call build_with_mops,motoko)

perf:
set -e; \
mkdir -p ../_out/$(APP); \
cp README.md ../_out/$(APP); \
cd ../_out/$(APP); \
ic-repl ../../$(APP)/gc.sh; \
ic-repl ../../$(APP)/classes.sh

clean:
rm *.wasm && rm mops.toml
$(call perf_two,motoko,gc.sh,classes.sh)
2 changes: 1 addition & 1 deletion motoko/classes.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!ic-repl
load "../prelude.sh";

let class = wasm_profiling(".dfx/local/canisters/classes/classes.wasm");
let class = wasm_profiling("motoko/.dfx/local/canisters/classes/classes.wasm");
let map = install(class, encode (), null);

let file = "README.md";
Expand Down
54 changes: 0 additions & 54 deletions motoko/dfx.json

This file was deleted.

10 changes: 5 additions & 5 deletions motoko/gc.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!ic-repl
load "../prelude.sh";

let default = wasm_profiling("default.wasm", vec{"schedule_copying_gc"});
let copying = wasm_profiling("copying.wasm", vec {"copying_gc"});
let compacting = wasm_profiling("compacting.wasm", vec{"compacting_gc"});
let generational = wasm_profiling("generational.wasm", vec{"generational_gc"});
let incremental = wasm_profiling("incremental.wasm", vec{"incremental_gc"});
let default = wasm_profiling("motoko/default.wasm", vec{"schedule_copying_gc"});
let copying = wasm_profiling("motoko/copying.wasm", vec {"copying_gc"});
let compacting = wasm_profiling("motoko/compacting.wasm", vec{"compacting_gc"});
let generational = wasm_profiling("motoko/generational.wasm", vec{"generational_gc"});
let incremental = wasm_profiling("motoko/incremental.wasm", vec{"incremental_gc"});

let file = "README.md";
output(file, "\n\n## Garbage Collection\n\n| |generate 800k|max mem|batch_get 50|batch_put 50|batch_remove 50|\n|--:|--:|--:|--:|--:|--:|\n");
Expand Down
54 changes: 54 additions & 0 deletions motoko/motoko/dfx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"canisters": {
"classes": {
"type": "motoko",
"main": "src/Map.mo"
},
"default": {
"type": "custom",
"candid": "../../collections/rust/collection.did",
"wasm": "default.wasm",
"build": [
"sh -c '$(dfx cache show)/moc ../../collections/motoko/src/triemap.mo -o default.wasm --public-metadata candid:service $(mops sources)'"
]
},
"copying": {
"type": "custom",
"candid": "../../collections/rust/collection.did",
"wasm": "copying.wasm",
"build": [
"sh -c '$(dfx cache show)/moc ../../collections/motoko/src/triemap.mo -o copying.wasm --public-metadata candid:service $(mops sources) --force-gc --copying-gc'"
]
},
"compacting": {
"type": "custom",
"candid": "../../collections/rust/collection.did",
"wasm": "compacting.wasm",
"build": [
"sh -c '$(dfx cache show)/moc ../../collections/motoko/src/triemap.mo -o compacting.wasm --public-metadata candid:service $(mops sources) --force-gc --compacting-gc'"
]
},
"generational": {
"type": "custom",
"candid": "../../collections/rust/collection.did",
"wasm": "generational.wasm",
"build": [
"sh -c '$(dfx cache show)/moc ../../collections/motoko/src/triemap.mo -o generational.wasm --public-metadata candid:service $(mops sources) --force-gc --generational-gc'"
]
},
"incremental": {
"type": "custom",
"candid": "../../collections/rust/collection.did",
"wasm": "incremental.wasm",
"build": [
"sh -c '$(dfx cache show)/moc ../../collections/motoko/src/triemap.mo -o incremental.wasm --public-metadata candid:service $(mops sources) --force-gc --incremental-gc'"
]
}
},
"defaults": {
"build": {
"packtool": "mops sources",
"args": ""
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 4 additions & 15 deletions pub-sub/Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
APP = pub-sub
include ../*.mk

.PHONY: all motoko rust build perf
all: build perf

motoko:
cd motoko; \
dfx canister create --all; \
dfx build; \
cd ..
$(call build,motoko)

rust:
cd rust; \
dfx canister create --all; \
dfx build; \
cd ..
$(call build,rust)

build: motoko rust

perf:
set -e; \
mkdir -p ../_out/$(APP); \
cp README.md ../_out/$(APP); \
cd ../_out/$(APP); \
ic-repl ../../$(APP)/motoko/perf.sh; \
ic-repl ../../$(APP)/rust/perf.sh
$(call perf_two,pub-sub,motoko/perf.sh,rust/perf.sh)
45 changes: 45 additions & 0 deletions utils.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
define ic-wasm
echo "No Optimize!"
endef

define build_with_mops
set -e; \
cd $(1); \
envsubst < mops.template.toml > mops.toml; \
mops install; \
dfx canister create --all; \
dfx ledger fabricate-cycles --t 100 --canister $$(dfx identity get-wallet); \
dfx build; \
rm mops.toml; \
$(call ic-wasm,.dfx/local/canisters/); \
cd ..
endef

define build
set -e; \
cd $(1); \
dfx canister create --all; \
dfx ledger fabricate-cycles --t 100 --canister $$(dfx identity get-wallet); \
dfx build; \
$(call ic-wasm,.dfx/local/canisters/); \
cd ..
endef

define prepare_perf
mkdir -p ../_out/$(1); \
cp README.md ../_out/$(1); \
cd ../_out/$(1)
endef

define perf
set -e; \
$(call prepare_perf,$(1)); \
ic-repl ../../$(1)/$(2)
endef

define perf_two
set -e; \
$(call prepare_perf,$(1)); \
ic-repl ../../$(1)/$(2); \
ic-repl ../../$(1)/$(3)
endef

0 comments on commit 8feb431

Please sign in to comment.