Performance Impact of Eval

33 views
Skip to first unread message

MalteU

unread,
Sep 29, 2008, 10:29:04 AM9/29/08
to v8-users
Hi,

I have a questions relating to the performace impact of using eval. We
will of course benchmark this, too, but of course benchmark sometimes
lie.

For the JS meta system Joose http://code.google.com/p/joose-js/ we are
evaluating changing the attribute meta class in way that getter and
setter methods for attributes are created using eval instead of
closures. Those uses of eval will almost always happen at "compile
time".
Initial benchmarking show that using eval improves runtime performance
by about 20-50% depending on the JS engine.

Are there reasons (e.g. slower compilation of JS) against using eval
for this use case?

Cheers
Malte

Feng Qian

unread,
Oct 1, 2008, 5:01:10 PM10/1/08
to v8-u...@googlegroups.com
Eval itself is expensive in V8 because it has to compile the code and
run once, then throw it away.

V8 added CompilationCache recently, it might help. If the same source
code is eval'ed more than once, the second time pays no compilation
cost if the cache is hit. I don't remember when the cache entry is
evicted, check the source code.

Reply all
Reply to author
Forward
0 new messages