Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fix webapp bottolenecks4 #139

Merged
merged 6 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/bench-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
env:
TZ: Asia/Tokyo
run: |
go clean -testcache
go test -p=1 -v ./...

- name: "[bench] Benchmark"
Expand Down
1 change: 1 addition & 0 deletions bench/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/urfave/cli v1.22.1
go.uber.org/zap v1.26.0
golang.org/x/sync v0.4.0

)

require (
Expand Down
1 change: 0 additions & 1 deletion bench/isupipe/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func assertSearchLivestream() {
// FIXME: いくらか画面表示内容に問題がないことをチェックする

// moderateにより登録されたNGワードが含まれるコメントが残っていたら失格
// FIXME: ベンチ側では、ngワードのmoderate後に含まれる投稿を見つけたら失格扱いにする
func assertModeratedComment() {
// NGワード一覧取得

Expand Down
18 changes: 10 additions & 8 deletions bench/isupipe/client_livecomment.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ import (
)

type Livecomment struct {
ID int `json:"id"`
User User `json:"user"`
Livestream Livestream `json:"livestream"`
Comment string `json:"comment"`
Tip int `json:"tip"`
ReportCount int `json:"report_count"`
CreatedAt int `json:"created_at"`
UpdatedAt int `json:"updated_at"`
ID int `json:"id"`
User User `json:"user"`
Livestream Livestream `json:"livestream"`
Comment string `json:"comment"`
Tip int `json:"tip"`
CreatedAt int `json:"created_at"`
UpdatedAt int `json:"updated_at"`
}

type LivecommentReport struct {
Expand Down Expand Up @@ -123,6 +122,9 @@ func (c *Client) GetLivecommentReports(ctx context.Context, livestreamID int, op
return reports, nil
}

// FIXME: 実装
// func (c *Client) GetNgwords(ctx context.Context)

func (c *Client) PostLivecomment(ctx context.Context, livestreamID int, r *PostLivecommentRequest, opts ...ClientOption) (*PostLivecommentResponse, error) {
var (
defaultStatusCode = http.StatusCreated
Expand Down
1 change: 0 additions & 1 deletion bench/isupipe/client_livestream.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type Livestream struct {
Description string `json:"description"`
PlaylistUrl string `json:"playlist_url"`
ThumbnailUrl string `json:"thumbnail_url"`
ViewersCount int `json:"viewers_count"`
StartAt int `json:"start_at"`
EndAt int `json:"end_at"`
CreatedAt int `json:"created_at"`
Expand Down
23 changes: 10 additions & 13 deletions bench/isupipe/client_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,19 @@ import (
)

type LivestreamStatistics struct {
MostTipRanking []TipRank `json:"most_tip_ranking"`
MostPostedReactionRanking []ReactionRank `json:"most_posted_reaction_ranking"`
Rank int64 `json:"rank"`
ViewersCount int64 `json:"viewers_count"`
TotalReactions int64 `json:"total_reactions"`
TotalReports int64 `json:"total_reports"`
MaxTip int64 `json:"max_tip"`
}

type UserStatistics struct {
TipRankPerLivestreams map[int]TipRank `json:"tip_rank_by_livestream"`
}

type TipRank struct {
Rank int `json:"tip_rank"`
TotalTip int `json:"total_tip"`
}

type ReactionRank struct {
Rank int `json:"reaction_rank"`
EmojiName string `json:"emoji_name"`
Rank int64 `json:"rank"`
ViewersCount int64 `json:"viewers_count"`
TotalReactions int64 `json:"total_reactions"`
TotalLivecomments int64 `json:"total_livecomments"`
TotalTip int64 `json:"total_tip"`
}

func (c *Client) GetUserStatistics(ctx context.Context, username string, opts ...ClientOption) (*UserStatistics, error) {
Expand Down
3 changes: 0 additions & 3 deletions bench/isupipe/client_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ func TestClientUser_Login(t *testing.T) {
)
assert.NoError(t, err)

_, err = client.Initialize(ctx)
assert.NoError(t, err)

streamer := scheduler.UserScheduler.GetRandomStreamer()
assert.NoError(t, err)

Expand Down
27 changes: 27 additions & 0 deletions bench/isupipe/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package isupipe

import (
"context"
"log"
"testing"
"time"

"github.com/isucon/isucandar/agent"
"github.com/isucon/isucon13/bench/internal/config"
)

func TestMain(m *testing.M) {
client, err := NewClient(
agent.WithBaseURL(config.TargetBaseURL),
agent.WithTimeout(1*time.Minute),
)
if err != nil {
log.Fatalln(err)
}

if _, err := client.Initialize(context.Background()); err != nil {
log.Fatalln(err)
}

m.Run()
}
2 changes: 2 additions & 0 deletions development/docker-compose-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ services:
- ../webapp/initial_tags.sql:/home/isucon/webapp/go/initial_tags.sql
- ../webapp/initial_livestreams.sql:/home/isucon/webapp/go/initial_livestreams.sql
- ../webapp/initial_reservation_slots.sql:/home/isucon/webapp/go/initial_reservation_slots.sql
- ../webapp/initial_reactions.sql:/home/isucon/webapp/go/initial_reactions.sql
- ../webapp/initial_livecomments.sql:/home/isucon/webapp/go/initial_livecomments.sql
- ../webapp/powerdns/pdnsutil:/usr/local/bin/pdnsutil
environment:
ISUCON13_MYSQL_DIALCONFIG_ADDRESS: mysql
Expand Down
4 changes: 0 additions & 4 deletions docs/isupipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,6 @@ components:
type: string
thumbnail_url:
type: string
viewers_count:
type: integer
start_at:
type: integer
end_at:
Expand All @@ -552,8 +550,6 @@ components:
type: string
tip:
type: integer
report_count:
type: integer
created_at:
type: integer
updated_at:
Expand Down
7 changes: 0 additions & 7 deletions docs/reservation.md

This file was deleted.

25 changes: 25 additions & 0 deletions docs/specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,28 @@ ISUPipeでは、治安維持のため、配信者が個人個人でスパム対


* シーズン4

# 配信予約

## ベンチマーカーが予約する時間の粒度について

最小単位は1h。

のちほどこれでは不足するようならより細かい粒度も検討する

# チップの概念について

isupipeでは、行われている配信に対してライブコメントを投稿することができ、
ライブコメントにはチップ(tips)が含まれます。
これは、一般的に投げ銭システムと呼ばれるものです。

isupipeでは、このtipsについて、以下のようなレベル分けを行っております。

|金額帯|色|
|:--:|:--:|
|1 ~ 499| 青 |
|500 ~ 999 | 緑 |
|1000 ~ 4999| 黄色 |
|5000 ~ 9999 | オレンジ |
|10000 ~ 20000 | 赤 |

16 changes: 0 additions & 16 deletions docs/tips.md

This file was deleted.

28 changes: 28 additions & 0 deletions docs/transplant.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 移植マニュアル


## Webappについて




## self-hosted runnerについて




## 関連するミドルウェアについて




## CI実行方法について




## ベンチマーカーで発生するエラーについて

エラーには以下のような種類があります

うち、移植失敗の可能性を示唆するものは以下のとおりです
20 changes: 20 additions & 0 deletions scripts/generate_initial_livecomment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import random

N = 100000

SQL_FORMAT = "\t(1, 1, '{comment}'),\n"



with open('./initial-data/positive_sentence.txt', 'r') as f:
livecomments = list(line.rstrip() for line in f.readlines())

with open('/tmp/livecomments.sql', 'w') as f:
f.write("INSERT INTO livecomments (user_id, livestream_id, comment)\n")
f.write("VALUES\n")
for _ in range(N):
comment = random.choice(livecomments)
sql = SQL_FORMAT.format(comment=comment)
f.write(sql)
f.write("\t(1, 1, 'こんにちは');\n")

19 changes: 19 additions & 0 deletions scripts/generate_initial_reaction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import random

N = 100000


SQL_FORMAT = "\t('{emoji_name}', 1, 1),\n"

with open('./initial-data/emoji.txt', 'r') as f:
emoji_list = list(line.rstrip() for line in f.readlines())


with open('/tmp/reactions.sql', 'w') as f:
f.write('INSERT INTO reactions (emoji_name, user_id, livestream_id)\n')
f.write('VALUES\n')
for _ in range(N):
emoji_name = random.choice(emoji_list)
sql = SQL_FORMAT.format(emoji_name=emoji_name)
f.write(sql)
f.write("\t('+1', 1, 1);\n")
Loading