HN user

mnemonik

4,596 karma
Posts275
Comments254
View on HN
bytecodealliance.org 1y ago

Making WebAssembly and Wasmtime More Portable

mnemonik
3pts0
bytecodealliance.org 1y ago

New Stack Maps for Wasmtime and Cranelift

mnemonik
3pts0
bytecodealliance.org 3y ago

Security and Correctness in Wasmtime

mnemonik
77pts16
bytecodealliance.org 3y ago

Wasmtime 1.0: A Look at Performance

mnemonik
99pts22
fitzgeraldnick.com 8y ago

How does dynamic dispatch work in WebAssembly?

mnemonik
98pts19
fitzgeraldnick.com 8y ago

Speed Without Wizardry

mnemonik
206pts69
hacks.mozilla.org 8y ago

Oxidizing Source Maps with Rust and WebAssembly

mnemonik
207pts30
bholley.net 8y ago

How Stylo Brought Rust and Servo to Firefox

mnemonik
639pts191
technomancy.us 10y ago

In which a spacefaring text editor holds up against an onslaught

mnemonik
3pts0
medium.com 10y ago

Browsers, Innovators Dilemma, and Project Tofino

mnemonik
13pts0
hacks.mozilla.org 10y ago

Compiling to WebAssembly: It’s Happening

mnemonik
306pts216
wingolog.org 10y ago

Two paths, one peak: a view on high-performance language implementations

mnemonik
9pts0
hacks.mozilla.org 10y ago

Developer Edition 44: New visual editing and memory management tools

mnemonik
7pts0
fitzgeraldnick.com 10y ago

Back to the Futu-Rr-e: Deterministic Debugging with Rr

mnemonik
61pts9
bholley.net 11y ago

Must Be This Tall to Write Multi-Threaded Code

mnemonik
146pts112
hacks.mozilla.org 11y ago

Compacting Garbage Collection in SpiderMonkey

mnemonik
24pts0
fitzgeraldnick.com 11y ago

Source Maps Are an Insufficient Debugging Format for the Web

mnemonik
71pts13
www.bloomberg.com 11y ago

A Bay Area Startup Spins Lab-Grown Silk

mnemonik
39pts13
hacks.mozilla.org 11y ago

ES6 in Depth: Destructuring

mnemonik
128pts96
vijayan.ca 11y ago

The Smartphone as Application Server

mnemonik
54pts10
fitzgen.github.io 11y ago

Show HN: Oxischeme – A Scheme implementation in Rust

mnemonik
18pts0
javascriptjake.com 11y ago

Giving

mnemonik
2pts0
rfrn.org 11y ago

Making SpiderMonkey's Debugger Just-In-Time

mnemonik
7pts0
fitzgen.github.io 11y ago

Show HN: Wu.js – Higher order functions for ES6 iterators

mnemonik
56pts4
ocharles.org.uk 12y ago

In Praise of EitherT

mnemonik
1pts0
www.slideshare.net 12y ago

Blazing Performance with Flame Graphs (2013)

mnemonik
2pts0
fitzgeraldnick.com 12y ago

Beyond Source Maps

mnemonik
53pts22
www.sfgate.com 12y ago

How San Francisco creates its own housing crisis

mnemonik
1pts0
fitzgeraldnick.com 12y ago

Hiding Implementation Details with ECMAScript 6 WeakMaps

mnemonik
1pts0
hacks.mozilla.org 12y ago

Firefox Developer Tools: Split console, pretty-print minified JS and more

mnemonik
24pts0

Yes, you can use the component model (and other tooling like WIT) without using WASI.

Yes, the component model is a standard developed under the umbrella of the W3C's WebAssembly Community Group.

That said, while it is relatively stable and hasn't changed much in the last year or so, the component model has not graduated through all the phases of the standardization process yet. It doesn't, for example, have a formal specification yet, although its canonical ABI does have a reference implementation in Python.

https://github.com/WebAssembly/component-model/

Wasmtime 1.0 4 years ago

There is a section in the linked announcement titled "Why use a WebAssembly Runtime?" that hopefully answers your question.

There is a DOM story: host bindings. It just isn't implemented yet.

However, that doesn't mean that you can't use it now. wasm-bindgen is essentially a polyfill for host bindings plus some other little things.

Some resources to check out if you want to learn more:

* Host bindings: https://github.com/WebAssembly/host-bindings/blob/master/pro...

* More info about web-sys (web-sys is like the raw libc for the web): https://rustwasm.github.io/wasm-bindgen/web-sys/index.html

* API documentation for web-sys: https://docs.rs/web-sys/0.3.2/web_sys/

* DOM hello world example: https://rustwasm.github.io/wasm-bindgen/examples/dom.html

* A mini MS Paint style example: https://rustwasm.github.io/wasm-bindgen/examples/paint.html

* An FM synth in WebAudio: https://rustwasm.github.io/wasm-bindgen/examples/web-audio.h...

Thanks for the heads up. It used to be a `thread_local!`, but switching to a `static mut` resulted in smaller code size. I just forgot to update the code snippet in the article.

which IIRC requires unsafe access as it's not thread-safe

Yes, and also has no guarantees against mutably aliasing and re-entry.

Note that wasm currently has no shared memory threading (just message passing via FFI through JS and workers), so thread-safety isn't an issue to be wary of here, just re-entry.

Can you file bug(s) with links to the crash report(s) in about:crashes?

Alternatively, you could email me your crash reports (email in profile) and I could file bug(s) for youe.

Up until a couple months ago, it had an O(n^2) marking algorithm that kept iterating until it got to a fixed point.

Thanks to the hard work of Steve Fink, these days it has an O(n) marking algorithm. See https://bugzilla.mozilla.org/show_bug.cgi?id=1164294 for the details.

Edit to address your questions more directly:

how aggressive is Firefox in holding on to weakly referenced objects?

They are just collected at the next GC slice where they are no longer retained. SpiderMonkey doesn't do anything to try and eagerly collect them. GC slices generally won't happen until either there has been enough pressure (allocations) to trigger one or the user is inactive for N amount of time. There are tons of GC triggering heuristics and some are probably not optimal. It is on the GC team's TODO list to revisit and clean these up.

does Firefox always continue to allocate memory from the host OS, or is there some threshold where it starts to let things slip?

The threshold of how much is allocated before triggering GC grows as the retained set's size grows. This is bounded by available memory.

Aaaaand I have a meeting I need to go attend.

Yes it is. I also wrote more about the backend implementation on lobste.rs <https://lobste.rs/s/cvtz0x/firefox_s_new_memory_tool >:

Hi folks,

For the last year or so, my coworker Jim Blandy and I have been designing and implementing APIs in SpiderMonkey (Firefox’s JavaScript engine) to support various kinds of memory allocation/retention introspection. We are finally shipping a frontend to users as well, and this blog post is an intro to that. This is very much the tip of the iceberg and we wanted to just start shipping since we’ve been building APIs for so long, but this is really a fraction of the things planned. Nightly already has filtering/searching and will soon have import/export of snapshots as well as diffing <http://i.imgur.com/qjWOERs.gif >. Dominator trees and shortest paths from GC roots are incoming as well.

How is this built?

We made an abstraction called “ubi::Node” <https://dxr.mozilla.org/mozilla-central/rev/a8ed7dd831d1969a... > (for “ubiquitous node”) that sees the GC’s heap graph with a traditional nodes-and-edges view so that we don’t have to worry about the difference between (say) an object and some jit code when writing graph analyses. What is cool is that this interface can be backed by either the live heap graph or an offline heap graph. When you save a heap snapshot, we traverse this graph and serialize it into protobuf messages. These can then be reconstructed into an offline graph which you can run analyses on at your leisure.

We also make pretty extensive use of stack capturing, because that is a concrete way to tie retention and GC pressure back to something that feels concrete to users: locations in their source code. I’ve written a bit about how we minimize the overhead of (potentially very frequent) stack captures before by hash consing individual frames so that tails are shared <http://fitzgeraldnick.com/weblog/61/ >. Since then, we have also found a neat way to avoid walking the stack repeatedly if we have already done so once.

If anyone has any questions, please ask away :)

And I made a quick update:

Also, Jim loved writing this comment so much (it is a fun read) that I feel I have to share it :)

https://dxr.mozilla.org/mozilla-central/rev/a8ed7dd831d1969a...

We use this for sampling object allocations to give insight into GC pressure.

Note that the proposal you linked is solving a different (albeit related) problem compared to what I discuss in the article.

That proposal is about formatting the JS-implementation of Java/Clojure/etc specific objects/types at the source-level.

The article is discussing how to even locate a binding's value. The more aggressive your compiler, and the further your source language from JS, the more this becomes a problem that needs solving. However, this is also a problem for people that simply need to debug minified JS and don't want to figure out which source-level variable "aB" refers to, or struggle to figure out that some other source-level constant variable was inlined and can't be inspected by the debugger anymore.

Neither of the two solutions need to block progress on the other. Neither of the two wholly fixes the other's problem, either.

FWIW, I've found the Guide incredibly helpful, and in general found the docs very satisfying. (Although I do wish the pointers guide was more complete :) )

The API docs + search in the docs are incredible IMO. I'm in absolute love with rustdoc. Having links to the source right there is the most valuable thing ever, both when trying to understand how to use a given API, and when trying to write similar things its really useful to be able to look at how others have done things.

All of the potential partnerships (including going with Google again) offered an improvement economically over the last deal partnership.

Mozilla chose not to go with Google again.

This is a great question, thanks for asking.

For crashes, definitely submitting the crash report found in about:crashes helps a ton.

Checking the browser console for an error message + stack and pasting that in a bug + description of bad behavior can be useful.

Finally, in extreme cases you can enable all the devtools logging[0] and then run firefox while piping stdout into a log file. This is a firehose of information, but it should hopefully point to the part of the code base that is misbehaving.

[0] https://wiki.mozilla.org/DevTools/Hacking#Enabling_DevTools_...

It might be just me, but it's very common when I use the JavaScript debugger in Firefox that it either freezes the site, the debugger, or Firefox itself.

If you have a test case and steps to reproduce, please file a bug! We can't usually fix the bugs we don't know about.