diff --git a/.gitignore b/.gitignore index 45b752d..cbb5222 100644 --- a/.gitignore +++ b/.gitignore @@ -330,4 +330,10 @@ ASALocalRun/ .mfractor/ .linker.txt -coreclrbin \ No newline at end of file +coreclrbin + +.vscode/ +tibcdata/ +rawibcdata/ +src/ApiTemplate/tibcdata +published/ diff --git a/build-coreclr.sh b/build-coreclr.sh index d1c00b0..8933f34 100755 --- a/build-coreclr.sh +++ b/build-coreclr.sh @@ -24,3 +24,5 @@ cp "$coreclrbuilddir/Microsoft.NET.HostModel.dll" "$coreclrbinariesdir" cp "$coreclrbuilddir/corebundle" "$coreclrbinariesdir" cp "$coreclrbuilddir/System.Private.CoreLib.dll" "$coreclrbinariesdir" cp "$coreclrbuilddir/crossgen" "$coreclrbinariesdir" +cp -r "$coreclrbuilddir/crossgen2" "$coreclrbinariesdir/crossgen2" +cp -r "$coreclrbuilddir/tibcmgr" "$coreclrbinariesdir/tibcmgr" diff --git a/produce_tibc.sh b/produce_tibc.sh new file mode 100755 index 0000000..c1b9e0e --- /dev/null +++ b/produce_tibc.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +scriptroot="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +referencescommandline= + +for dll in $scriptroot/src/ApiTemplate/obj/Release/netcoreapp3.0/linux-x64/multifile-publish/*.dll +do + referencescommandline="$referencescommandline -r:$dll" +done + +rm -r -f $scriptroot/tibcdata +mkdir -p $scriptroot/tibcdata + +for dll in $scriptroot/src/ApiTemplate/obj/Release/netcoreapp3.0/linux-x64/multifile-publish/*.dll +do + assemfullname=$(basename $dll) + assemname="${assemfullname%.*}" + ibcfile=$scriptroot/rawibcdata/$assemname.ibc + tibcfile=$scriptroot/tibcdata/$assemname.tibc + if [ -f $ibcfile ] + then + tibc_command="$scriptroot/src/coreclrbin/tibcmgr/tibcmgr convert $referencescommandline $ibcfile $dll $tibcfile" + echo $tibc_command + $tibc_command + fi +done + diff --git a/produce_tunedimage.sh b/produce_tunedimage.sh new file mode 100755 index 0000000..26e879a --- /dev/null +++ b/produce_tunedimage.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +scriptroot="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + + +rm -r -f $scriptroot/src/ApiTemplate/tibcdata +mkdir -p $scriptroot/src/ApiTemplate/tibcdata +cp $scriptroot/tibcdata/* $scriptroot/src/ApiTemplate/tibcdata + +dotnet publish -c Release src/ApiTemplate/ApiTemplate.csproj -o publish -p:SelfContained=true -p:UseStaticHost=true -p:UsePublishFilterList=true -p:PublishTrimmed=true -p:PublishReadyToRun=true -p:UseTibcData=true -p:UseCrossgen2=true $1 diff --git a/run_tuning.sh b/run_tuning.sh new file mode 100755 index 0000000..58877f4 --- /dev/null +++ b/run_tuning.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +scriptroot="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +dotnet publish -c Release src/ApiTemplate/ApiTemplate.csproj -o publish -p:UseStaticHost=true -p:UsePublishFilterList=true -p:LinkAggressively=true -p:PublishTrimmed=true -p:SelfContained=true -p:ProduceTuningImage=true -p:UseCrossgen2=true -r linux-x64 -p:PublishReadyToRun=true + +rm -r -f $scriptroot/rawibcdata +mkdir -p $scriptroot/rawibcdata + +export COMPlus_ZapBBInstr=* +export COMPlus_ZapBBInstrDir=$scriptroot/rawibcdata +export COMPlus_ZapBBInstrR2RGenerics=2 + +$scriptroot/publish/ApiTemplate & PROC_ID=$! +echo $PROC_ID + +sleep 1 +curl http://localhost:5000/WeatherForecast > /dev/null +while [ $? -ne 0 ] +do + sleep 1 + curl http://localhost:5000/WeatherForecast > /dev/null +done + +echo Service Live! + +counter=1 +while [ $counter -le 10 ] +do + echo $counter + curl http://localhost:5000/WeatherForecast > /dev/null + counter=$(($counter+1)) + sleep 1 +done + +echo Telling the service to quit +kill -s SIGTERM $PROC_ID + +sleep 1 +while kill -0 "$PROC_ID" >/dev/null 2>&1; do + echo "PROCESS IS STILL RUNNING" + sleep 1 +done + +echo "PROCESS TERMINATED" + +$scriptroot/produce_tibc.sh +$scriptroot/produce_tunedimage.sh + diff --git a/send-to-perflab.sh b/send-to-perflab.sh index 30959d4..293ecdf 100755 --- a/send-to-perflab.sh +++ b/send-to-perflab.sh @@ -11,6 +11,12 @@ if [[ -z "$client" ]] || [[ -z "$server" ]]; then exit 1 fi +crossgen2Arguments= +if [ "$1" == "crossgen2" ]; then + echo "Using crossgen2" + crossgen2Arguments="--build-arg /p:UseCrossgen2=true --build-arg /p:UseTibcData=true" +fi + # clone benchmarks repo if [[ ! -e "$driverproject" ]]; then git clone https://github.com/aspnet/benchmarks @@ -24,6 +30,8 @@ dotnet run -p "$driverproject" -- \ --self-contained \ --sdk 3.0.100-rc1-014176 \ --path weatherforecast \ + --aspnetcoreversion 3.0 \ + --runtimeversion 3.0 \ --warmup 1 \ --duration 2 \ --build-arg "/p:SelfContained=true" \ @@ -35,7 +43,8 @@ dotnet run -p "$driverproject" -- \ --display-output \ --iterations 1 \ --collect-counters \ - --env "COMPlus_gcServer=1" + --env "COMPlus_gcServer=1" \ + $crossgen2Arguments # --fetch \ # --collect-startup \ diff --git a/src/ApiTemplate/Linker.xml b/src/ApiTemplate/Linker.xml index d12dfda..0ee1ba3 100644 --- a/src/ApiTemplate/Linker.xml +++ b/src/ApiTemplate/Linker.xml @@ -3,6 +3,7 @@ + diff --git a/src/CustomR2RLogic.targets b/src/CustomR2RLogic.targets index f27ea2d..0650e5c 100644 --- a/src/CustomR2RLogic.targets +++ b/src/CustomR2RLogic.targets @@ -1,11 +1,15 @@ + + $(MSBuildProjectDirectory)/tibcdata/ + <_CrossgenTool Remove="@(_CrossgenTool)" /> - <_CrossgenTool Include="$(CoreClrBinariesDir)crossgen" /> + <_CrossgenTool Include="$(CoreClrBinariesDir)crossgen" Condition="'$(UseCrossgen2)' != 'true'" /> + <_CrossgenTool Include="$(CoreClrBinariesDir)crossgen2/crossgen2" Condition="'$(UseCrossgen2)' == 'true'" /> @@ -18,18 +22,50 @@ <_ReadyToRunImplementationAssemblies Remove="@(_ReadyToRunImplementationAssemblies)" - Condition=" '%(Extension)' != '.dll' " /> + Condition=" '%(Extension)' != '.dll'" /> + <_TibcFiles Include="$(TibcDir)*.tibc" Condition="'$(UseCrossgen2)' == 'true'" /> + - + + + @(_CrossgenTool) /nologo /MissingDependenciesOK $(CrossgenCommand) /r @(_ReadyToRunImplementationAssemblies->'%(FullPath)', ' /r ') - + + + + + + @(_CrossgenTool) + + $(CrossgenCommand) --resilient + $(CrossgenCommand) --tuning + $(CrossgenCommand) --Ot + $(CrossgenCommand) --inputbubble --partial -t:@(_TibcFiles->'%(FullPath)', ' -t:') + + $(CrossgenCommand) -r:@(_ReadyToRunImplementationAssemblies->'%(FullPath)', ' -r:') + + + + + + + +