Now, I expect this is naive of me, but I notice there is lots of
static data in the codebase. if I were to refactor this into some kind
of 'GlobalContext' class, could I not simply instantiate multiple of
those GlobalContexts without them interfering with each other?
I guess to do this I am talking about a fork of the V8 code, which is
certainly unfortunate. I'd just like to get an idea of the work
involved; I need to embed a JS engine, and none of them seem like an
exact fit for my needs; TraceMonkey and JavaScriptCore look like they
may be more heavyweight than V8, and may have more runtime
dependencies as well.
I need something as lightweight as possible (that wont cause a bloated
executable or have tons of dll-type dependencies) because the app is
installed through downloading. For reference, I have used Lua for
scripting up till now, which adds a grand total of about 300k of
executable code to the app. I don't expect to get near that value from
a JS engine, but still the smaller the better; more than a Mb or two
of code from the JS engine will probably be unacceptable.
Anyway, so, say I was to create an 'Engine' class to wrap up V8, and
stuff all the static data in there. And then either use TLS to store
an Engine reference, or modify the functions to take an 'Engine&'
parameter. Would that work? Obviously forking is bad, and modifying
lots of function signatures would be a fairly major job, but could I
expect that to be enough to deal with the locking issue?
Best Regards,
Steve
Now, I expect this is naive of me, but I notice there is lots of
static data in the codebase. if I were to refactor this into some kind
of 'GlobalContext' class, could I not simply instantiate multiple of
those GlobalContexts without them interfering with each other? Or is
there funky stuff to do with thread local storage or something else
that would make this fail?
> One idea that has been bandied around in the V8 team is to change the API
> minimally by
> adding a GlobalContext parameter to the V8::Locker constructor. So when you
That sounds nice and simple from the API point of view, and would also
minimise the amount of function-signature refactoring required. I've
actually done something a bit similar to the whole 'TLS for storing
GlobalContexts' idea in the rest of my app, so at least I should be
familiar with the general pattern.
> The first step http://images.google.com/images?q=first+step+is+doozie would
> be to make a single GlobalContext, put its address in thread local storage
> and measure how much that slowed things down.
Hehe; well I think my very first step is to do a quick evaluation of
the amount of static variables I would have to mess with :-)
But yes, some profiling would be a good start, since of course you
guys won't want to introduce any performance issues just to support
functionality not needed by Chrome. Even if the TLS has a noticeable
cost, we might still be able to have a #define switch to change
between the full TLS thing and a simpler version, where there is one
static GlobalContext, which would surely cost nothing to access :-)
> Patches welcome, as we like to say. :-)
Excellent! That would save any worrying about forking/maintainance etc
for me :-)
The choice for me is either mess with V8, or try to get TraceMonkey
going. I will go and look see how much work there might be in adding
the GlobalContext idea to V8. If its practical, I will very seriously
look at doing this work.
Best Regards,
Steve.
Well, I've had a look at the codebase, and I reckon there are just
over three hundred static variables that would need to go into a
Global Context. I'm not saying I'm definitely going to do this yet,
but if I do have a go, I have a few practical questions:
* What's the best way to measure any possible performance regressions?
* I can only develop for Windows, but a TLS-based solution will likely
need a little porting to other platforms; is this ok?
* Are there any published code-style guidelines for V8?
* Should I try to land one big patch with all the changes, or find a
way to do it more incrementally?
* Anything else I should know? :-)
Best Regards,
Steve
It would be much appreciated if it runs in Linux.
Best Regards,
--
Luis Otavio de Colla Furquim
Não alimente os pingos
Don't feed the tribbles - http://www.thinkgeek.com/geektoys/plush/ac6e/
By the nice edges of dataly graphs I shall walk
http://www.furquim.org/chironfs/
Hi,
Well, I've had a look at the codebase, and I reckon there are just
over three hundred static variables that would need to go into a
Global Context. I'm not saying I'm definitely going to do this yet,
but if I do have a go, I have a few practical questions:
* What's the best way to measure any possible performance regressions?
* I can only develop for Windows, but a TLS-based solution will likely
need a little porting to other platforms; is this ok?
* Are there any published code-style guidelines for V8?
* Should I try to land one big patch with all the changes, or find a
way to do it more incrementally?
* Anything else I should know? :-)
Thanks for the reply. I'm beginning to see just how much work it would
be. A simple global search for static variables just doesn't get close
to the amount of work really involved. There's a lot of data not
explicitly marked static (including, as you say, variables defined in
macros). There's probably weeks if not months of work here.
I also think it will be hard to accurately estimate the performance
impact of TLS without actually doing all the work, because until all
the modules are converted, we probably won't know exactly which call
sites would need to access the TLS data. A starting point might be a
throwaway prototype that just compares direct static data access to
TLS access. It would be hard to simulate appropriate cache-usage
patterns in such a test though. I'm also not sure exactly how to read
the results: without knowing the potential call-sites in the V8 code,
it would be difficult to say exactly how fast one TLS access would
need to be compared to the existing static access. Then there's the
question of whether all platforms would have similarly fast TLS
access.
Anyway, this (V8 with this patch) would still be my preferred solution
overall, but it's probably not practical for me to put this amount of
work in at this time :-(
Best Regards,
Steve