# HG changeset patch # User Fukuda Kouki # Date 1571817842 -32400 # Node ID 84b10c91ca43db8a0b7969973c68236743f056e2 # Parent 10b5e6b8583dc1c748fa376edd0008096d60aaea 提出ずみ中間予稿 diff -r 10b5e6b8583d -r 84b10c91ca43 .DS_Store Binary file .DS_Store has changed diff -r 10b5e6b8583d -r 84b10c91ca43 midterm/.DS_Store Binary file midterm/.DS_Store has changed diff -r 10b5e6b8583d -r 84b10c91ca43 midterm/code/client.p6 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/midterm/code/client.p6 Wed Oct 23 17:04:02 2019 +0900 @@ -0,0 +1,5 @@ +my $conn = IO::Socket::INET.new( :host, + :port(3333) ); + +$conn.print: 'FILEPASS'; + diff -r 10b5e6b8583d -r 84b10c91ca43 midterm/images/Raku.pdf Binary file midterm/images/Raku.pdf has changed diff -r 10b5e6b8583d -r 84b10c91ca43 midterm/midterm.aux --- a/midterm/midterm.aux Wed Oct 23 15:59:48 2019 +0900 +++ b/midterm/midterm.aux Wed Oct 23 17:04:02 2019 +0900 @@ -1,6 +1,8 @@ \relax \@writefile{toc}{\contentsline {section}{\numberline {1}スクリプト言語の高速実行}{1}} \@writefile{toc}{\contentsline {section}{\numberline {2}Raku}{1}} +\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces Rakuの構成}}{1}} +\newlabel{fig:perl6cbcinter}{{1}{1}} \@writefile{toc}{\contentsline {section}{\numberline {3}MoarVM}{1}} \@writefile{toc}{\contentsline {section}{\numberline {4}NQP}{1}} \@writefile{toc}{\contentsline {section}{\numberline {5}なぜRakuは遅いのか}{1}} @@ -11,8 +13,10 @@ \citation{*} \bibstyle{junsrt} \bibdata{reference} -\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces Abyssサーバーを用いたスクリプト言語実行の状態遷移}}{2}} -\newlabel{fig:perl6cbcinter}{{1}{2}} +\@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces Abyssサーバーを用いたスクリプト言語実行手順}}{2}} +\newlabel{fig:perl6cbcinter}{{2}{2}} \newlabel{codeseg}{{1}{2}} \@writefile{lol}{\contentsline {lstlisting}{\numberline {1}Abyssサーバーのsource code}{2}} +\newlabel{codeseg}{{2}{2}} +\@writefile{lol}{\contentsline {lstlisting}{\numberline {2}クライアント側のsource code}{2}} \@writefile{toc}{\contentsline {section}{\numberline {7}まとめ}{2}} diff -r 10b5e6b8583d -r 84b10c91ca43 midterm/midterm.log --- a/midterm/midterm.log Wed Oct 23 15:59:48 2019 +0900 +++ b/midterm/midterm.log Wed Oct 23 17:04:02 2019 +0900 @@ -1,4 +1,4 @@ -This is e-pTeX, Version 3.14159265-p3.6-141210-2.6 (utf8.euc) (TeX Live 2015) (preloaded format=platex 2016.4.14) 23 OCT 2019 15:43 +This is e-pTeX, Version 3.14159265-p3.6-141210-2.6 (utf8.euc) (TeX Live 2015) (preloaded format=platex 2016.4.14) 23 OCT 2019 17:03 entering extended mode restricted \write18 enabled. file:line:error style messages enabled. @@ -192,7 +192,14 @@ LaTeX Warning: Unused global option(s): [9.5pt]. -(./midterm.aux) +(./midterm.aux + +LaTeX Warning: Label `fig:perl6cbcinter' multiply defined. + + +LaTeX Warning: Label `codeseg' multiply defined. + +) \openout1 = `midterm.aux'. LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 40. @@ -222,8 +229,8 @@ (Font) Font shape `JT1/gt/m/n' tried instead on input line 49. LaTeX Font Info: Font shape `JY1/mc/bx/n' in size <14.4> not available (Font) Font shape `JY1/gt/m/n' tried instead on input line 49. -File: images/abyss.pdf Graphic file (type pdf) - +File: images/Raku.pdf Graphic file (type pdf) + File: ./images/emblem-bitmap.pdf Graphic file (type pdf) <./images/emblem-bitmap.pdf> @@ -235,7 +242,9 @@ [1 -] (./code/abyss.p6 +] +File: images/abyss.pdf Graphic file (type pdf) + (./code/abyss.p6 LaTeX Font Info: Try loading font information for OML+cmr on input line 1. (/usr/local/texlive/2015/texmf-dist/tex/latex/base/omlcmr.fd @@ -255,15 +264,20 @@ LaTeX Font Info: Font shape `OMS/cmr/m/n' in size <10> not available (Font) Font shape `OMS/cmsy/m/n' tried instead on input line 4. ) +(./code/client.p6) No file midterm.bbl. -[2] (./midterm.aux) ) +[2] (./midterm.aux) + +LaTeX Warning: There were multiply-defined labels. + + ) Here is how much of TeX's memory you used: - 2492 strings out of 493777 - 33160 string characters out of 6151334 - 246407 words of memory out of 5000000 - 5978 multiletter control sequences out of 15000+600000 + 2497 strings out of 493777 + 33219 string characters out of 6151334 + 291446 words of memory out of 5000000 + 5979 multiletter control sequences out of 15000+600000 13101 words of font info for 51 fonts, out of 8000000 for 9000 929 hyphenation exceptions out of 8191 28i,15n,43p,238b,1178s stack positions out of 5000i,500n,10000p,200000b,80000s -Output written on midterm.dvi (2 pages, 12724 bytes). +Output written on midterm.dvi (2 pages, 14452 bytes). diff -r 10b5e6b8583d -r 84b10c91ca43 midterm/midterm.pdf Binary file midterm/midterm.pdf has changed diff -r 10b5e6b8583d -r 84b10c91ca43 midterm/midterm.synctex.gz Binary file midterm/midterm.synctex.gz has changed diff -r 10b5e6b8583d -r 84b10c91ca43 midterm/midterm.tex --- a/midterm/midterm.tex Wed Oct 23 15:59:48 2019 +0900 +++ b/midterm/midterm.tex Wed Oct 23 17:04:02 2019 +0900 @@ -55,8 +55,9 @@ この問題を解決するために,サーバーのコンテナ化を行う. \section{Raku} +Rakuは元はPerl5の後継言語のPerl6として開発されていたが,現在は名称が変更されRakuとなっている. Rakuの現在の主流な実装はRakudoである.RakudoはMoarVM,とNQPと呼ばれるRakuのサブセット,NQPとRaku自身で記述されたRakuという構成である. -MoarVMはNQPを解釈する. +MoarVMはNQPとByte Codeを解釈する. NQP とは Not Quite Perl の略で Raku のサブセットである.その為基本的な文 法などは Raku に準拠しているが,変数を束縛で宣言する などの違いが見られる. @@ -65,6 +66,14 @@ Rakuの起動は,MoarVMを起動,nqpをロード,Rakudoをロードもしくはコンパイルし,その後JITしながら実行する. +\begin{figure}[H] + \begin{center} + \includegraphics[width=80mm]{images/Raku.pdf} + \end{center} + \caption{Rakuの構成} + \label{fig:perl6cbcinter} +\end{figure} + \section{MoarVM} MoarVM は Raku に特化した VM である.C言語で実装されている. JITコンパイルなどが現在導入されているが,起動時間などが低速である問題がある. MoarVM 独自の ByteCode があり, NQP からこれを出力する機能などが存在している. @@ -81,11 +90,12 @@ 通常Rubyのようなスクリプト言語ではまずrubyVMが起動し,その後スクリプトをByte code に変換して実行という手順を踏む. Rakudo はインタプリタの起動時間及び、 全体的な処理時間が他のスクリプト言語と比較して非常に低速である。 これはRakudo自体がRakuで書かれているため,MoarVMを起動し,RakudoとNQP をコンパイルし,その後スクリプトのByte code変換というような手順で進むためである。 +またRakuは実行時の情報が必要であり,メソッドを実行する際にinvokeが走ることも遅い原因である. \section{Abyssサーバー} -ここではAbyssサーバーについて説明する.AbyssサーバーはRakuで書かれている. -図1はAbyssサーバーを用いたスクリプト言語実行の状態遷移図である. AbyssサーバーはユーザーがRakuを実行する際,クライアント側から転送されてきたファイルを事前に起動してあるサーバー側が処理し,その実行結果を返す構造となっている. +ここではAbyssサーバーについて説明する.AbyssサーバーはRakuで書かれている. クライアント側から投げられたRakuを実行するためのサーバーである. +図1はAbyssサーバーを用いたスクリプト言語実行手順である. AbyssサーバーはユーザーがRakuを実行する際,クライアント側から転送されてきたファイルを事前に起動してあるサーバー側が処理し,その実行結果を返す構造となっている. この手法を用いることで,サーバー上で事前にRakudoを起動したRakudoを再利用し,投げられたRakuスクリプトの実行を行うためRakudoの起動時間を短縮できると推測できる. @@ -94,16 +104,19 @@ \begin{center} \includegraphics[width=80mm]{images/abyss.pdf} \end{center} - \caption{Abyssサーバーを用いたスクリプト言語実行の状態遷移} + \caption{Abyssサーバーを用いたスクリプト言語実行手順} \label{fig:perl6cbcinter} \end{figure} -Code1はAbyss サーバーの自身のソースコードである. +Code1はAbyss サーバーのソースコードである. Abyssサーバーは起動すると,まず自身にファイルを転送するためのソケットを生成し,その後ファイルを受け取るための待機ループに入る. -ファイルが送られてきた際はファイルの中身をバッファーに変換し読み込む,その後読み込んだバッファーを文字列にデコードし,文字列を式として評価するEVALを用いて,プログラムを実行する. -Code1の2行目にあるMONKEY−SEE−NO−EVALはRaku上でEVALを使用可能にするpragmaである. + +ファイルパスを受け取るとファイルパスをバッファーに変換し読み込む,その後読み込んだバッファーを文字列にデコードし,ファイルパスの文字列を読み込み,ファイルの中身を式として評価するEVALFILEを用いて,プログラムを実行する. +Code1の2行目にあるMONKEY−SEE−NO−EVALはRaku上でEVALFILEを使用可能にするpragmaである. 現状のRakuのEVALFILEでは,出力がサーバー側に返っているので,クライアント側から出力を見るためにクライアント側に返す必要がある. + \lstinputlisting[label=codeseg, caption=Abyssサーバーのsource code]{code/abyss.p6} +\lstinputlisting[label=codeseg, caption=クライアント側のsource code]{code/client.p6} %通常、自分でプロセス立ち上げてPerl6を実行する際は, %\section{問題点} @@ -115,6 +128,7 @@ Rakuには現状Unix domainソケットの実装がないので、Unix domainソケットを実装し、自分以外が実行できないようにすることが今後の課題に挙げられる. また今回例題として用いたものはスクリプト言語Rakuであったが,その他のスクリプト言語にも応用が利くかどうか検討する必要はある +今回用いたRakuのEVALFILE自体にクライアント側に出力を返す実装追加することも今後の課題に挙げられる. %またPerl6の機能としてevalfiel があるが現状出力がサーバー上に返ってしまい %手元に返ってこないので、evalfileの実装を出力が手元に返ってくるように書き換える必要がある