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

chore(tinygo): Add -no-debug build flag in examples #387

Merged
merged 1 commit into from
Apr 24, 2022

Conversation

adamreese
Copy link
Member

Adding the --no-debug build flag reduces the wasm binary file size
significantly.

For example building examples/http-tinygo before was 764K. Now it's
reduced to 221K.

Adding the --no-debug build flag reduces the wasm binary file size
significantly.

For example building examples/http-tinygo before was 764K.  Now it's
reduced to 221K.
@lann
Copy link
Collaborator

lann commented Apr 22, 2022

Do we lose good backtraces with this?

@adamreese
Copy link
Member Author

Here is the difference when calling a panic with WASMTIME_BACKTRACE_DETAILS=1

2022-04-22T16:08:02.068361Z ERROR spin_http_engine: Error processing request: wasm trap: wasm `unreachable` instruction executed
wasm backtrace:
    0:  0xe57 - runtime.abort
                    at /opt/homebrew/Cellar/tinygo/0.22.0/src/runtime/runtime_tinygowasm.go:61:6
              - runtime._panic
                    at /opt/homebrew/Cellar/tinygo/0.22.0/src/runtime/panic.go:13:7
2022-04-22T16:08:47.032766Z ERROR spin_http_engine: Error processing request: wasm trap: wasm `unreachable` instruction executed
wasm backtrace:
    0:  0xe43 - <unknown>!runtime._panic

@adamreese
Copy link
Member Author

Doesn't reference anything in user code.

@lann
Copy link
Collaborator

lann commented Apr 22, 2022

Oh right, wasmtime wants WASMTIME_BACKTRACE_DETAILS=1 to inline guest stack traces:

2022-04-22T16:40:42.225817Z ERROR spin_http_engine: Error processing request: wasm trap: wasm `unreachable` instruction executed
wasm backtrace:
    0:  0xe4f - runtime.abort
                    at /usr/lib/tinygo/src/runtime/runtime_tinygowasm.go:61:6
              - runtime._panic
                    at /usr/lib/tinygo/src/runtime/panic.go:13:7
    1: 0x27cec - main.panic_here
                    at /home/lann/f/spin/examples/http-tinygo-outbound-http/main.go:13:7
    2: 0x27c87 - main.init#1$1
                    at /home/lann/f/spin/examples/http-tinygo-outbound-http/main.go:18:13
    3: 0x27859 - spin_http_handle_http_request
                    at /home/lann/f/spin/sdk/go/http/internals.go:34:9
    4: 0x27f4a - __wasm_export_spin_http_handle_http_request
                    at /home/lann/f/spin/sdk/go/http/spin-http.c:113:3

With -no-debug:

2022-04-22T16:41:28.891321Z ERROR spin_http_engine: Error processing request: wasm trap: wasm `unreachable` instruction executed
wasm backtrace:
    0:  0xe3b - <unknown>!runtime._panic
    1: 0x27666 - <unknown>!main.panic_here
    2: 0x27601 - <unknown>!main.init#1$1
    3: 0x271e7 - <unknown>!spin_http_handle_http_request
    4: 0x278be - <unknown>!__wasm_export_spin_http_handle_http_request

Which...really isn't terrible as a default.

@radu-matei radu-matei merged commit d376818 into fermyon:main Apr 24, 2022
@adamreese adamreese deleted the chore/no-debug-tinygo branch April 25, 2022 14:36
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.

3 participants