LoginSignup
1
0

More than 5 years have passed since last update.

H2Oを5秒で3%速くする

Posted at

タイトルは煽りです

H2O の性能測定する時って (べつに nginx とか何でも同じだけど)、
普通は「アクセスログなんかいらねえ」ので、「ログは一切出すな」的な設定にするのが普通ですよね?

H2O だと、具体的には *.conf で

    access-log: /dev/null

出力先を /dev/null にしてあげるとかをよくやると思います。

ところが、こういう風に設定を書いても、「ログをとる関数のリストをスキャンして順番に呼び出す」という処理は内部的にはやらざるをえないので、ゼロ・オーバーヘッドにはならないです。

そこで、いっそのこと access-log の設定自体を消してやれば、/dev/null に投げる分の時間さえリストラできます:

    # access-log: /dev/null

access-log: /dev/null 「あり」と「なし」で、雑に gprof をとった結果は下のような感じ:

# access-log: /dev/null あり
Flat profile:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls  ms/call  ms/call  name    
 11.11      0.35     0.35   680393     0.00     0.00  on_req_tile (tile-proxy.c:179)
  9.21      0.64     0.29   712536     0.00     0.00  handle_incoming_request (http1.c:379)
  6.98      0.86     0.22   710764     0.00     0.00  log_access (access_log.c:248)  # <== ここ
  5.08      1.02     0.16    13346     0.01     0.01  evloop_do_proceed (epoll.c.h:94)
  4.76      1.17     0.15    12932     0.01     0.23  h2o_evloop_run (evloop.c.h:482)
...(略)
  0.00      3.15     0.00        1     0.00     0.00  yoml__resolve_alias (yoml-parser.h:157)
# access-log: /dev/null なし
Flat profile:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls  ms/call  ms/call  name    
 10.19      0.33     0.33   906677     0.00     0.00  on_req_tile (tile-proxy.c:179)
  8.64      0.61     0.28   108967     0.00     0.00  evloop_do_proceed (epoll.c.h:94)
  8.02      0.87     0.26   870058     0.00     0.00  flatten_headers (http1.c:555)
  7.72      1.12     0.25   961038     0.00     0.00  handle_incoming_request (http1.c:379)
  5.86      1.31     0.19   938251     0.00     0.00  phr_parse_request (picohttpparser.c:344)
...(略)
  0.00      3.24     0.00        1     0.00     0.00  yoml__resolve_alias (yoml-parser.h:157)

なお、煽り記事のため実験条件などは詳しく書きません。

1
0
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
1
0