eduardolundgren / tracking.js

A modern approach for Computer Vision on the web
http://trackingjs.com
Other
9.44k stars 1.45k forks source link

Using asm.js for performance sensitive utility functions #156

Open TikiTDO opened 8 years ago

TikiTDO commented 8 years ago

I noticed a few of the most performance intensive utility functions (all the Image utility functions, and possibly the Fast/Brief implementations) are written in plain Javascript, when all they really do is work with scalars and big buffers. These would be great candidates to be rewritten into something that compiles into asm.js.

Is there a particular reason why this shouldn't be done? If not I could throw together some proof of concepts.

eduardolundgren commented 8 years ago

When they were written asm.js were not there. I would love to see some prototype, sounds promising.

paprikka commented 8 years ago

It seems like there's a potential significant performance gain if we decide to move some of the tracking functions to C. I wouldn't be surprised if trackColor_ worked at least several faster once ported (I've been playing with it a bit, but my C's a bit rusty, so it'll take some time till I have anything worth talking about (ran on quad core i7 3.2 ghz / 16gb ram). Anyway, this would be my first candidate. Also, good job on optimising this stuff using plain JS, really impressive.

cirocosta commented 8 years ago

hey @paprikka , great to know!

Do you have any branch in a fork of yours that we could take a look and eventually help you with that? Taking trackColor as the first candidate (i suppose it's the most straightforward to implement) looks like a great way of validating that

puzrin commented 6 years ago
  1. Not asm.js but WebAssembly.
  2. Speed benefit in benchmarker is ~ 5-20%, if javascript is optimized well (that's my experience). But another profit is that performance become much more stable.

You may fin useful https://github.com/nodeca/multimath to create universal and small math modules in WA/JS.