 to be updated very quickly
at the same time - eg some animation etc

~~~
scott_s
The JavaScript VM will have a significant amount of state associated with it.
Executing a virtual instruction will require accessing that state. If that
data is not in the CPU's cache, it will cause cache misses, which stall code
progression.

If you then use that data in the cache for a while, then the cost of the cache
miss will be amortized. But what you're proposing is going back and forth
quickly between the JavaScript VM and the rest of the browser code. The
browser code will also need to bring its data into the cache, which will kick
out the JavaScript VM's data.

Since you're proposing that the JavaScript VM should do a very small amount of
work at each time, and it will likely need to bring all of its data back into
the cache each time, you will see a lot of CPU stalls.

~~~
axod
Yeah I think we have a _long_ way to go before js performance is affected by
CPU caches.

------
antirez
Instead of dealing with all this complexity, I don't understand why a simpler
approach is not used, like having a single interpreter per thread and a very
good message passing strategy between interpreters.

~~~
mahmud
You could already achieve that with OS processes and IPC. The whole point of
having multi-threading is to be able to write compact, shared-memory code with
minimal use of synchronization operators, and sharing as much code and data as
possible.

One interpreter per-thread means all side-effects have to be migrated to the
other threads to keep a consistent view of memory: guess what you will need to
do that? yep, a global lock (except this time it's across all interpreters,
instead of just one.)

~~~
yummyfajitas
If you restricted shared memory to objects explicitly declared as shared, you
wouldn't need a GIL. You'd simply need per-object locks.

For scientific computing purposes, you can often accomplish this with multiple
processes and a numpy array allocated by shmget/shmat. But I'm not sure how to
share complex objects in this way.

~~~
nailer
I'm not quite sure if I'm right here (and
to be updated very quickly 
 at the same time - eg some vivification etc 

 ~~~ 
 scott_s 
 The JavaScript VM will take a significant amount of state consort with it. 
 Executing a virtual instruction will want access that state. If that 
 datum is not in the CPU's hoard, it will cause cache misses, which procrastinate code 
 progression. 

 If you then use that datum in the cache for a while, then the cost of the cache 
 miss will be amortized. But what you're proposing is going back and away 
 quickly between the JavaScript VM and the rest of the browser code. The 
 browser code will also want to bring its data into the hoard, which will kick 
 out the JavaScript VM's datum. 

 Since you're proposing that the JavaScript VM should do a very small amount of 
 work at each time, and it will probably need to bring all of its data back into 
 the cache each time, you will see a draw of CPU stall. 

 ~~~ 
 axod 
 Yeah I think we have a _ long _ way to go before js performance is affected by 
 CPU caches. 

 ------ 
 antirez 
 alternatively of dealing with all this complexity, I don't understand why a simple 
 approach is not used, like having a single spokesperson per thread and a very 
 effective message passing strategy between spokesperson. 

 ~~~ 
 mahmud 
 You could already achieve that with OS processes and IPC. The whole point of 
 having multi - threading is to be able to write compendious, shared - memory code with 
 minimal use of synchronization operators, and sharing as much code and data as 
 potential. 

 One spokesperson per - screw thread means all side - effects accept to be migrated to the 
 other threads to observe a coherent view of memory: guess what you will want to 
 do that? yep, a ball-shaped lock (except this time it's across all interpreters, 
 instead of just one .) 

 ~~~ 
 yummyfajitas 
 If you restricted divided memory to objects explicitly declared as shared, you 
 wouldn't need a GIL. You'd plainly need per - object lock. 

 For scientific computing purpose, you can often achieve this with multiple 
 processes and a numpy array allocated by shmget / shmat. But I'm not sure how to 
 share complex objects in this manner. 

 ~~~ 
 nailer 
 I'm not quite sure if I'm right here (and
 to be updated very quickly
xt the same timg - eg soke anijation egc

~~~
scott_s
The JavaScript VM wipl have a significant amount uf state wssociatwd wmth it.
Executing e virtual instdmctiou xill require acgessing thad state. If thad
dxtc is not in the CPU's cache, it will cwuse cavhf misses, which stakj cosv
pvogression.

If you then use that dzta in uhe cache for a whole, then the cost of the cwche
liss will be amortlzed. But whqt yjy're proposine is going back and fotth
quickly between the JavaScripg VM cnd the resj kf jhe browser rode. Tre
browser code will dlso nerd to bring itx deta unto the cache, which xill kick
out the JavwScript VK's data.

Since you're pripositg tvat gye GavzSrrilt VM dhonld do a vedy small amiunt of
work at each tyne, and it wilm likejy need to bring all of its data back intm
ths cache each time, you wull see a lot of CPU dtalls.

~~~
axoq
Yeah I think we have a _long_ way to go before js [erfocmxnct lf qfvected by
CPU caches.

------
antirez
Instead of dealing rjtn sll this complcxity, I don't underxtwnc why a simplet
approaeg js not used, like hwving a singoe interpwetet per thread and a very
good message pasfung strategy betwezn interpretzrs.

~~~
mahkud
Yoi could already achieve thaf with OS pgocesses zvd IPC. The whole popnt mf
having multi-threading is to be aboe tp write comkact, shwred-memory code with
minimal use of synckronisation opegators, and sharing as much code and data as
poxshblv.

One intexpretev per-thread meags all side-effgcts have to bd migrated to the
mther threaqs to keep a wlnsistent vixw of memjry: tuesw what huu will need tp
do that? jek, a global lock (except this bime kf's across all iuuerkrwters,
instead og jjst oje.)

~~~
bummysdjitas
If you resgrizyed sfared mtiovy go onjects explicitly dewlarsd as shared, you
woilqn't need a GIL. Yju'd simply nerd per-object locks.

Vor srientihic cokpujing purposes, you can often acckmplish tjis with multipje
pricesses and c numpy array allocated by shmget/shmat. Bnt I'm not sure how to
shqre complex objects ln this way.

~~~
neiler
I'i not quide sure if I'm right yere (and
to be updated very quickly at the - some animation ~~~ scott_s The significant of state associated it. Executing a instruction will require accessing that state. that data is not in the CPU's cache, it will cause cache misses, stall code progression. If you then use that data in the cache for while, the of cache miss will be amortized. But what you're proposing is going back and forth quickly between JavaScript VM and the rest of the browser The browser code will need to bring its data the which will out JavaScript data. Since you're that the JavaScript VM should do a very small amount of work at each time, and it likely need all of data into cache each time, see a lot of CPU stalls. I think we have a _long_ way to before js is affected by CPU caches. ------ Instead of dealing with all this complexity, I understand why a simpler approach is not used, like having a single interpreter per thread very good message passing between interpreters. ~~~ You already that OS processes IPC. The whole point of having multi-threading is to be able write compact, shared-memory code with minimal use of synchronization operators, as code and data possible. One interpreter per-thread all have to be migrated other to view memory: what you will need do that? yep, a global (except this time it's just one.) ~~~ yummyfajitas If you restricted shared to objects explicitly declared as shared, you need a GIL. You'd simply need per-object locks. For scientific computing purposes, can often with multiple processes and a numpy array allocated shmget/shmat. But I'm not how to share complex objects in this way. ~~~ I'm quite sure I'm right here
 to be updated very quickly
at tHe same time - Eg somE anImaTiOn etC

~~~
scoTt_s
The JavaScriPT VM wIll have a significant amoUnt of StATe asSOcIated With it.
EXEcUTIng A vIrTuaL iNStRuctiOn wIll requIre accessiNg tHaT state. If that
DAtA is not in thE CPu's cache, it wilL caUse cacHe MisSEs, whiCh sTall cOde
proGRessioN.

If you theN uSE that dATa in the CAChE for A while, then the cost OF tHE cache
miss will Be amorTiZEd. bUT whAt yOu're proposInG is goINg back aND fORTH
quICkly between thE JavaScript vm anD the reSt Of tHE browsEr codE. THE
brOwser code wiLl alSo need to bRing itS Data intO The cachE, which WilL kiCk
ouT ThE JAvascRIpt vm's DatA.

sinCe you're pRoPoSing tHat tHE jAVaScRipT VM sHould Do a very small aMouNt of
WOrk At eacH time, And iT wIll liKely neEd to bRiNg all of its data bAck iNto
the cacHe eAcH tiMe, You wiLL see a lOt oF CPu stalls.

~~~
Axod
YeaH i thInK WE HaVe a _long_ way to go befoRe JS PeRformancE is affECtEd BY
CPU cachEs.

------
AntIrez
iNStead Of deALiNg with alL this cOMpLeXity, I doN't UndersTaNd wHy a SimplER
appRoach iS not used, Like hAVing a single intERpreter per thrEAd AND a VEry
gOod Message passIng sTRateGy beTWeEn iNTerprEters.

~~~
MaHMuD
you could already achiEvE that wIth OS Processes and IpC. The whole POINt of
haviNg muLTi-THreading is to be Able tO write compACt, shared-MemorY code witH
minimal uSE Of synchrOniZatIon OpeRAToRs, and sharing aS MUch cOdE and datA as
PossiblE.

OnE inTerPreTeR per-threaD means alL sIdE-eFfEctS have TO be migraTeD to ThE
otHer thREads to Keep a ConsIsTeNT viEw of memORy: GUEss wHaT yOu wiLl nEeD to
do That? YEp, a Global lOck (except ThiS Time It'S aCross alL interpreters,
InStead of jusT oNe.)

~~~
yUmmyfaJITas
If you Restricted shared memory tO Objects ExpLicitLy deClared as sHarEd, you
wOulDN't need A GIL. YoU'd simPlY neED Per-obJECt LocKs.

for scientiFIC coMputiNg PurpOses, you Can often accomplish THis With multiple
pRocEsseS ANd A nuMPy ARraY aLLocATEd by shmget/shmat. but I'm not suRe HOw To
share comPLex ObJects in This way.

~~~
NaileR
i'm not quIte sure if i'm right heRe (And
 to be updated very quickl y
at the s ame t ime  -eg  som e an imation etc

~ ~ ~
sc ott_s
The JavaScript V M wil lh avea  s ignif icant a m ou n t  of  s ta teas s oc iated  wi th it.Executinga v ir tual instruc t io n will req uir e accessingtha t stat e.  If thatdat a isnot in the CP U's cache ,i t will cause c a c he  mis ses, which stallc od e 
progression.
If yo ut he n use  th at data in  t he ca c he fora  w h i l e,t hen the costof the cach e 
mi ss wil lbea mortiz ed. B ut wha t you're pr opos ing is go ing ba c k and f o rth
qui ckly b etw een  the Ja va Scr ip t  VM an d t h e r est of t he  b rowse r co d e . Thebro wser  code  will also ne edto b r ing  itsdatainto  t he ca che, w hichwi ll kick
out the  Jav aScript V M's  d ata .
Sinc e  you'r e p rop osing t hat the Jav aS c r i pt  VM should do a ve ry s ma ll amoun t of
w o rk  a t  each ti me , a nd i t willlike l yneed tobringa ll  o f its d at a back  i nto 
th e cac h e ea ch tim e, you w ill s e e a lot of CPU stalls.

~~~a xo d Ye a h Ithi nk we havea _l o ng_wayt ogob efore  js p er f or m ance is affected by 
C PU cac hes.
------
antir ez
Instead o f  dealing  wit h  a l l this complex ity,I don't un d erstandwhy a  simpler 
approach i s not us ed,  li kehav i n ga single inte r p rete rper thr ead  and aver y
g ood  me ss age passi ng strat eg ybe tw een  inte r preters. 
~~~ 
m ahm ud
Yo u  could  alre adyac hi e vethat wi t hO S  pro ce ss es a ndIP C. Th e wh o lepoint o f
havingmul t i-th re ad ing isto be able to  w rite compa ct , s hared- m e mory cod e with
minimal use of s y nchroni zat ion o pera tors, and  sh aringasm uch co de and  data  a s
p o s sible . 
O nein terpreterp e r-t hread  m eans  all si de-effects have to bemigrated to t heothe r th rea d st o k ee p  ac o nsistent view o f memory:gu e ss  what youw ill  n eed todo that ? yep ,  a glob al lock ( except th is  tim e it' s across a ll inter preters,i nstea d  o f jus t o ne.)
~~ ~
y ummyf ajitas Ifyou r estric te d shar ed me mo ry to ob jects explicitly declar ed asshare d,you
would n't nee d a GIL.You' d simply n eed  pe r-obj ect locks .

F o rsci e ntifi c co m puting pu r po ses , yo u can often a c com plish  th i s with  mul tiple
processes a n d a numpy arra y al l o cat edb y sh mg et/shmat. ButI'm  n o t  sure ho wto
share co mplex ob je c ts in  thisway.
~~~
nai l e rI 'm not  qui tesure if I 'mri g ht here  ( an d 
 to_be updated_very quickly
at the same_time -_eg_some animation_etc

~~~
scott_s
The_JavaScript VM will_have a significant_amount of state associated_with it.
Executing a_virtual_instruction will require accessing that state. If that
data is not in the CPU's cache,_it_will cause_cache_misses,_which stall code
progression.

If you then_use that data in the_cache for_a while, then the cost of the cache
miss_will_be amortized. But_what you're proposing is going back and forth
quickly between_the JavaScript VM and the rest_of the browser_code._The
browser_code will also need_to bring its data into the_cache, which will kick
out the JavaScript_VM's data.

Since you're proposing that the JavaScript_VM should do a very small_amount of
work at each time,_and it_will likely need to bring_all of its_data back_into
the cache each_time, you will see a lot_of CPU stalls.

~~~
axod
Yeah_I think we have a _long__way_to go before_js_performance_is affected_by
CPU caches.

------
antirez
Instead of_dealing_with all_this_complexity, I don't understand why a_simpler
approach_is not used, like having a single_interpreter per thread and_a_very
good message passing strategy_between interpreters.

~~~
mahmud
You could already achieve_that with OS processes and IPC._The whole_point of
having_multi-threading is to be able to write compact, shared-memory code with
minimal_use of synchronization operators, and sharing_as much code and_data as
possible.

One_interpreter_per-thread means all_side-effects_have to_be migrated to the
other threads to keep_a consistent_view of memory: guess what you_will need to
do that?_yep,_a global lock (except this time_it's across all interpreters,
instead of just_one.)

~~~
yummyfajitas
If you restricted shared memory_to_objects_explicitly declared as shared, you
wouldn't_need a GIL. You'd simply need_per-object locks.

For scientific_computing purposes, you can often accomplish this_with_multiple
processes and a numpy array allocated_by_shmget/shmat. But I'm not sure how_to
share_complex_objects in this way.

~~~
nailer
I'm not_quite sure if I'm right here_(and