Hacker News new | past | comments | ask | show | jobs | submit | azakai's comments login

You can open a large file using a File or Blob, which do not store all the data in memory at once. Then you can read slices from it. That even works synchronously, in Workers:

https://developer.mozilla.org/en-US/docs/Web/API/FileReaderS...


Yes, I have done this. But sometimes you need a large chunk of data in memory and things get dicey quickly.

A related example is image editing software like Adobe Photoshop on the Web. Large images can require more then 4GB in many cases.

There is also Wasmnizer-ts, which compiles TypeScript to WasmGC:

https://github.com/web-devkits/Wasmnizer-ts

How does Jaws compare to that?


I haven't seen Wasmnizer before. This looks like a cool project and I'll be definitely taking a closer look when I have some time, but for now I just took a quick peek.

The main difference is obviously TypeScript vs JavaScript. Because they are not bothering with JavaScript, some stuff is much easier, like for example if a function specifies an argument as `number`, you can statically compile it to use a type representing a number (possibly even without heap allocations) instead of passing something like `anyref` everywhere and doing typechecks.

The second big difference is that they seem to use types imported form the host. This means they can implement part of the types/builtins/methods on the host (which is easier, cause in JavaScript you simply use JavaScript for defining host stuff) at a cost of doing more calls from WASM to the host. And then you need the host to implement those functions (here is an example for JS host: https://github.com/web-devkits/Wasmnizer-ts/blob/main/tools/...). My plan for Jaws is to only rely on WASI, so that you can run your program on any runtime that supports WASI.

I'm also not sure about their approach to semantics. I can't quite grasp how they implement for example scopes. I tried to compile a small TS script that relies on scope, like:

  let message: string = 'Hello, World!';

  function test() {
    console.log(message);
  }

  test()
And the result was console.log printing null. I'm not sure if I'm doing something wrong or is it expected, but I'll ask them in an issue later.

Do you have any plans to be able to take TypeScript types to do type optimizations? That sounds like a bonus to me to be able to have easier implementation and faster run times.

Yup, that's something that I would definitely like to do. In performance critical applications adding type information can speed up things quite a lot, especially when you think about numbers. At the moment I have to pass numbers as structs with one f64 field, because an argument to a function in Javascript can be any available type. If the type is specified, the signature or return type can use f64 types directly and don't even do heap allocations. But even for heap allocated types it may result in better performance, cause at the moment for each object I have to check what type it is and what path to take in order to proceed.

Interesting, thanks! And good luck with your project.

Sharing GC data between wasm modules is supported, yes. You just need to define the types identically on both sides, and things work.

They address the possibility of memorization in the PDF:

> This effect cannot be explained by memorization since < 1.41% of the initial puzzle board states appear in our training set.


> I couldn't figure out a way to to get emscripten wasm code to play nice with wasm32-unknown-unknown

There is good news there, some people plan to get Emscripten and Rust to work well together in Wasm:

https://github.com/rustwasm/wasm-bindgen/pull/4014#issuecomm...


They also support MicroPython as an option now and not just Pyodide,

https://pyscript.net/tech-preview/micropython/about.html

In fact the main PyScript site uses MicroPython now, I see in the dev console (micropython.mjs and micropython.wasm).


Direct link to playable wasm version:

https://phoboslab.org/high_impact/biolab/


the number of layers it takes to get it to work on my phone is so high, but it's amazing.


I'm not sure there is a clear separation between applying heuristics and searching a space. Often in compilers you search a subset of a space using heuristics, and you can adjust those to control how much of the space you cover.

For example, here is a pass that reorders WebAssembly globals in the Binaryen optimizer:

https://github.com/WebAssembly/binaryen/blob/main/src/passes...

We have a simple criteria for the quality of a solution - how big the binary size is with an order - but the space of possible orders is huge (every permutation that keeps every global after its dependencies). What we do is a targeted search of that space using some heuristics using parameters that work well enough and aren't too slow in practice.


> I'm not sure there is a clear separation between applying heuristics

There is and it's quite simple: if your heuristic reduces the size of your search space faster than it takes to perform the search (ie try solutions) then you have a real algo on your hands. Otherwise you're just searching. This is basically the border between P and NP and it's just that in compilers most of the problems are NP hard so none of the heuristics are really that good.


I disagree with this part of your comment:

> then you have a real algo on your hands

To me an algorithm is closed, while a heuristic (aka rule of thumb) is just a fast way to probably get a better solution / subset of the solution space at the cost of possibly missing the optimal result or even ending up in a pessimal corner case.

With an NP complete problem you'd rather have some solution rather than use up your lifetime searching for the best.


> To me an algorithm is closed

i dunno what "closed" means here? converges? lots of things with heuristics converge...

most things people think of as algorithms are just heuristics codified. take for example unit propagation in DPLL (fairly modern SAT approach); quoting wiki[1]

> In practice, this often leads to deterministic cascades of units, thus avoiding a large part of the naive search space.

that *in practice* there means there's no guarantee because ofc not - otherwise they would've proven something about NP. but they didn't, they just came up with a way to search that's sometimes/often not bad. a lot of people call this an algorithm ("... is a refinement of the earlier Davis–Putnam algorithm") because it fits the dictionary definiton (a repeatable process) but i do not because it's a repeatable process that isn't proven to produce anything (ie faster than brute force). and the intuition i'm proposing for why it doesn't is because it doesn't actually shrink the search space fast enough.

note, my definitions/intuitions don't translate/have the same force elsewhere (especially in continuous/differentiable spaces) but they're a pretty standard/obvious perspective in combinatorial optimization (np-hard/np-complete problems).

[1] https://en.wikipedia.org/wiki/DPLL_algorithm#The_algorithm


Adding a comment here to note that the post was just updated to clarify that:

https://web.dev/case-studies/google-sheets-wasmgc#the_final_...

> The final result

> After all these optimizations, the final WasmGC version of Sheets achieves a calculation performance approximately twice as fast as JavaScript, representing a fourfold improvement from the starting point of the initial WasmGC version.


Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: