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

Tiny devices #1

Open
mcollina opened this issue Apr 1, 2014 · 14 comments
Open

Tiny devices #1

mcollina opened this issue Apr 1, 2014 · 14 comments

Comments

@mcollina
Copy link

mcollina commented Apr 1, 2014

It seems libuv runs only on unixes and Windows. Are you still aiming at small devices running these operating systems (say OpenWRT), or are you aiming also at embedded devices?

Anyway, I'm in. I see a big potential in this!

@creationix
Copy link
Owner

By tiny, I mean things like arm linux boxes with ~128mb of ram. These things can run node, but not well and not many instances.

It would be cool if we could run on things like my $10 TP-Link router I picked up in China. These devices have a slow MIPS cpu, tiny flash drives and around 8-16mb of ram running a minimal linux. I've seen them run lua so I expect they can run duktape. I'm not sure what it would take to get libuv on them.

@dominictarr
Copy link
Collaborator

how heavy is libuv? there isn't that much code... and it doesn't manage memory for you.
I don't really see how it would require headroom that 8mb doesn't have, provided that you used an allocator that made sense in low mem.

@creationix
Copy link
Owner

It's not too heavy. Luvit which includes luajit + libuv + openssl + zlib + node API shims written in lua clocks in at around 1.5MB (vs about 11mb for node)

@creationix
Copy link
Owner

Stock lua + libuv (luv bindings) loads a repl at 1mb rss.

@creationix
Copy link
Owner

For comparison, the stock lua repl included in lua is 1.1mb. So libuv is more efficient than whatever is baked into lua.

@creationix
Copy link
Owner

@mcollina I don't think I'm even going to attempt to run libuv and a JavaScript runtime on a microcontroller. Is there prior art in this kind of experiment?

@dominictarr
Copy link
Collaborator

espriuno has a very low mem js runtime, but it is very slow (trades mem for cpu) it evals it as it parses it, i understand, instead of building an ast etc. of course, in a microcontroler you arn't gonna have a kernel so a polyfil for posix doesn't make sense anyway.

@svaarala
Copy link
Contributor

svaarala commented Apr 3, 2014

Duktape runs on embedded devices with 128 kB RAM right now (hello world RAM footprint is around 80 kB), and there's ongoing effort to get the hello world footprint lower. An event loop is often needed for these environments too, but only a very bare bone one: timers, and perhaps some networking. I think that a separate event loop library for these very tight environments makes sense, while DukLuv would work well for environments with at least a few megabytes of memory.

@creationix
Copy link
Owner

@svaarala wow, that's really impressive! How does that compare to stock lua and embedded lua?

You're right that libuv is way too much for that kind of device, but it sure is nice and provides a lot of primitives for devices that can run it.

@prust
Copy link

prust commented Oct 12, 2015

Sorry to comment on an old thread, but have you looked at mbed TLS (formerly PolarSSL -- libcurl supports compiling with it) as a lightweight alternative to OpenSSL and miniz (github) as a lightweight alternative to zlib?

There are times when it would be nice to have the full node.js API, but there are other times when I would prefer a small, self-contained executable with just the pieces I need (even avoiding libuv when it isn't necessary).

@creationix
Copy link
Owner

Thanks for the links. I'm actually using miniz for luvit.io (with a few patches I added to fix it's buggy zip file support.) We're still using openssl, but I think switching to mbed would shrink the binary a bit. I'll look into doing the same for dukluv when I get back to working on this.

@prust
Copy link

prust commented Oct 13, 2015

@creationix: Great! Are the patches included in https://github.com/creationix/dukluv/blob/master/lib/miniz.c ?

@prust
Copy link

prust commented Oct 13, 2015

Follow-up: it looks like the CRC patch (luvit/luvi#113) is included in dukluv's copy of miniz.

@creationix
Copy link
Owner

Right, when in doubt, look at luvit's miniz code, I try to copy all patches here, but sometimes forget.

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

No branches or pull requests

5 participants