LoginSignup
0
1

More than 5 years have passed since last update.

コンピュータ将棋ソフトとの対局サーバーを立てよう<その19>

Last updated at Posted at 2017-03-21

前回の記事 : http://qiita.com/muzudho1/items/6d7accac76f947d9ce58

作ったプログラムを 相方に丸投げしたいので、マニュアルを書く必要があるんだが、どう書けばいいのか。

外側から触れる順に並べてみよう。

名称 場所
(1) 窓口 /var/www/html/tamesi26a5.php
(2) セマフォ起こし /home/★user/★project/expect_service/tamesi37a1.expect
(3) セマフォ /home/★user/★project/cpp_service/t37a1.d/tamesi37a1.exe
(4) 浮かむ瀬(チャイルド4) /home/★user/★project/ukamuse_sdt4_child4/bin/apery.exe

デプロイメントしにくいフォルダー階層だぜ……。まあ、37種類ほどのテストの数をこなしやすい用途のフォルダー階層なんで、本番向きに用意したものではない。

サーバー1台に この4点セット を配備したいんだが、ライブラリといった環境もいるだろ。

  • ERLANG
  • RabbitMQ 3.6.6
  • php-amqplib/php-amqplib 2.5.*
  • Composer
    • curl
    • bcmath
  • libev-dev
  • Expect 5.45-7
  • PHP 7.0
  • Apache 2.4.18

あっ、まだ けっこう沢山ある……。あとでまとめよう。これらもポン、ポンと、インストールできるようにしたい。
スクリプト化しろだって? それも丸投げだろ。マニュアルだけ書けばいい……。

起動方法

  • インストール方法
  • バージョン確認方法
  • 起動方法
  • 起動していることを確認する方法

がいるな。

設定方法

  • Apache と PHP をつなげるとこだけが難しい。自動化されてない。
  • メッセージ・キュー名がハードコーディングされている。増やしたいときどうするのか。
  • URLもハードコーディングされている。増やしたいときどうするのか。

コンパイル方法

  • コンパイルなんかするのか。もっと汎用的なプログラムにした方がいいんじゃないのか?

そもそも入っている前提のもの

  • apt
  • g++
  • mono 4.2.1
  • nano
  • grep
  • make
  • wget

これはキリがない。

消すもの

  • PHP 5

そういえば、設定の煩雑さに ぶち切れて、PHP 5 とかいうものを OS から跡形も残さず抹消したんだった。

Ubuntuの更新

Ubuntu を 16.04、または最新版に更新します。

do-release-upgrade

開発者じゃないんだったら、g++ は要らないか。

make コマンドは多分、最初から入ってるだろう。インストールに使えるかもしれない。

浮かむ瀬(チャイルド4)は、デバッグ版じゃなくて リリース版を渡すように注意だな。

定跡ファイルと、評価値ファイルも必要だ。

./apery bench

で、浮かむ瀬が 動いてるかどうか確認できることも マニュアルに書いておこう……、あっ! チャイルド4 では動かないや……。

USI

setoption name Minimum_Thinking_Time value 500

思考時間を 0.5 秒に伸ばすなら起動時に設定する必要がある。途中で変えたいなら、浮かむ瀬再起動か、あるいはソースコードレベルから改造。

bash は使わなかったな。

開発者じゃなければ mono も要らないか。

さくらVPS では var/www/html がWebページのデフォルト階層。

やって当たり前かと思っていたんだが、
PHP のエラー表示対応とか、日本語対応とか、まったくしなくていいな……。
出てくるのは bestmove 2g2f とかなんで……。
日本語が欲しいのはエラーが出たときだけか。

mbstring.internal_encoding = UTF-8

UTF-8 対応ぐらいは欲しいか。

PHP7 をインストールする。

apt-get -y install php php-cgi libapache2-mod-php php-common php-pear php-mbstring

php をインストールすると php7 が入る。php7 を入れたらアパッチを再起動する。

sudo /etc/init.d/apache2 restart
[ ok ] Restarting apache2 (via systemctl): apache2.service.

RabbitMQ のインストール

自分で書いた記事を あとで参考にしよう。
http://qiita.com/muzudho1/items/bf3f6debf6db7f96300c#_reference-bfc60da48dec57f06190

apt のインストール

RabbitMQ.Client.dll などをインストールするためのインストーラー。

apt install apt-file
apt-file update

クライアント用 RabbitMQ のインストール。

apt-file search RabbitMQ.Client.dll

ただ、RabbitMQ.Client.dll は Windows / C# 用だろう。System.Messaging とか、本番で使うだろうか?

ERLANG (アーラン)をダウンロード

あるいは、圧縮ファイルを丸ごと渡すか?
でもこれ、C# 用 System.Messaging 用だろ。本番運用で使うんだろうか?

NuGet の使い方

これも本番の運用中では使わないんじゃないか?
C# 用 System.Messaging 用だろ。

Ubuntu での RabbitMQ のグレードアップの仕方

これは必要。

sudo apt-get update
sudo apt-get install rabbitmq-server
gpg --keyserver pgpkeys.mit.edu --recv-key 7638D0442B90D010
gpg -a --export 7638D0442B90D010 | sudo apt-key add -
wget -O- https://packages.erlang-solutions.com/debian/erlang_solutions.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install init-system-helpers socat esl-erlang
wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install rabbitmq-server

RabbitMQ サーバーの起動

rabbitmq-server

[Ctrl]+[Z] で止めて

bg 1

1 はジョブ番号。

とする。

Composer を入れたい

PHP の環境を作るものなので、 /var/www/html ディレクトリに移動して作業すること。

curl が必要なので PHP7 用を入れる。

sudo apt-get install php-curl
sudo service apache2 restart
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

インストールを確認する。

ls -an

.composer という隠しファイルが作られていて、次のようにコマンドを叩く。

composer

composer をインストールできていれば、PHPファイルを置きたいフォルダーに、composer.json ファイルを自分で作る。

nano composer.json

composer.json

{
  "require": {
      "php-amqplib/php-amqplib": "2.6.*"
  }
}

composer.json があるところで

copmoser update

と叩く。まだ無理か。

bcmath をインストール

sudo apt install php7.0-bcmath
※パスワード入力
composer update

インストールの方が先か?

composer install

アパッチ再起動。

sudo service apache2 restart

自分の記事を見直す。
http://qiita.com/muzudho1/items/3ff3e8dfde0ff5bed203#_reference-96aadf48e98efd0298c7

cron は使わなかった。

自分の記事を見直す。
http://qiita.com/muzudho1/items/3ca7bade03f7c2fd8292#_reference-3e659d58af3dcf8582f4

expect 5.45-7 のインストール

apt-get -y install expect

既に入っているかも。

自分の記事を見直す。
http://qiita.com/muzudho1/items/8f940f8b4c679c23a174#_reference-a78ee16b0c896c7d47ce

AMQP-CPP

「AMQP-CPP」 (CopernicaMarketingSoftware/AMQP-CPP)
https://github.com/CopernicaMarketingSoftware/AMQP-CPP

ダウンロードしてインストールが要るか?

# make
# make install
# make pure

libev-dev もインストール

sudo apt-get update
sudo apt-get install libev-dev

自分の記事を見直す。
http://qiita.com/muzudho1/items/1432040086218e14ebe2#_reference-a80ce71e0ed6ad5c0197

自分の記事を見直す。
http://qiita.com/muzudho1/items/798dfbf267340f3801e1#_reference-1a747e743b7ff0dbb050

自分の記事を見直す。
http://qiita.com/muzudho1/items/6fbe1681a7e14dcac3f2#_reference-d57789b2016536e29156

自分の記事を見直す。
http://qiita.com/muzudho1/items/3d292bafc4a8fa54eb43#_reference-af85235244f8a382e785

自分の記事を見直す。
http://qiita.com/muzudho1/items/b45c52c50f11011e17f3#_reference-f0209d8d92425a55c741

自分の記事を見直す。
http://qiita.com/muzudho1/items/90eec636fc1664dbfcee#_reference-99a929aad0b8a250b719

ニコ動の動画が見れなかったのでクロームのキャッシュをクリアーしたからか、Qiitaへの投稿が 400番台エラーになって無駄になった。
まあいいか。

フォルダー構造を本番用に変えよう

1つのディレクトリにまとまってた方がいいだろ。

メモ書き

開発中ネームを適当にきめる。

    shogi

    あんまりなので shogi1s にするか。(1秒未満の指し手→shogi 1 second)
    sasite1s の方がいいか?

    /var/www/html/sasite1s/
        |
        +--- ukamuse_sdt4_child5.php
                 # これにアクセスすると、bestmove 2g2f などを返す

    /usr/games/sasite1s/
        |
        +--- ukamuse_sdt4_sasite1s/
                |
                +--- reservation.expect
                |
                +--- reservation.exe
                |
                +--- bin
                        |
                        +--- apery
                        |
                        +--- apery.out.log
                        |
                        +--- apery.err.log
                        |
                        +--- 20161007
                                |
                                +--- KKP_synthesized.bin
                                |
                                +--- KK_synthesized.bin
                                |
                                +--- KPP_synthesized.bin

    メッセージキュー
        "To_UkamuseSdt4_Sasite1s"    →浮かむ瀬SDT4(sasite1s用)
        "From_UkamuseSdt4_Sasite1s"  ←浮かむ瀬SDT4(sasite1s用)

    パッケージ
        |
        |                           # Webアプリケーション
        +--- Apache 2.4.18
        |       |
        |       +--- curl ------+
        |       |               |
        |       +--- bcmath ----+
        |                       |
        |                       +--- Composer
        |                               |
        |                               +--- PHP 7.0
        |
        |
        |                           # 外部プロセス操作
        +--- Expect 5.45-7
        |
        |
        |                           # プロセス間通信
        +--- libev-dev
                |
                +--- ERLANG 19.3
                        |
                        +--- RabbitMQ 3.6.6
                        |
                        +--- php-amqplib/php-amqplib 2.5.*

だいぶ 詰めてきたか?

    プロセス
        |
        +--- RabbitMQ Server
        |
        +--- ./apery

とりあえずリネームしよう。

変更前 変更後
窓口 /var/www/html/tamesi26a5.php /var/www/html/sasite1s/ukamuse_sdt4_sasite1s.php
セマフォ起こし /home/★user/★project/expect_service/tamesi37a1.expect /usr/games/sasite1s/ukamuse_sdt4_sasite1s/reservation.expect
セマフォ /home/★user/★project/cpp_service/t37a1.d/tamesi37a1.exe /usr/games/sasite1s/ukamuse_sdt4_sasite1s/reservation.exe
浮かむ瀬(チャイルド4) /home/★user/★project/ukamuse_sdt4_child4/bin/apery.exe /usr/games/sasite1s/ukamuse_sdt4_sasite1s/binapery

ソースコードも本番環境に配布した方がいいんだろうか?

ソースは Git Hub か、Bit Bucket に置いておくものだよな。
本番環境にソースは置かない方がいいか。ベストが分からんところだ。

etc

設定ファイルを etc ディレクトリ下に置いていいんだろうか。だったら使おうかな。

    設定ファイル
    /
    |
    +--- etc/sasite1s.d/
            |
            +--- IpAddress.txt
                     # (2017-03-23 Comment)要らないのでは。

こんなんでいいんだろうか?

(2017-03-23 Comment) 別にIPアドレスとかハードコーディングしてなかった。要らないのでは?

フォルダーのパーミッションを書き込み可能にして ファイルを移動。

次の実行形式ファイルのパーミッションを実行可能に変更。

  • reservation.expect
  • reservation.exe
  • bin/apery

テキスト・エディターでソースを保存したときは、文字コードが UTF-8 BOM有りにしておく。

改行もLinux用に置換しておきたいが、問題があればやる。

浮かむ瀬改造版の起動

./apery --enqueue From_UkamuseSdt4_Sasite1s durable --dequeue To_UkamuseSdt4_Sasite1s durable autodelete > ./apery.out.log 2> ./apery.err.log < /dev/null &

RabbitMQ の起動方法は省略。

おやっ? 実行できなくなっている。

# ./apery
Killed
-rwxr-xr-x 1 ★user ★user 1601896 Mar 22 23:43 apery

容量を確認してみるか。

テスト環境

# ls -l
total 1576
drwxr-xr-x 2 root root    4096 Mar 12 07:09 20161007
-rwxr-xr-x 1 root root 1601896 Mar 21 02:33 apery
-rw-r--r-- 1 root root       0 Mar 21 04:17 apery.err.log
-rw-r--r-- 1 root root       0 Mar 21 04:17 apery.out.log
-rw-r--r-- 1 root root    1531 Mar 12 05:48 benchmark.sfen

benchmark.sfen は必需品なのか?

本番環境

# ls -l
total 1576
drwxrwxr-x 2 ★user ★user    4096 Mar 22 23:43 20161007
-rwxr-xr-x 1 ★user ★user 1601896 Mar 22 23:43 apery
-rw-r--r-- 1 root  root        0 Mar 23 00:43 apery.err.log
-rw-r--r-- 1 root  root        0 Mar 23 00:43 apery.out.log
-rw-rw-r-- 1 ★user ★user    1539 Mar 23 00:48 benchmark.sfen

容量が違う。改行がおかしいのか?

テスト環境

# ls -l
total 837616
-rw-rw-r-- 1 ★user ★user  81251424 Mar 22 23:44 KKP_synthesized.bin
-rw-rw-r-- 1 ★user ★user     52488 Mar 22 23:43 KK_synthesized.bin
-rw-rw-r-- 1 ★user ★user 776402496 Mar 22 23:46 KPP_synthesized.bin

本番環境

root@tk2-217-18401:/usr/games/sasite1s/ukamuse_sdt4_sasite1s/bin/20161007# ls -l
total 837616
-rw-rw-r-- 1 ★user ★user  81251424 Mar 22 23:44 KKP_synthesized.bin
-rw-rw-r-- 1 ★user ★user     52488 Mar 22 23:43 KK_synthesized.bin
-rw-rw-r-- 1 ★user ★user 776402496 Mar 22 23:46 KPP_synthesized.bin

評価値ファイルに変わりはなさげ。

# ps aux | grep apery
root     19584  0.3 48.1 1613836 489540 ?      Sl   Mar21  10:33 ./apery --enqueue 1113 durable --dequeue 1112 durable autodelete
root     30305  0.0  0.0  12936   984 pts/1    S+   01:17   0:00 grep --color=auto apery

テスト環境のは 2つ目を起動できるのだろうか?

# ./apery --enqueue From_UkamuseSdt4_Sasite1s durable --dequeue To_UkamuseSdt4_Sasite1s durable autodelete > ./apery.out.log 2> ./apery.err.log < /dev/null &
[1] 30327
# jobs
[1]+  Killed                  ./apery --enqueue From_UkamuseSdt4_Sasite1s durable --dequeue To_UkamuseSdt4_Sasite1s durable autodelete > ./apery.out.log 2> ./apery.err.log < /dev/null

この引数では起動できないようだ。

# ./apery --enqueue 1115 durable --dequeue 1114 durable autodelete > ./apery.out.log 2> ./apery.err.log < /dev/null &
[1] 30362
# jobs
[1]+  Killed                  ./apery --enqueue 1115 durable --dequeue 1114 durable autodelete > ./apery.out.log 2> ./apery.err.log < /dev/null

なんで起動できなくなったんだろな。あるいはすぐ落ちるのか。

localhost:5672 にはテスト環境が接続しているからか?
しかし 送信用、受信用で接続とか いくつもするし。
1つのポートに 複数のチャンネルを開くのも 普通の使い方だし。

Killed はどんなときに起こるのか?

top
top - 01:41:18 up 18 days,  4:23,  1 user,  load average: 0.05, 0.10, 0.08
Tasks: 104 total,   2 running, 102 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.5 us,  0.2 sy,  0.0 ni, 99.2 id,  0.0 wa,  0.0 hi,  0.2 si,  0.0 st
KiB Mem :  1017748 total,    94708 free,   756804 used,   166236 buff/cache
KiB Swap:  1046524 total,    38520 free,  1008004 used.   103964 avail Mem
 8169 rabbitmq  20   0 2704848  26396   1744 S   0.7  2.6  18:59.95 beam.smp
13211 www-data  20   0  352576  10096   4300 S   0.7  1.0   0:00.22 apache2
30710 root      20   0   40516   1988   1380 R   0.7  0.2   0:01.45 top
19584 root      20   0 1613836 489660   1180 S   0.3 48.1  10:39.92 apery
28688 root      20   0       0      0      0 S   0.3  0.0   0:01.26 kworker/0:2
    1 root      20   0   37560   2468   1312 S   0.0  0.2   3:46.25 systemd
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.60 kthreadd
    3 root      20   0       0      0      0 S   0.0  0.0   0:27.75 ksoftirqd/0
    5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H
    7 root      20   0       0      0      0 S   0.0  0.0   4:41.36 rcu_sched
    8 root      20   0       0      0      0 S   0.0  0.0   6:10.87 rcuos/0
    9 root      20   0       0      0      0 S   0.0  0.0   0:48.06 rcuos/1

apery がメモリを 48% ぐらい使ってないか?

Apery の USI_Hash はデフォルトで 256MB、
最大で 1024 * 1024 MegaByte、つまり 1 Tera Byte。

これで 48% だとすれば、メモリは 2Tera Byte ぐらいあるのか??

KiB Swap:  1046524

という表記を見ると、1 GigaByte ぐらいのスワップが発生していると見ていいんだろうか?

USI_Hash

を 256 から 64 に減らしたらどうだろうか?

 8169 rabbitmq  20   0 2707928  28324   1768 S   0.7  2.8  19:14.44 beam.smp
31262 root      20   0 1482308 148332   2916 S   0.3 14.6   0:01.73 apery
31374 root      20   0   40516   1992   1380 R   0.3  0.2   0:00.02 top
    1 root      20   0   37560   2468   1312 S   0.0  0.2   3:46.56 systemd
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.60 kthreadd

再起動直後は 14.6 % か。これを検討開始させると 34.5 % ぐらい増えるのか? およそ 3分の1?

31262 root      20   0 1482472 659364   1700 S   1.0 64.8   0:07.06 apery
 8169 rabbitmq  20   0 2705360  25784   1620 S   0.7  2.5  19:20.15 beam.smp
  714 memcache  20   0  378776  12004      0 S   0.3  1.2   5:31.89 memcached
  715 mysql     20   0 1302112    524      0 S   0.3  0.1  38:47.58 mysqld
11959 root      20   0  351884   8324   8048 S   0.3  0.8   3:51.47 apache2
31623 root      20   0   40516   1992   1384 R   0.3  0.2   0:00.03 top
    1 root      20   0   37560   1164    580 S   0.0  0.1   3:46.70 systemd
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.60 kthreadd
    3 root      20   0       0      0      0 S   0.0  0.0   0:27.78 ksoftirqd/0
    5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H

USI_Hash を 128 にしたんだが、なぜかメモリは 64.8 %に増えてしまった。

テスト環境の起動のメモ書き

どんどんアップデートして内容が古くなるが、今のものを書いとく。

────────────────────────────────────────

    二重起動防止
    ============

        # ps aux | grep apery
            # プロセスがいくつ起動しているか確認できる

        # ps aux | grep php
            # 競合するサンプル・プログラムが走ってなければOK。

    浮かむ瀬(テスト用)の起動<その1>
    ====================================

        # cd /home/★user/shogi/ukamuse_sdt4_child4/bin

        # ./apery --enqueue 1113 durable --dequeue 1112 durable autodelete > ./apery.out.log 2> ./apery.err.log < /dev/null &

    浮かむ瀬(テスト用)の起動<その1>の確認
    ==========================================

        # jobs
        [1]+  Running                 ./apery --enqueue 1113 durable --dequeue 1112 durable autodelete > ./apery.out.log 2> ./apery.err.log < /dev/null &

        ※起動後、30秒ぐらい経ってから次のステップを始めた方が usiコマンドの応答が正常に返ってくるようだ。(原因不明、状況不明)

    浮かむ瀬(テスト用)の起動<その2>
    ====================================

        # /home/★user/shogi/csharp_service/tamesi34_cs.exe 2> /home/★user/shogi/csharp_service/tamesi34_cs.err.log

            Delete ? >
                        [Enter] ※何も入力せず [Enter]キーだけ押す。

            Enqueue ? >
                        1112
            Enqueue ? >
                        3
            Dequeue ? >
                        1113
            Dequeue ? >
                        1
            Enqueue? >
                        usi

                                ※数秒して、次のような応答が返ってくればok(一例)
                            <-------- [interrupt!] Dequeue(^q^) id name ukamuse_SDT4
                            id author Hiraoka Takuya

                            option name Best_Book_Move type check default false
                            option name Book_File type string default book/20150503/book.bin
                            option name Byoyomi_Margin type spin default 500 min 0 max 2147483647
                            option name Clear_Hash type button
                            option name Draw_Ply type spin default 256 min 1 max 2147483647
                            option name Engine_Name type string default ukamuse_SDT4
                            option name Max_Book_Ply type spin default 32767 min 0 max 32767
                            option name Max_Random_Score_Diff type spin default 0 min 0 max 32600
                            option name Max_Random_Score_Diff_Ply type spin default 32767 min 0 max 32767
                            option name Min_Book_Ply type spin default 32767 min 0 max 32767
                            option name Min_Book_Score type spin default -180 min -32601 max 32601
                            option name Minimum_Thinking_Time type spin default 20 min 0 max 2147483647
                            option name Move_Overhead type spin default 30 min 0 max 5000
                            option name MultiPV type spin default 1 min 1 max 594
                            option name OwnBook type check default true
                            option name Slow_Mover type spin default 89 min 1 max 1000
                            option name Slow_Mover_10 type spin default 10 min 1 max 1000
                            option name Slow_Mover_16 type spin default 20 min 1 max 1000
                            option name Slow_Mover_20 type spin default 40 min 1 max 1000
                            option name Threads type spin default 2 min 1 max 256
                            option name Time_Margin type spin default 4500 min 0 max 2147483647
                            option name USI_Hash type spin default 256 min 1 max 1048576
                            option name USI_Ponder type check default true
                            usiok

                                ※usiokの応答が返ってこなければ、動いていない。(原因不明、状況不明)
                                ※aperyのジョブをkillし、起動からやり直すこと。

                                ※プロンプトはでないので、usiokを目印に続けて打ち込む。

                        setoption name USI_Hash value 128
                                ※ ハッシュサイズ
                                ※ デフォルトで 256 だが、サーバーのメモリの 48% を使ってしまって 2台起動できない。
                                ※ そこで半分の 128 にしてみよう。

                                ※ 応答はない

            Enqueue? >
                        isready
                                ※3.6秒ほどかかる
                                ※10秒経っても反応がなければ、起動中に失敗か?
                            readyok

        エラーログの確認
        ================

            # nano /home/★user/shogi/ukamuse_sdt4_child4/bin/apery.err.log
            # nano /home/★user/shogi/csharp_service/tamesi34_cs.err.log

────────────────────────────────────────
 8169 rabbitmq  20   0 2705872  16588   1504 S   1.0  1.6  19:41.75 beam.smp
32006 root      20   0 1875684 801608   1680 R   0.7 78.8   0:11.87 apery
    1 root      20   0   37560    976    448 S   0.0  0.1   3:47.19 systemd
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.61 kthreadd
    3 root      20   0       0      0      0 S   0.0  0.0   0:27.82 ksoftirqd/0

USI_Hash を 512 にしたら 78.8% に増えただけだった。

 8169 rabbitmq  20   0 2706896   6856   1468 S   1.7  0.7  19:43.25 beam.smp
32644 root      20   0 1416932 553580   1664 S   0.7 54.4   0:02.40 apery
11959 root      20   0  351884      8      0 S   0.3  0.0   3:52.00 apache2
    1 root      20   0   37560   1048    564 S   0.0  0.1   3:47.21 systemd
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.61 kthreadd
    3 root      20   0       0      0      0 S   0.0  0.0   0:27.82 ksoftirqd/0
    5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H
    7 root      20   0       0      0      0 S   0.0  0.0   4:43.54 rcu_sched
    8 root      20   0       0      0      0 S   0.0  0.0   6:13.31 rcuos/0

USI_Hash を 64 MB にしても 54.4 % もメモリーを使うのか?

 8169 rabbitmq  20   0 2706384  16576   1460 S   0.7  1.6  19:45.29 beam.smp
  310 root      20   0   40516   1992   1384 R   0.3  0.2   0:00.03 top
32732 root      20   0 1384164 591988   1736 S   0.3 58.2   0:02.45 apery
    1 root      20   0   37560   1056    584 S   0.0  0.1   3:47.27 systemd
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.61 kthreadd
    3 root      20   0       0      0      0 S   0.0  0.0   0:27.82 ksoftirqd/0
    5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H
    7 root      20   0       0      0      0 S   0.0  0.0   4:43.66 rcu_sched
    8 root      20   0       0      0      0 S   0.0  0.0   6:13.40 rcuos/0
    9 root      20   0       0      0      0 S   0.0  0.0   0:48.48 rcuos/1
   10 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_bh

USI_Hash を 32 MB にしても、58.2 %もメモリーを使っている(/_\)

# jobs
[1]-  Running                 ./apery --enqueue From_UkamuseSdt4_Sasite1s durable --dequeue To_UkamuseSdt4_Sasite1s durable autodelete > ./apery.out.log 2> ./apery.err.log < /dev/null &  (wd: /usr/games/sasite1s/ukamuse_sdt4_sasite1s/bin)
[2]+  Killed                  ./apery --enqueue 1113 durable --dequeue 1112 durable autodelete > ./apery.out.log 2> ./apery.err.log < /dev/null

テスト環境版でも、2機目にすると Killed になってしまうようだ。
困ったもんだ。

reservation.exe

# /usr/games/sasite1s/ukamuse_sdt4_sasite1s/reservation.exe --enqueue From_UkamuseSdt4_Sasite1s durable --dequeue To_UkamuseSdt4_Sasite1s durable autodelete
コマンドライン引数の「--queue 送信先キュー名 寿命」を漏れなく指定してください。
例: --queue 1113 durable autodelete
寿命は可変個数設定可能「durable」「autodelete」「passive」「exclusive」
name_queue=[]

あっ、コマンドライン引数を間違っていたぜ。

# /usr/games/sasite1s/ukamuse_sdt4_sasite1s/reservation.exe --queue To_UkamuseSdt4_Sasite1s durable autodelete
queueName = "To_UkamuseSdt4_Sasite1s"
messages = 0
consumers = 1

こう書くのだった。

reservation.expect

# /usr/games/sasite1s/ukamuse_sdt4_sasite1s/reservation.expect --queue To_UkamuseSdt4_Sasite1s durable autodelete
/usr/games/sasite1s/ukamuse_sdt4_sasite1s/reservation.expect: line 1: #!/usr/bin/expect: No such file or directory
/usr/games/sasite1s/ukamuse_sdt4_sasite1s/reservation.expect: line 2: $'\r': command not found
: No such file or directory_sdt4_sasite1s/reservation.expect: line 3: cd: /usr/games/sasite1s/ukamuse_sdt4_sasite1s
/usr/games/sasite1s/ukamuse_sdt4_sasite1s/reservation.expect: line 4: $'\r': command not found
/usr/games/sasite1s/ukamuse_sdt4_sasite1s/reservation.expect: line 6: $'\r': command not found
/usr/games/sasite1s/ukamuse_sdt4_sasite1s/reservation.expect: line 7: spawn: command not found
/usr/games/sasite1s/ukamuse_sdt4_sasite1s/reservation.expect: line 8: $'\r': command not found
": no such file or directorye =
": no such file or directory =
": no such file or directorys =

あれっ、「#!/usr/bin/expect: No such file or directory」
実行方法が違うのか?

# expect /usr/games/sasite1s/ukamuse_sdt4_sasite1s/reservation.expect --queue To_UkamuseSdt4_Sasite1s durable autodelete

あー、expect は実行ファイルじゃなくて、コマンドだったか!

ukamuse_sdt4_sasite1s.php ファイル間違ってた

  • × tamesi37a1.php.txt
  • 〇 tamesi26a5.php.txt

元にするソースコードを間違っていたので直す。

composer もインストールしないと

Warning: require_once(/var/www/html/sasite1s/vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/sasite1s/ukamuse_sdt4_sasite1s.php on line 5

Fatal error: require_once(): Failed opening required '/var/www/html/sasite1s/vendor/autoload.php' (include_path='.:/usr/share/php') in /var/www/html/sasite1s/ukamuse_sdt4_sasite1s.php on line 5

じゃあ、

cd /var/www/html/sasite1s

に移動して、

nano composer.json

と叩いてファイルを作る。

composer.json

{
  "require": {
      "php-amqplib/php-amqplib": "2.6.*"
  }
}
# composer install

なんかエラーっぽい表示が出るが、
ローディングは 遅れて始まるまで 時間がかかるので、1分ぐらい気長に待つこと。

Do not run Composer as root/super user! See https://getcomposer.org/root for details
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing php-amqplib/php-amqplib (v2.6.3) Downloading: 100%
Writing lock file
Generating autoload files
# ls -l
total 20
-rw-r--r-- 1 root  root    65 Mar 23 04:22 composer.json
-rw-r--r-- 1 root  root  3040 Mar 23 04:23 composer.lock
-rw-rw-r-- 1 csg10 csg10 6258 Mar 23 04:19 ukamuse_sdt4_sasite1s.php
drwxr-xr-x 4 root  root  4096 Mar 23 04:23 vendor

vendor というフォルダーができていれば、PHPでパッケージを利用する準備はOK。

ブラウザから

http://★サイトアドレス/tamesi26a5.php?sfen%20lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL%20b%20-%201%20moves

でアクセス。画面上は

error = "busy" busy = 1

だが、ページのソースを見ると

error = "busy"
busy = 1

改行されている。OK。メッセージが1件残っている。

# rabbitmqctl list_queues
Listing queues ...
1112    1
amq.gen-6X-aAcq9ZPaEA4RZwkLz_A  0
1113    0
To_UkamuseSdt4_Sasite1s 0
From_UkamuseSdt4_Sasite1s       0

1112 には 1件溜まっているが、To_UkamuseSdt4_Sasite1s は 0件だ。
見に行く先を間違えているのでは?

見に行く先を間違えていた。正しくは

http://★サイトアドレス/sasite1s/ukamuse_sdt4_sasite1s.php?sfen lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL b - 1 moves

だ。

ukamuse_sdt4_sasite1s.php に埋め込んでいたメッセージ・キュー名も全部 書き直し。

URL

なんか

http://★サイトアドレス/sasite1s/ukamuse_sdt4_sasite1s.php?

という名前は慎重すぎる気がする。

http://★サイトアドレス/sasite1s/ukamuse_sdt4.php?

でいいんじゃないか?

ところで 技巧を実行してみたんだが、

# ./release
usi
id name Gikou 20160606
id author Yosuke Demura
option name BookMaxPly type spin default 50 min 0 max 50
option name ByoyomiMargin type spin default 100 min 0 max 10000
option name DrawScore type spin default 0 min -200 max 200
option name FischerMargin type spin default 12000 min 0 max 60000
option name MinBookScoreForBlack type spin default 0 min -500 max 500
option name MinBookScoreForWhite type spin default -180 min -500 max 500
option name MinThinkingTime type spin default 1000 min 10 max 60000
option name MultiPV type spin default 1 min 1 max 700
option name NarrowBook type check default false
option name OwnBook type check default true
option name SuddenDeathMargin type spin default 60 min 0 max 600
option name Threads type spin default 2 min 1 max 64
option name TinyBook type check default false
usiok
isready
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Aborted

何か std::bad_alloc が出ているな。

# ./apery
Killed
# ./apery bench
Killed

改造版浮かむ瀬チャイルド4 は、メモリの使い方が重たいんだろうか?

話題が変わるんで次の記事へ

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1