今日はRuby3のコンカレッシュモデルを紹介しますが、このプレゼンテーションはRuby-Kaigiの今年のプレゼンテーションを紹介します。このプレゼンテーションは2つのモチベーションです。プレゼンテーションはコンカレッシュモデルを紹介します。このプレゼンテーションは、非常に難しい製品です。実は、プレゼンテーションが沢山難しいウ的話となく、プレゼンテーションを使って、プレゼンテーションを使って、プレゼンテーションを使うと思う。このプレゼンテーションは、何かと違ううちのプレゼンテーションを使う必要があります。プログラム素晴らしいアプシュラークションをコンカネットプログラムでもう一つのパフォーマンスを使用するCPUや多くのコースを使用するもちろんコンピューターは多くのCPUコースを使用するもちろんパラリルコンピューターを使用するもちろんコンカネットプログラムマンスはパラリルスレッドの使用するもちろんサポートを使用するパラリルプログラムで使用するもちろんこの2つの2つのプログラムでパフォーマンスを使用するもちろん新しいアプシュラークションモードを紹介しますRuby3のゲルドを使用するもちろんRuby3のゲルドを使用するこの技術この技術デートレースのコンジションプログラムでゲルドを使用するもちろんゲルドを使用するもちろんゲルドを使用するもちろん今日は今日プログラムでゲルドを使用するどう使用するゲルドの難しい技術を使用する30分30分70分確かにこれを見たい場合はRubyKaigiのこの技術を使用するもちろんこれを再びゲルドのプログラムだけでRuby3のプログラムではゲルドの名前もちろんと言うこれまでゲルドのプログラムにはゲルドのディスクシューを使用するもちろんでゲルドのプログラムではゲルドの手術にゲルドのプログラムではゲルドとコイツアツアダー from Japan.I'm also of current virtual machinesand includes recent garbage collection changes.And also, I'm an employee of sales of Helokku.So there is a booth of Helokku.So we can discuss, please visit Helokku boothand we can discuss moreabout this proposal or help products.So at first, I want to show yousome difficulty of multistage programming.Multistage programming has many, many difficulties.So it's easy to introducethis race and race conditionsor introduce a deadlock or a livelock.Or, and also it is difficult to debugbecause it's the thread program,the thread behavior is non-deterministic.So it is difficult to find out which is the bugand we cannot reproduce such a bug.So it is very difficult.This is because the thread programmingdepends on the timing.So maybe if you have an experienceabout thread programs,so you can understand my states.And also, it is difficult to tunethe performance of threads.Today, I want to focuson the datarace and race conditions.So I quote this programfrom this great blog post,the race condition process datarace.This blog post explains what is the dataraceand what is the race condition.So if you have any questionplease check this blog post.This program has several bugson managed thread programs.So there are no bugs on the serial executionso without any migrating.This bank amount transfer programhas issues.So bank amount transfer programis a very traditional examplefor the parallel executionor concurrent execution.So maybe you can understandwhat this program do.So can you understand the issues?Okay.So the first one is the datarace.So these two lineshas datarace issues.I don't explainwhat is the program.But this is the program.Also another one is therace condition bugs.So combination of these two linescodes the program.So the balance ofsource accounts can be under flow.So if you can't find these bugsso you shouldn't do the managed thread programs.Anyway.So the solution of theto make a managed thread safe programso we need to synchronize all ofall of these methods.So using the mutual exclusionmutex or such asynclosable method.So difficulty of such amuch thread program isso it is easy to introducethe mutual shared statesbetween threads.So we need to synchronizesuch a sharing mutualmutable objects correctly.So correctlyso completeness isthe program.So we need to makesome other synchronizationfor any shared states.But using Ruby's threadsso it is easy to makemulti-state programs.And it is easy to introducesuch a shared object.But it is difficult torecognize which object,which data is sharedor not.So we can trackon a small program.So I mean that onlyone hand is sharedand only 100ruby source code.It is easy to seeall of programs.So we can checkthis data is a shared one.And this string is notshared.So we can understandeasily.Howeverit's difficult to trackonthe big program.Maybe you are writingsome Rails applicationsor some productionapplications.And maybeit should be bigapplications.Also such a bigapplications depends onexternal libraryprovided by ruby genes.So we need to understandeverything.So everything meanswe need to understandso the libraryis thread safe or not.And this method or this datais shared or not shared.Isolated or not isolated.So we need to understandeverything.Or believethe library'sdocument and so on.But it's notusually.I believe thatsometimes documentssay lie.So it is a hard way toI think it is a hard way.So I should use somedifficulty aboutmarset programs.So I wantto overcome suchdifficulties.We wantto overcome this difficulty.So thewe canwe can understandthat the programof difficulty isone reason of difficultyis come from the easyto share the mutable objects.So with rubyit is easy to writethe thread programs.And we can easy toshare any objects.So the ideato overcome suchdifficulties.So idea is to notshare mutable objectswithout any of these directions.So we can studyfrom the other languageswithout anyenvironment.So consider thatcopy everythingis there is no problembecause we don't sharethe data.So for example,share script can passthe data with pipeand all of the datais not shared.So every data iscopied to other process.Everything is too slow.And alsoprohibit mutable objects.So some functional languagessuch asHuskell orVocaloge andAlan or Eksherso suchlangages prohibits mutateofdata.It introduceshuge incompatibility.So maybe you got angryif we say thatso Ruby3 can'tinsert any instance variable.It is huge incompatibilityso it's not acceptable.And the otherlangage.So rocket programming languagesyou can allow to sharethe immutable object.However,we want to shareother kind of objects.And the another approachprohibitto requiresomespecial protocol to mutatethe objects.So closurelangagethey cantheyprovide some mutable objects.But using mutable objectswe need to use undertransaction.That'sthere.If we introducesuch a transaction for eachmutable mutation operationsso it is alsothe incompatibility.So we have someexamples.So note that weI do not listusing approach to usingtype systemlike last.So starting from thislangage we can pick upsome ideas.So wewe need to keepcompatibility withruby 2. Socompatibility is verydifficult.Also we shouldmake a prior program.And we shouldshould not care about rocks anymore.It is very hard tomake usthreadsafe programs.And we can sharemultable objects withcopy,but copy operationshould be first.And we shouldshare mutable objectsif we can.And we canprovide special data objectsto share mutable objectslike closure.So normalobject,normal shared objectsorry,normal mutualobjects can beallowed.But ifyou want to share betweenmultable objects,then we need tointroduce severalprotocol.So wename is such awe.Soto achievethese goals,weproposedthe guild.So guildwe canhave at least one guildat the roundinterpreterbooted after booted.And we can make another guild.And guild can haveseveral threads.Andthreadsbelong tog1.And theycannot learn in power.Threadt3belong toanother guild.So wecan learnthreadt3.So wecan learnThreadt1Threadt2Threadt3Learn in power.And the mostimportant rule ismultable object havemembership.Allmultable objects shouldbelong to only one guildexclusively.So it means thatobjectscannot haveseveral guilds membership.So this is becauseguild is not community.So theycannot belong to another guild.And the guildcannot touch the objectbelong to other guild.So guild2cannot touchthe object belong to guild1.So only one guildcannot access tothe mutableobjects.So wedon't need to considerallmultable objects anymore.Ofcourse it's onlyone thread runon the guild.Butwe need to communicateeachother between guilds.So weprovide a communication pathcalled channel.So guildchannel iscommunication pathto each guild.Andchannel providescommunicationmethodcopy and move.Sowe named moveas a transfermemberset method.Socopy objectcopy is veryeasy to understand.So if we wantcopy transferthis objectO1,then we needto copyeverything the O1refer to.So there is2of...So we duplicateall of objectstraceablechromesO1.So it is easyI think.Butmoving operation is not soeasy.So transfermemberset methodtry to makesomechange membership ofeach object.Soallofmethodstraceable fromO1.So O1 and O2 and O3change the membershipof theGrid1 to guild2.Andafter that,if wetouchthe old objectin guild1,a transferred objectin guild1,it should be raised.So it should error.So it means thatwe movethe object.Andwe touchafter that,we touchthis object.It should beor if we want to showtheobject status and it shouldbe also error.So we canunderstand this object istransferred.So we canusually we cancopy small objectslike dbdoes.Sosometimes we want topass the parametersand some operationlike around.Sosuch a small objectit is easy to copy.So thereare no overhead.Andyou can move a small amountof number of objects.So itmeans thatif you load somebinary file,some picture filethen sowe can movesuch a big data,bigfinally data toanother guildwithout any copy.And also we allowto copy thetransferred immutable objectwithout any overhead.Soin this case,immutableobject is not a frozenobject.So please seethe A2this line.Soarray is frozenthatthis A2contains mutableobjects.Soin this case,A2arrayA2is notimmutableobjects.Sowithfor theimmutableobjectswe can only sendreference to the other guilds.Soit is very lightweight.Andalso numeric objectand so on is immutable.Sowe can sendwithout any overheads.Like that.Sowith guilds,we canmake a master worker typeapplications.Andalso we can make a pipelinebased application.Soeach guild can run in power.Andwe canmovebetween the guilds.Andalso we can make a bank examplelike that.Alsowe canso if you want to make moreperformancewe can use somespecial data structure.Soyou can use externaldatabase or externalkeybalist orintroduce some softwaretransaction memoryspecial object.Sothis listcomparison between thesets and guilds.Sothread has several advantages.Sointer-thread communicationis very fast.Soit's because we only need topass the reference to object.Andwe already know the thread programming.Sothere are many many threadprogramming books.We can understand.Wecan really know how to makethread objects.Andso it is difficult.Soas I said,I think it isdifficult to make correctthreadsafe programs.Sousually I'm ac programmer.AndI make ac threadprogram on Clanguage.And I understandthreadprogram is very difficult.Alsothere isadvantages and disadvantages.Andguilds are guilds.Sowe have several disadvantages.Sowe need to introducesome overheadtoachieve theinter-guildscommunication.Alsowe need to runthis model.Sonobody knowsabout guilds.Andwe need to make a pilot programusing guilds from scratch.Butwe don't need to care about the synchronization anymore.So it is very easyI think,I hope.Andalsomovetechnic reduce theoverhead ofinter-threadinter-guildscommunication.SoI think this is a trade-offbetween performanceand the safety and theprecision.Soit is similar to garbagecollection.So garbagecollection,without garbagecollection,it can bemore faster.So we don'tneed to care about thewe shouldn't care aboutthe performanceoverhead.So GCoverhead.However,Garbagecollectionmake programhappily because wedon't need to care where weneed to free theobject or something like that.SoI'm not sure which do youlike,but I likegarbagecollection and I likeguild.So anyway,by the way,there ismany-many discussion aboutthe name of guilds.Sowhy the name is guilds?So I think the guildis a guild metaphor forobjects membership.AndI check thedeplications.Sonobody using thisname guildson the computer scienceterminology,maybe,Ithink,I hope.And there are nodeplications,top-level classes and modulesin all ruby gems.I checkevery,all ofsource code in ruby gems.Thereare no guilds,modulesand classes.Andthe mostimportant thing is thefirst letter isdifferent from othersimilar abstractions.Sot isfor threads,pis for process.Sowe can't use p and tand f for fiber.Andwe can useg,so it is anempty throat.So anyway,there are many-manyficalty to implement our guilds.Sohow to achieve the object membership.Andhow to implement the inter-guild communication.Andhow to design shared mutable data.Andhow to isolate processglobal data.So it isvery,veryimplementationdependentthings.SoI'llshow a bit ofthis.Socopy is very easy to understand.Somake a copysends a copied reference.Soit is easy.Somoving is not soeasy.Soactuallywe makesoaftermoving,theoriginal objectdestroyed.Andwe shouldcall the error toif we touchthe source objectaftertransferred.Sohow to implement it.Themagic is makingsome small copies.Soit is copy,butit doesn't copyeverything.Somake anew headers of objectsandrefer to the dataandsendsand invalidates original objectsandsends our headers.Sothis techniquewe don't needto copysuch these data.Sousing such amoving operationwe only needto checkthe membershipwithout anyoverhead.SoI mean that each objectshouldn't knowthe own guild.So guildknow the object,buteach objectshouldn'tknow the guild.Sointerpreter shouldn'tneed to checkthe guild ownershipand membership.Andthere are many,many otherconsiderations.So weto keepcompatibility with Ruby2.Sowe are discussing about thesedetailed specificationslike global variablesand there isseveral datain the Ruby process.Sowe need to consider about this.Forexample,there isgarbage correctionvisual space.So how to do thisand so on.These areperformancepreliminary performance evaluation.Sothere is no guildimplementation.So Imajor guildsin C languageand simulatesthe behavior of guilds.Sousing the guildswithtwo core machinethe Fibonaccimaster worker programis faster than thesingle guilds programs.Alsowe evaluatethe moving.Butthe moving is verythrow because we need tocheck all ofentriesof array.Sowith someoptimizationwe can improve the performancelike the reference passingI think.Butit is not done.Sothis is the checklistof the goal of Ruby3.SoI thinkall of the entrythe guild can pass.I'm not sure,butI hope so.SoI want to show the severalanswerand questions.Sothe first questionis,can we try guild now?No,I'm sorry.Soimplementing the guildon MRI is very bigproject.So itis notyet.Sosupportingthis project byyou or your companyis very welcome.Andalsosomeguys tryto implement the guildfeature onJLB.Orwe can discussinterface.So interface meansAPI.We canwithoutimplementation.Alsothe secondquestionis,should we wait forRuby3?So I'm not sure.Soif we make guildsimplementation.Sowe can introduce onRuby3.Iwant to implement next yearbutI'm not surewe can do itin next year.Sothe next question is,can guildreplace all of threat programs?No.Theanswer is no.Soto utilize guilds.Soyou need to rewrite your programsusing threats.Soit is not so easy.ButI assume the 90% ofprogram can bedelighted by guilds.Andmaybeit is enough.SoRubyprogram language Rubymaybeit is enoughfor the most of case.Butnot complete.Butit is okay for us,Ithink.Sopointerface.Ithink.Sofor example,we can makewebserverusing guildsbecausemoving I.U. objectis very easy to implement.Sosome guysay it is ownership.Itistrue.Soactually,beforewe name the guilds,wesay it is ownership model.Butwename it membershipbecause guild is not ownerof object,owner ofmembers.Anotherquestion ismoving cause huge overhead forthe big object work.Bigobject work means some bighush tablereferred to the other object.Sothe answer is yes.Weneed to move all objects andit willbecomehuge overhead.Sowe need to introduce special datastructure like closure orsomething like that.Butthe people,Ibelieve that people canchange theirprograms to fitthis model if weprovide it.And anotherquestion is can we shareprojects?Soit is a very detailed problem butit is a verybig problem on this.Sothe answer is wecannot share procobjects because procobjects canrelyte thelocal value and itmeans it is mutabledata.Sowe have severaloptions to allow tocopy the procobject and bindings toallow themove local environment orsomething like that.Orintroduce some similarobstructionof proc tofit gearsmodel.Soas Ishow there are manyunsolvednot finishedprograms thatwe want totry to make thismodel for ruby 3.Sotoday I show youwhy this program is very difficultand I showourproposal guild for ruby 3.Sonot implemented yet butI show key ideasand some questionsandthe current answers.Sothis is over.Sothank you so much.We have maybeten minutes to discuss.So if you haveany question, so pleasesay slowly.So the overhead, soyou say that theexecution timeor memory consumptionwhich one?Both.Okay.Socurrent one is same asthreads.Soif youon your computerif you makethousands of threadsit is same.Andmaybe the samecreation time I think.Butwe canimprove suchperformance becausethe currentgild isnot fixed so we canchange the specification tomake it lightweight.ButI think the creation of thehead is not so big issue becausewe can make a guild pool orsomething like that.Sothe question iswhen the standardIo standard input or outputhow aboutother guilds.Sogood question.Somaybe we need to duplicatesuch a standardIo.ButI'm not sure we can solveeverything on that.Good question.So the question ishow todefine the classin the other guilds.Right?Yeah yeah yeah exactly.Yeah yeah yeah.SoIon this slidethis presentation Iescape this point.Butso guildsso ourfirst approach is guildsshare.So guildsis designed to shareto share a class and modulesand we canshare the method object andthe byte course.Sosuch a techniquewilldecrease memory consumption andother overheads.Howeveras you said,so the class objectis mutable.Module objectis mutable.Sothis is program.So this is same asthread programming.Sothis is open program.ButI think thatsuch a sharedso I'm sorry.SoI think most of the caseclass and modulesare mutable.Orwe don't touchclassdefinition andmodule definitions.Andthat'sit can be program.Sofor example,so if we useoutload andaccess to theconstant variablein the other guilds.So it isproblem.So it is problem inmulti-state environment.Soit is same problem.Sofor example,we cansupport some hooks,somenew tracepoint hooksfor the class load orsomething,some events.Sowe can check anymodification for such a sharedclass or module.So we canunderstand.Oh,this isthis guildviolates such aisolation and so on.Sothis is mydesign.But I'msure it is enough.Soother option is toisolate the class and modulesbetween the guilds.Soit is okay.But this issimilar to the multi-processoror multi-virtual machinemodel.So we madebefore.So it iseasy to understand.Sotheir environments arecompletely isolated.ButI think it caused manymany overhead for the memoryconsumption and the creationoverheads.So it is trade-off.And maybe we willmake both models,isolation model or mixingmodel,shared model.So wecan evaluate.We want toevaluate on that.Is it okay?Thank you.Soit is avery preliminarydesign.Sothis programpass the programto the other guildwith string.ButI believe it is not a good designso we can change.Soit is asoplease note thatit is a preliminary.Soon this case,there isa globalmethod,fibonacci numbercalculation method,andthe makerchild-fibonacci guild.Andeach guild hasdefault channel.And usingdefault channel,we cancommunicate with each other.Sobutplease do not believe it isthe last design.Sowe can changethe morewe can changebetter.Any otherquestions?Or we candiscuss after this session.Sothank you so much.