try ... catch performance

38 views
Skip to first unread message

alphanull

unread,
Nov 1, 2012, 11:28:23 AM11/1/12
to q-con...@googlegroups.com
Hello,

I just poked around the Q source a bit and saw that there are quite a lot of try ... catch blocks to catch any errors. Now, this can be quite a performance impact on certain browsers. Also interesting is that this penalty seems to occur mainly when using try/catch  _inside_ a function, like it is generally done in Q. Now, if you could move these blocks so that they are _outside_ of a function call this could result in a perfiormance increase.

For the raw Numbers, take a look at this: http://jsperf.com/try-catch-performance-overhead

Maybe this particular optimization would also make sense for Q?

Kris Kowal

unread,
Nov 1, 2012, 12:56:11 PM11/1/12
to q-con...@googlegroups.com
> For the raw Numbers, take a look at this:
> http://jsperf.com/try-catch-performance-overhead
> Maybe this particular optimization would also make sense for Q?

I think you’ll find that Q already benefits from this optimization on
its hot code-paths. Except for our code that handles exception
formatting, every try/catch block in Q rapidly delegates to a
callback.

Kris Kowal
Reply all
Reply to author
Forward
0 new messages