day2Jrockit.docx

上传人:b****7 文档编号:11297482 上传时间:2023-02-26 格式:DOCX 页数:20 大小:261.75KB
下载 相关 举报
day2Jrockit.docx_第1页
第1页 / 共20页
day2Jrockit.docx_第2页
第2页 / 共20页
day2Jrockit.docx_第3页
第3页 / 共20页
day2Jrockit.docx_第4页
第4页 / 共20页
day2Jrockit.docx_第5页
第5页 / 共20页
点击查看更多>>
下载资源
资源描述

day2Jrockit.docx

《day2Jrockit.docx》由会员分享,可在线阅读,更多相关《day2Jrockit.docx(20页珍藏版)》请在冰豆网上搜索。

day2Jrockit.docx

day2Jrockit

Jrockit

时间:

8

1.ExplainOracleJRockitJDK

AbouttheJDK

TheJRockitJVMisahigh-performanceJVMdevelopedtoensurereliability,scalability,manageability,andflexibilityforJavaapplications.TheJRockitJVMprovidesimprovedperformanceforJavaapplicationsdeployedonIntel32-bit(Xeon)and64-bit(XeonandSPARC)architecturesatsignificantlylowercoststotheenterprise.Further,itistheonlyenterprise-classJVMoptimizedforIntelarchitectures,providingseamlessinteroperabilityacrossmultiplehardwareandoperatingsystemconfigurations.TheJRockitJVMenablesyourJavaapplicationstorunoptimallyonWindowsandLinuxoperatingsystems(both32-bitand64-bitarchitectures).TheJRockitJVMisespeciallywell-suitedforrunningOracleWebLogicServer.

TheJRockitJVMisonecomponentoftheOracleJRockitJavadevelopmentkit(JDK).InadditiontotheJRockitJVM,theJDKiscomprisedoftheJavaRuntimeEnvironment(JRE),whichcontainstheJVMandJavaclasslibraries(asspecifiedbytheJavaPlatform,StandardEdition6APISpecification),aswellasasetofdevelopmenttools,suchasacompiler.

TheJRockitJDKiscompatiblewithJ2SE5.0andJavaSE6.

 

2.UseJITCompilationandOptimizations

just-in-timecompilation(JIT),alsoknownasdynamictranslation,isamethodtoimprovetheruntimeperformanceofcomputerprograms.Traditionally,computerprogramshadtwomodesofruntimeoperation,eitherinterpretedorstatic(ahead-of-time)compilation.Interpretedcodeistranslatedfromahigh-levellanguagetoamachinecodecontinuouslyduringeveryexecution,whereasstaticallycompiledcodeistranslatedintomachinecodebeforeexecution,andonlyrequiresthistranslationonce.

JITcompilersrepresentahybridapproach,withtranslationoccurringcontinuously,aswithinterpreters,butwithcachingoftranslatedcodetominimizeperformancedegradation.Italsooffersotheradvantagesoverstaticallycompiledcodeatdevelopmenttime,suchashandlingoflate-bounddatatypesandtheabilitytoenforcesecurityguarantees.

JITbuildsupontwoearlierideasinrun-timeenvironments:

bytecodecompilationanddynamiccompilation.Itconvertscodeatruntimepriortoexecutingitnatively,forexamplebytecodeintonativemachinecode.

Severalmodernruntimeenvironments,suchasMicrosoft's.NETFrameworkandmostimplementationsofJava,relyonJITcompilationforhigh-speedcodeexecution.

Step1:

JITCompilation

Thefirststepinthemachine-codegenerationprocessisjust-in-time(JIT)compilation.JRockitdoesnotincludeaninterpreter;sotheJITcompilationofthebytecodeintonativemachinecodehastooccurbeforeamethodexecutes.TheJITcompilationisperformedthefirsttimeaJavamethodiscalled.

TheJITcompilerisfastandgeneratesmoderatelyefficientcode.ThisisnecessarytoenabletheJavaapplicationtostartandrunquickly.Subsequently,profilingrevealsfrequentlycalledmethods(hotspots)thatrequirefurtheroptimization.TheJRockitapproach—JITcompilationandnointerpreter—resultsinrelativelylongerstartuptimes,buteveniftheJITcompilationresultsinonlymoderatelyefficientcode,thegeneratedcodeisstillsignificantlyfasterthaninterpretedcode.

Step2:

ThreadMonitoring

Duringthesecondstepofthemachine-codegenerationprocess,theJRockitJVMusesasophisticated,low-cost,samplingbasedtechniquetoidentifywhichfunctionsmeritoptimization:

a"samplerthread"wakesupperiodicallyandchecksthestatusofseveralapplicationthreads.Itidentifieswhateachthreadisexecutingandlogssomeexecutionhistory.Thisinformationistrackedforallthemethods;whentheinformationindicatesthatamethodisheavilyused(hot),thatmethodisearmarkedforoptimization.Usually,aflurryofsuchoptimizationopportunitiesoccurintheapplication'searlyrunstages,withtherateslowingdownasexecutioncontinues.

Step3:

CodeOptimization

Codeoptimizationisaprocessbywhichcommonly-executedcodeisrecompiledtomakeitrunmoreefficiently.

ThefirsttimethattheJRockitJVMrunsamethod,themethodiscompiledintomachinecode.Thiscompilationisquick,buttheresultingcodeisnotasefficientasitcouldbe.Thiscodeisacceptableformethodsthatarerunonceanddiscarded;however,ifamethodisusedrepeatedly,thesystemcangetaperformanceboostifthecodeforthatparticularmethodisregeneratedinamoreefficientway.

TheJRockitJVMoptimizesthesecommonly-executed(hot)methodstomakethecodeasefficientaspossible.Theoptimizationrunsinthebackgroundanddoesnotinterferewiththerunningapplication.

3.ManageMemory

Mnumberof"static"collectorsthatcanbestartedeitherbyspecifyingtheactualcollector(-Xgc:

)orbydefault,asdeterminedbytheJVMmodeyouselectatstartup.

Commandlineoption:

-Xns:

Thesizeofthenurseryhasanimpactonallocationspeed,garbagecollectionfrequencyandgarbagecollectiontimes.Asmallnurserywillbecomefullquicklyandmustbegarbagecollectedmoreoften,whilegarbagecollectionofalargenurserytakesslightlylongertime.Anurserythatissosmallthatfewornoobjectshavediedbeforeayoungcollectionisstartedisofverylittleuse,andneitherisanurserythatissolargethatnoyoungcollectionsareperformedbetweengarbagecollectionsofthewholeheapthataretriggeredduetoallocationoflargeobjectsinoldspace.

SettingaPauseTargetforDeterministicMode

Commandlineoption:

-XpauseTarget:

Thedeterministicmodeusesapausetargetforoptimizingthepausetimes.Thepausetargetimpactstheapplicationthroughput,asalowerpausetargetwillinflictmoreoverheadonthememorymanagementsystem.Setthepausetargetashighasyourapplicationcantolerate.

Thegarbagecollectorwillaimonkeepingthegarbagecollectionpausesbelowthegivenpausetarget.

SettingaPauseTargetforPausetimeMode

Commandlineoption:

-XpauseTarget:

Thepausetimemodeusesapausetargetforoptimizingthepausetimes.Thepausetargetimpactstheapplicationthroughput,asalowerpausetargetwillinflictmoreoverheadonthememorymanagementsystem.Setthepausetargetashighasyourapplicationcantolerate.

4.ManageThreadsandLocks

 

UnderstandingThreads

AjavaapplicationconsistsofoneormorethreadsthatrunJavacode.TheentireJVMprocessconsistsoftheJavathreadsandsomeJVMinternalthreads,forexampleoneormoregarbagecollectionthreads,acodeoptimizerthreadandoneormorefinalizerthreads.

Fromtheoperatingsystem’spointofviewtheJavathreadsarejustlikeanyapplicationthreads.Schedulingofthethreadsishandledbytheoperatingsystem,aswellasthreadpriorities.

WithinJava,theJavathreadsarerepresentedbythreadobjects.Eachthreadalsohasastack,usedforstoringruntimedata.Thethreadstackhasaspecificsize.Ifathreadtriestostoremoreitemsonthestackthanthestacksizeallows,thethreadwillthrowastackoverflowerror.

UnderstandingLocks

Whenthreadsinaprocessshareandupdatethesamedata,theiractivitiesmustbesynchronizedtoavoiderrors.InJava,thisisdonewiththesynchronizedkeyword,orwithwaitandnotify.Synchronizationisachievedbytheuseoflocks,eachofwhichisassociatedwithanobjectbytheJVM.Forathreadtoworkonanobject,itmusthavecontroloverthelockassociatedwithit,itmust“hold”thelock.Onlyonethreadcanholdalockatatime.Ifathreadtriestotakealockthatisalreadyheldbyanotherthread,thenitmustwaituntilthelockisreleased.Whenthishappens,thereissocalled“contention”forthelock.

Therearefourdifferentkindsoflocks:

•Fatlocks:

Afatlockisalockwithahistoryofcontention(severalthreadstryingtotakethelocksimultaneously),oralockthathasbeenwaitedon(fornotification).

•Thinlocks:

Athinlockisalockthatdoesnothaveanycontention.

●Recursivelocks:

Arecursivelockisalockthathasbeentakenbyathreadseveraltimeswithouthavingbeenreleased.

•Lazylocks:

Alazylockisalockthatisnotreleasedwhenacriticalsectionisexited.Oncealazylockisacquiredbyathread,otherthreadsthattrytoacquirethelockhavetoensurethatthelockis,orcanbe,released.LazylocksareusedbydefaultinOracleJRockitJVM27.6.Inolderreleases,lazylocksareonlyusedifyouhavestartedtheJVMwiththe-XXlazyUnlockingoption.

Athinlockcanbeinflatedtoafatlockandafatlockcanbedeflatedtoathinlock.TheJRockitJVMusesacomplexsetofheuristicstodeterminewhentoinflateathinlocktoafatlockandwhentodeflateafatlocktoathinlock.

LockChains

Severalthreadscanbetiedupinwhatiscalledlockchains.Althoughtheyappearsomewhatcomplex,lockchainsarefairlystraightforward.Theycanbedefinedasfollows:

●ThreadsAandBformalockchainifthreadAholdsalockthatthreadBistryingtotake.IfAisnottryingtotakealock,thenthelockchainis“open.”

●IfA->Bisalockchain,andB->Cisalockchain,thenA->B->Cisamorecompletelockchain.

●IfthereisnoadditionalthreadwaitingforalockheldbyC,thenA->B->Cisacompleteandopenlockchain.

LockChainTypes

TheJRockitJVManalyzesthethreadsandformscompletelockchains.Therearethreepossiblekindsoflockchains:

Open,DeadlockedandBlockedlockchains.

OpenChains

Openlockchainsrepresentastraightdependency,threadA

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 初中教育 > 数学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1