This card is powered by https://github.com/anuraghazra/github-readme-stats
isucon-practice-20200718's Introduction
isucon-practice-20200718's People
isucon-practice-20200718's Issues
SlowQueryと戦う
mysql> show variables like 'long%'
-> ;
+-----------------+----------+
| Variable_name | Value |
+-----------------+----------+
| long_query_time | 0.100000 |
+-----------------+----------+
1 row in set (0.00 sec)
mysql> show variables like 'slow%';
+---------------------+----------------+
| Variable_name | Value |
+---------------------+----------------+
| slow_launch_time | 2 |
| slow_query_log | ON |
| slow_query_log_file | mysql-slow.log |
+---------------------+----------------+
3 rows in set (0.00 sec)
mysql>
設定してあった
現在の設定だと 0.1秒らしい
Session情報のStoreを高速化する
isucon-practice-20200718/app/src/app.go
Lines 174 to 177 in fac5277
/tmp/isucon
とかにFileでStoreしてる
session情報のやり取りが多くてネックになってるなら Redisとかに置き換える?
N+1っぽい場所を見るぞ
isucon-practice-20200718/app/src/app.go
Lines 256 to 261 in fac5277
isucon-practice-20200718/app/src/app.go
Lines 316 to 321 in fac5277
prepared statement用意して、そこに1行読んでうんぬんみたいにしてる。
Joinで行けるのであればそれで良さそうな気がする。
Markdownの生成を考える
isucon-practice-20200718/app/src/app.go
Lines 91 to 106 in fac5277
perlのプログラムで現在生成している。
プロファイラ見て sys.call execとかがネックになってそうならこれを試してみよう
ベンチが通ったら概ね同じMarkdownが生成されてるだろうと思って良さそう。
templateを高速化してみる
template.FuncMap
はテンプレート内で独自の関数を呼び出す際に必要で、移植元の参考実装が使用している場合、実装を合わせるために利用される`
FuncMapでやってるのは
url_for
src/templates/base_bottom.html:<script type="text/javascript" src="{{ url_for "/js/jquery.min.js" }}"></script>
src/templates/base_bottom.html:<script type="text/javascript" src="{{ url_for "/js/bootstrap.min.js" }}"></script>
src/templates/base_top.html:<link rel="stylesheet" href="{{ url_for "/css/bootstrap.min.css" }}">
src/templates/base_top.html:<link rel="stylesheet" href="{{ url_for "/css/bootstrap-responsive.min.css" }}">
src/templates/base_top.html:<link rel="stylesheet" href="{{ url_for "/" }}">
src/templates/base_top.html:<li><a href="{{ url_for "/" }}">Home</a></li>
src/templates/base_top.html:<li><a href="{{ url_for "/mypage" }}">MyPage</a></li>
src/templates/base_top.html:<li><a href="{{ url_for "/signin" }}">SignIn</a></li>
src/templates/index.html: <a href="{{ url_for "/memo/" }}{{ .Id }}">{{ first_line .Content }}</a> by {{ .Username }} ({{ .CreatedAt }})
src/templates/memo.html:<a id="older" href="{{ url_for "/memo/" }}{{ .Older.Id }}">< older memo</a>
src/templates/memo.html:<a id="newer" href="{{ url_for "/memo/" }}{{ .Newer.Id }}">newer memo ></a>
src/templates/mypage.html:<form action="{{ url_for "/memo" }}" method="post">
src/templates/mypage.html: <a href="{{ url_for "/memo/" }}{{ .Id }}">{{ first_line .Content }}</a> by {{ .Username }} ({{ .CreatedAt }})
src/templates/signin.html:<form action="{{ url_for "/signin" }}" method="post">
firsrt_line
src/templates/index.html: <a href="{{ url_for "/memo/" }}{{ .Id }}">{{ first_line .Content }}</a> by {{ .Username }} ({{ .CreatedAt }})
src/templates/mypage.html: <a href="{{ url_for "/memo/" }}{{ .Id }}">{{ first_line .Content }}</a> by {{ .Username }} ({{ .CreatedAt }})
get_token
src/templates/base_top.html: <input type="hidden" name="sid" value="{{ get_token .Session }}">
src/templates/mypage.html: <input type="hidden" name="sid" value="{{ get_token .Session }}">
gen_markdown
src/templates/memo.html:{{ gen_markdown .Memo.Content }}
pprof いれる
はやくする
GoのSliceのallocationをあらかじめデカ目のサイズで取ってしまう
isucon-practice-20200718/app/src/app.go
Line 249 in fac5277
isucon-practice-20200718/app/src/app.go
Line 309 in fac5277
前にMaxの件数をcountしたり、LIMITで取得サイズを制限しているので、あらかじめそのサイズで確保しておけばallocationコストは抑えられるはず。
静的ファイルをnginxから配信する
isucon-practice-20200718/app/src/app.go
Line 145 in fac5277
ベンチでREADとかがネックになったら考える
Sortが複数のカラムで行われている
isucon-practice-20200718/app/src/app.go
Line 244 in fac5277
isucon-practice-20200718/app/src/app.go
Line 304 in fac5277
auto incrementのキーと他のキーで行われている。
順序的には同じなので、別に…?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.