Open3
WebGL-Native: ビルドの整理
 okuoku
okuokuprev: https://zenn.dev/okuoku/scraps/e085f787df3550
next: https://zenn.dev/okuoku/scraps/594b49004593a7
開発環境の改善
今は 記事の"実装"節 で書いたような変換を手で起動している。さすがにちょっとバカみてぇなので自動化を考えたい。
 okuoku
okuoku
 Cygwinに比べて wasm2c が遅すぎる
なぜかVisualStudioでビルドした wasm2c が異常に遅い。Cygwinだと3分少々の変換が、
$ time wasm2c -o temp.c gltest2.wasm
real    3m22.611s
user    3m21.156s
sys     0m0.515s
VisualStudioだと13分掛かる。。
$ time ~/repos/wabt/out/build/x64-Release/wasm2c -o temp.c gltest2.wasm
real    13m16.433s
user    0m0.000s
sys     0m0.000s
たぶん I/O ロジックがよくないな。。遅いのはCランタイムなので、Clang-clでビルドしても改善しない。
$ time ~/repos/wabt/out/build/x64-Clang-Release/wasm2c -o temp.c gltest2.wasm
real    11m54.026s
user    0m0.000s
sys     0m0.015s
 okuoku
okuokusetvbufしても改善しない
diff --git a/src/stream.cc b/src/stream.cc
index e52c51b9..5e09ddf5 100644
--- a/src/stream.cc
+++ b/src/stream.cc
@@ -221,7 +221,8 @@ FileStream::FileStream(string_view filename, Stream* log_stream)
     : Stream(log_stream), file_(nullptr), offset_(0), should_close_(false) {
   std::string filename_str = filename.to_string();
   file_ = fopen(filename_str.c_str(), "wb");
-
+  setvbuf(file_, NULL, _IOFBF, 1024 * 1024 * 16);
+
   // TODO(binji): this is pretty cheesy, should come up with a better API.
   if (file_) {
     should_close_ = true;
$ time ~/repos/wabt/out/build/x64-Release/wasm2c -o temp.c gltest2.wasm
real    14m1.907s
user    0m0.015s
sys     0m0.015s
ダメみたいですね。。 というわけで素直にMinGWでビルドするしか無いかな。。 ← MinGWでビルドしてもCRTはMSVCRTだから何も変わらないじゃん。。というわけでCygwin版をどうにかして使うしかない。
$ time ~/wabt-mingw/wasm2c.exe -o temp.c gltest2.wasm
real    11m7.897s
user    0m0.015s
sys     0m0.000s
↑ (MinGWでビルドした結果)