Re:You can now run WebAssembly on Cloudflare Workers
by zackbloom on Monday October 01, 2018 @02:38PM
(#18115527)
Each person can take their own meaning away from this, but for me the most impressive part will always be @kentonv's hand-rolled libc replacement: https://github.com/cloudflare/cloudflare-workers-wasm-demo/b...
[ Parent
| on HN ]
Re:You can now run WebAssembly on Cloudflare Workers
by citilife on Monday October 01, 2018 @05:08PM
(#18116828)
Everyone who's in CS at UIUC has to write their own libc replacement:
http://cs241.cs.illinois.edu/malloc.html
There is (or at least was) a score board you can compare against. By the end of the MP, there are usually handful beating libc.
The thing is.. libc is battle tested, so I'd always trust it over a hand rolled solution. It's always interesting to see improvements though (usually at a cost).
Re:You can now run WebAssembly on Cloudflare Workers
by tyingq on Monday October 01, 2018 @08:36PM
(#18117944)
True enough, but if you follow the link in GP, it's not really a libc replacement. For example, free() is a no-op. It's a drastically small subset of libc.
Re:You can now run WebAssembly on Cloudflare Workers
by weberc2 on Monday October 01, 2018 @09:39PM
(#18118184)
> libc is battle tested
I'm confused; isn't libc an interface and not an implementation?
Re:You can now run WebAssembly on Cloudflare Workers
by tejasmanohar on Monday October 01, 2018 @11:51PM
(#18118685)
OP probably means glibc
Re:You can now run WebAssembly on Cloudflare Workers
by 1_player on Monday October 01, 2018 @03:27PM
(#18115951)
// Really trivial malloc() implementation. We just allocate bytes sequentially from the start of
// the heap, and reset the whole heap to empty at the start of each request.
extern byte __heap_base; // Start of heap -- symbol provided by compiler.
byte* heap = NULL; // Current heap position.
void* last_malloc = NULL; // Last value returned by malloc(), for trivial optimizations.
void* malloc(size_t n) {
last_malloc = heap;
heap += n;
return last_malloc;
}
Am I missing something? How can this work? __heap_base is never used, so first malloc returns a pointer to (void * )NULL;Shouldn't it be:
byte *heap = &__heap_base;
or something to that effect?I haven't read the rest of the code, nor know how WebAssembly works, but I can't make sense of that snippet.
Re:You can now run WebAssembly on Cloudflare Workers
by Arnavion on Monday October 01, 2018 @03:36PM
(#18116046)
https://github.com/cloudflare/cloudflare-workers-wasm-demo/b...
// init() is called from JS to allocate space for the image file.
byte* init(size_t image_size) {
// Reset the heap to empty. (See malloc() implementation in bootstrap.h.)
heap = &__heap_base;
Re:You can now run WebAssembly on Cloudflare Workers
by 1_player on Monday October 01, 2018 @03:38PM
(#18116065)
Ah, I just had to look harder. Thanks
Re:You can now run WebAssembly on Cloudflare Workers
by kentonv on Tuesday October 02, 2018 @10:09AM
(#18121810)
TBH I did not expect people would actually be looking that closely. :)
Re:You can now run WebAssembly on Cloudflare Workers
by jgrahamc on Monday October 01, 2018 @02:49PM
(#18115625)
You're no C programmer, Zack. Anyone who's done any real C programming has implemented their own malloc.
Re:You can now run WebAssembly on Cloudflare Workers
by geofft on Monday October 01, 2018 @02:55PM
(#18115679)
(Is this an in-joke I'm missing or something?)
Re:You can now run WebAssembly on Cloudflare Workers
by Smerity on Monday October 01, 2018 @03:16PM
(#18115869)
It's polite ribbing amongst work colleagues where an engineer at Cloudflare (@zackbloom) offers praise to a colleague (@kentonv) for a mighty project (libc replacement) and Cloudflare's CTO (@jgrahamc) jokes that the project isn't hardcore enough ;)
tldr; Appears very much an in-joke between work colleagues at Cloudflare :)
Re:You can now run WebAssembly on Cloudflare Workers
by jgrahamc on Monday October 01, 2018 @03:18PM
(#18115897)
Correct. Not so much an in-joke. I was just surprised Zack thought implementing your own libc was amazing. But I'm an old fart C/assembly programmer so YMMV.
Re:You can now run WebAssembly on Cloudflare Workers
by zackbloom on Monday October 01, 2018 @04:26PM
(#18116525)
Having the top-comment doesn't lie, THE PEOPLE ARE WITH ME!
Also, is there a badge or sash I can get somewhere saying "Not a Real C Programmer"?
Re:You can now run WebAssembly on Cloudflare Workers
by enneff on Monday October 01, 2018 @10:53PM
(#18118497)
How about a badge for "I got schooled publicly by my CTO."
Re:You can now run WebAssembly on Cloudflare Workers
by jgrahamc on Monday October 01, 2018 @11:32PM
(#18118624)
Ha. I wasn't really schooling him, just ribbing him. He knows damn well he could run circles around me in JavaScript.