saza-ku / isucon13

0 stars 0 forks source link

11250720 #76

Open saza-ku opened 1 year ago

saza-ku commented 1 year ago

isucon1

alp

+-------+--------+------------------------------------------+-------+-------+-------+-------+-------+
| COUNT | METHOD |                   URI                    |  MIN  |  MAX  |  SUM  |  AVG  |  P99  |
+-------+--------+------------------------------------------+-------+-------+-------+-------+-------+
| 22    | POST   | /api/livestream/.+                       | 0.012 | 0.020 | 0.320 | 0.015 | 0.020 |
| 12    | GET    | /api/livestream/.+                       | 0.004 | 0.016 | 0.132 | 0.011 | 0.016 |
| 32    | GET    | /api/livestream/.+/statistics            | 0.000 | 0.024 | 0.064 | 0.002 | 0.024 |
| 2     | GET    | /api/user/.+/statistics                  | 0.024 | 0.028 | 0.052 | 0.026 | 0.028 |
| 1     | POST   | /api/register                            | 0.036 | 0.036 | 0.036 | 0.036 | 0.036 |
| 3     | POST   | /api/livestream/.+/reaction              | 0.004 | 0.004 | 0.012 | 0.004 | 0.004 |
| 5     | GET    | /api/tag                                 | 0.000 | 0.004 | 0.012 | 0.002 | 0.004 |
| 2     | POST   | /api/livestream/.+/livecomment           | 0.004 | 0.004 | 0.008 | 0.004 | 0.004 |
| 2     | POST   | /api/livestream/.+/livecomment/.+/report | 0.004 | 0.004 | 0.008 | 0.004 | 0.004 |
| 2     | POST   | /api/livestream/.+/enter                 | 0.004 | 0.004 | 0.004 | 0.002 | 0.004 |
| 3     | POST   | /api/login                               | 0.000 | 0.004 | 0.004 | 0.001 | 0.004 |
| 1     | GET    | /api/user/.+/icon                        | 0.004 | 0.004 | 0.004 | 0.004 | 0.004 |
| 1     | GET    | /api/payment                             | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 1     | DELETE | /api/livestream/.+/exit                  | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 2     | GET    | /api/user/.+                             | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
+-------+--------+------------------------------------------+-------+-------+-------+-------+-------+

slow query

explain

Reading from STDIN ...

# No events processed.

netdata

http://localhost:19991/#menu_services;after=1700896826049;before=1700896902119

pprof

go tool pprof -http=0.0.0.0:1080 http://isucon1/pprof/11250720
saza-ku commented 1 year ago

isucon2

alp

+-------+--------+-----+-----+-----+-----+-----+-----+
| COUNT | METHOD | URI | MIN | MAX | SUM | AVG | P99 |
+-------+--------+-----+-----+-----+-----+-----+-----+
+-------+--------+-----+-----+-----+-----+-----+-----+

slow query

Count: 52  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.8 (42), isudns[isudns]@isucon1
  SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=N and name='S' and domain_id=N

Count: 48  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.5 (25), isudns[isudns]@isucon1
  SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=N and type='S' and name='S'

Count: 54  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isudns[isudns]@isucon1
  select kind,content from domains, domainmetadata where domainmetadata.domain_id=domains.id and name='S'

Count: 149  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isudns[isudns]@isucon1
  #

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isudns[isudns]@isucon1
  delete from records where domain_id=N and name='S' and type='S'

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.5 (1), isudns[isudns]@isucon1
  SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=N and type='S' and name='S' and domain_id=N

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isudns[isudns]@isucon1
  insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth) values ('S',N,N,'S',N,N,'S',NULL,N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isudns[isudns]@isucon1
  commit

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isudns[isudns]@isucon1
  select id,name,master,last_check,notified_serial,type,options,catalog,account from domains where name='S'

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isudns[isudns]@isucon1
  SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED

explain

Reading from STDIN ...

# 170ms user time, 0 system time, 36.25M rss, 50.70M vsz
# Current date: Sat Nov 25 07:21:46 2023
# Hostname: ip-192-168-0-12
# Files: STDIN
# Overall: 319 total, 20 unique, 3.99 QPS, 0.00x concurrency _____________
# Time range: 2023-11-25T07:20:26 to 2023-11-25T07:21:46
# Attribute          total     min     max     avg     95%  stddev  median
# ============     ======= ======= ======= ======= ======= ======= =======
# Exec time           94ms     1us     4ms   293us   761us   438us    76us
# Lock time          181us       0     6us       0     1us       0       0
# Rows sent             73       0       1    0.23    0.99    0.42       0
# Rows examine     128.77k       0   1.25k  413.36   1.20k  575.51       0
# Query size        24.83k       5     195   79.72  136.99   47.52   84.10

# Profile
# Rank Query ID                        Response time Calls R/Call V/M   It
# ==== =============================== ============= ===== ====== ===== ==
#    1 0x42EF7D7D98FBCC9723BF896EBF...  0.0421 45.0%    52 0.0008  0.00 SELECT records
#    2 0x3D83BC87F3B3A00D571FFC8104...  0.0343 36.6%    48 0.0007  0.00 SELECT records
#    3 0x22279D81D51006139E0C76405B...  0.0049  5.2%    54 0.0001  0.00 SELECT domains domainmetadata
#    4 0xE77769C62EF669AA7DD5F6760F...  0.0048  5.1%     2 0.0024  0.00 SHOW VARIABLES
# MISC 0xMISC                           0.0075  8.0%   163 0.0000   0.0 <16 ITEMS>

# Query 1: 0 QPS, 0x concurrency, ID 0x42EF7D7D98FBCC9723BF896EBFC51D24 at byte 805
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: all events occurred at 2023-11-25T07:20:26
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count         16      52
# Exec time     44    42ms   701us     3ms   810us   761us   400us   725us
# Lock time     27    49us       0     2us       0     1us       0     1us
# Rows sent     57      42       0       1    0.81    0.99    0.39    0.99
# Rows examine  50  65.01k   1.25k   1.25k   1.25k   1.20k       0   1.20k
# Query size    27   6.85k     129     144  134.98  143.84    4.93  130.47
# String:
# Hosts        isucon1
# Users        isudns
# Query_time distribution
#   1us
#  10us
# 100us  ################################################################
#   1ms  ##
#  10ms
# 100ms
#    1s
#  10s+
# Tables
#    SHOW TABLE STATUS LIKE 'records'\G
#    SHOW CREATE TABLE `records`\G
# EXPLAIN /*!50100 PARTITIONS*/
SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and name='pawserv.u.isucon.dev' and domain_id=4\G
# EXPLAIN failed: DBD::mysql::st execute failed: Table 'isupipe.records' doesn't exist [for Statement "EXPLAIN SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and name='pawserv.u.isucon.dev' and domain_id=4"] at /usr/bin/pt-query-digest line 7796.

# Query 2: 0 QPS, 0x concurrency, ID 0x3D83BC87F3B3A00D571FFC8104A6E50C at byte 0
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: all events occurred at 2023-11-25T07:20:26
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count         15      48
# Exec time     36    34ms   658us     2ms   715us   725us   167us   657us
# Lock time     30    55us       0     3us     1us     1us       0     1us
# Rows sent     34      25       0       1    0.52    0.99    0.50    0.99
# Rows examine  46  60.01k   1.25k   1.25k   1.25k   1.20k    0.00   1.20k
# Query size    24   6.09k     126     143  129.98  136.99    4.46  124.25
# String:
# Hosts        isucon1
# Users        isudns
# Query_time distribution
#   1us
#  10us
# 100us  ################################################################
#   1ms  #
#  10ms
# 100ms
#    1s
#  10s+
# Tables
#    SHOW TABLE STATUS LIKE 'records'\G
#    SHOW CREATE TABLE `records`\G
# EXPLAIN 
SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='u.isucon.dev'\G
# EXPLAIN failed: DBD::mysql::st execute failed: Table 'isupipe.records' doesn't exist [for Statement "EXPLAIN SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='u.isucon.dev'"] at /usr/bin/pt-query-digest line 7796.

# Query 3: 0 QPS, 0x concurrency, ID 0x22279D81D51006139E0C76405B54C261 at byte 1619
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: all events occurred at 2023-11-25T07:20:26
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count         16      54
# Exec time      5     5ms    73us   220us    90us   108us    19us    84us
# Lock time     35    65us     1us     2us     1us     1us       0     1us
# Rows sent      0       0       0       0       0       0       0       0
# Rows examine   0       0       0       0       0       0       0       0
# Query size    24   6.01k     114     114     114     114       0     114
# String:
# Hosts        isucon1
# Users        isudns
# Query_time distribution
#   1us
#  10us  ################################################################
# 100us  ####################
#   1ms
#  10ms
# 100ms
#    1s
#  10s+
# Tables
#    SHOW TABLE STATUS LIKE 'domains'\G
#    SHOW CREATE TABLE `domains`\G
#    SHOW TABLE STATUS LIKE 'domainmetadata'\G
#    SHOW CREATE TABLE `domainmetadata`\G
# EXPLAIN 
select kind,content from domains, domainmetadata where domainmetadata.domain_id=domains.id and name='u.isucon.dev'\G
# EXPLAIN failed: DBD::mysql::st execute failed: Table 'isupipe.domains' doesn't exist [for Statement "EXPLAIN select kind,content from domains, domainmetadata where domainmetadata.domain_id=domains.id and name='u.isucon.dev'"] at /usr/bin/pt-query-digest line 7796.

# Query 4: 0 QPS, 0x concurrency, ID 0xE77769C62EF669AA7DD5F6760F2D2EBB at byte 89020
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: all events occurred at 2023-11-25T07:21:46
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count          0       2
# Exec time      5     5ms   951us     4ms     2ms     4ms     2ms     2ms
# Lock time      3     7us     1us     6us     3us     6us     3us     3us
# Rows sent      2       2       1       1       1       1       0       1
# Rows examine   0       2       1       1       1       1       0       1
# Query size     0      77      35      42   38.50      42    4.95   38.50
# String:
# Databases    isupipe
# Hosts        localhost
# Users        isucon
# Query_time distribution
#   1us
#  10us
# 100us  ################################################################
#   1ms  ################################################################
#  10ms
# 100ms
#    1s
#  10s+
SHOW VARIABLES LIKE 'wait\_timeout'\G

netdata

http://localhost:19992/#menu_services;after=1700896826081;before=1700896906089

pprof

go tool pprof -http=0.0.0.0:1080 http://isucon2/pprof/11250720
saza-ku commented 1 year ago

isucon3

alp

+-------+--------+-----+-----+-----+-----+-----+-----+
| COUNT | METHOD | URI | MIN | MAX | SUM | AVG | P99 |
+-------+--------+-----+-----+-----+-----+-----+-----+
+-------+--------+-----+-----+-----+-----+-----+-----+

slow query

Count: 22  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isucon[isucon]@isucon1
  UPDATE reservation_slots SET slot = slot - N WHERE start_at >= N AND end_at <= N

Count: 22  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=1.3 (28), isucon[isucon]@isucon1
  SELECT * FROM reservation_slots WHERE start_at >= N AND end_at <= N FOR UPDATE

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=109.0 (981), isucon[isucon]@isucon1
  SELECT * FROM livestream_tags WHERE tag_id IN (N)

Count: 2  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=7496.0 (14992), isucon[isucon]@isucon1
  SELECT * FROM livestreams

Count: 41  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (41), isucon[isucon]@isucon1
  SELECT * FROM themes WHERE user_id = N

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=632.5 (1265), isucon[isucon]@isucon1
  SELECT u.id AS id, COUNT(*) AS count FROM users u
  INNER JOIN livestreams l ON l.user_id = u.id
  INNER JOIN reactions r ON r.livestream_id = l.id
  GROUP BY u.id

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.0 (18), isucon[isucon]@isucon1
  SELECT * FROM livestreams WHERE user_id = N

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=642.0 (1284), isucon[isucon]@isucon1
  SELECT u.id AS id, IFNULL(SUM(l2.tip), N) AS count FROM users u
  INNER JOIN livestreams l ON l.user_id = u.id  
  INNER JOIN livecomments l2 ON l2.livestream_id = l.id
  GROUP BY u.id

explain

Reading from STDIN ...

# 200ms user time, 10ms system time, 36.88M rss, 51.07M vsz
# Current date: Sat Nov 25 07:21:46 2023
# Hostname: ip-192-168-0-13
# Files: STDIN
# Overall: 651 total, 55 unique, 8.14 QPS, 0.00x concurrency _____________
# Time range: 2023-11-25T07:20:26 to 2023-11-25T07:21:46
# Attribute          total     min     max     avg     95%  stddev  median
# ============     ======= ======= ======= ======= ======= ======= =======
# Exec time          374ms    13us     8ms   574us     5ms     1ms    66us
# Lock time          351us       0     5us       0     1us       0     1us
# Rows sent         29.67k       0   7.32k   46.68  107.34  426.18    0.99
# Rows examine     610.49k       0  10.76k  960.28   8.46k   2.45k    0.99
# Query size        68.95k       6     985  108.45  563.87  168.73   46.83

# Profile
# Rank Query ID                        Response time Calls R/Call V/M   It
# ==== =============================== ============= ===== ====== ===== ==
#    1 0xA3401CA3ABCC04C3AB221DB8AD...  0.1154 30.8%    22 0.0052  0.00 UPDATE reservation_slots
#    2 0x7F9C0C0BA9473953B723EE16C0...  0.1102 29.5%    22 0.0050  0.00 SELECT reservation_slots
#    3 0xD90E8C4E07438471B5F09BC1F9...  0.0200  5.3%     9 0.0022  0.00 SELECT livestream_tags
#    4 0x050F7D44808F43E5D33D0B90BC...  0.0157  4.2%     2 0.0078  0.00 SELECT livestreams
# MISC 0xMISC                           0.1129 30.2%   596 0.0002   0.0 <51 ITEMS>

# Query 1: 0 QPS, 0x concurrency, ID 0xA3401CA3ABCC04C3AB221DB8AD5CBF26 at byte 84764
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: all events occurred at 2023-11-25T07:20:26
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count          3      22
# Exec time     30   115ms     5ms     6ms     5ms     5ms   229us     5ms
# Lock time      4    16us       0     1us       0     1us       0     1us
# Rows sent      0       0       0       0       0       0       0       0
# Rows examine  30 188.18k   8.55k   8.55k   8.55k   8.55k       0   8.55k
# Query size     3   2.11k      98      98      98      98       0      98
# String:
# Hosts        isucon1
# Users        isucon
# Query_time distribution
#   1us
#  10us
# 100us
#   1ms  ################################################################
#  10ms
# 100ms
#    1s
#  10s+
# Tables
#    SHOW TABLE STATUS LIKE 'reservation_slots'\G
#    SHOW CREATE TABLE `reservation_slots`\G
UPDATE reservation_slots SET slot = slot - 1 WHERE start_at >= 1711936800 AND end_at <= 1711940400\G
# Converted for EXPLAIN
# EXPLAIN /*!50100 PARTITIONS*/
select  slot = slot - 1 from reservation_slots where  start_at >= 1711936800 AND end_at <= 1711940400\G

# Query 2: 0 QPS, 0x concurrency, ID 0x7F9C0C0BA9473953B723EE16C08655F1 at byte 1581
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: all events occurred at 2023-11-25T07:20:26
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count          3      22
# Exec time     29   110ms     5ms     5ms     5ms     5ms    69us     5ms
# Lock time      5    21us       0     1us       0     1us       0     1us
# Rows sent      0      28       1       7    1.27    0.99    1.25    0.99
# Rows examine  30 188.18k   8.55k   8.55k   8.55k   8.55k       0   8.55k
# Query size     2   2.06k      96      96      96      96       0      96
# String:
# Hosts        isucon1
# Users        isucon
# Query_time distribution
#   1us
#  10us
# 100us
#   1ms  ################################################################
#  10ms
# 100ms
#    1s
#  10s+
# Tables
#    SHOW TABLE STATUS LIKE 'reservation_slots'\G
#    SHOW CREATE TABLE `reservation_slots`\G
# EXPLAIN /*!50100 PARTITIONS*/
SELECT * FROM reservation_slots WHERE start_at >= 1700874000 AND end_at <= 1700899200 FOR UPDATE\G
# *************************** 1. row ***************************
#            id: 1
#   select_type: SIMPLE
#         table: reservation_slots
#    partitions: NULL
#          type: ALL
# possible_keys: NULL
#           key: NULL
#       key_len: NULL
#           ref: NULL
#          rows: 8593
#      filtered: 11.11
#         Extra: Using where

# Query 3: 0 QPS, 0x concurrency, ID 0xD90E8C4E07438471B5F09BC1F985ACD7 at byte 152788
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: all events occurred at 2023-11-25T07:20:26
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count          1       9
# Exec time      5    20ms     2ms     2ms     2ms     2ms    39us     2ms
# Lock time      1     4us       0     1us       0     1us       0       0
# Rows sent      3     981      97     135     109  130.47   11.60  102.22
# Rows examine  15  96.76k  10.72k  10.76k  10.75k  10.29k       0  10.29k
# Query size     0     450      49      51      50   49.17    0.97   49.17
# String:
# Hosts        isucon1
# Users        isucon
# Query_time distribution
#   1us
#  10us
# 100us
#   1ms  ################################################################
#  10ms
# 100ms
#    1s
#  10s+
# Tables
#    SHOW TABLE STATUS LIKE 'livestream_tags'\G
#    SHOW CREATE TABLE `livestream_tags`\G
# EXPLAIN 
SELECT * FROM livestream_tags WHERE tag_id IN (99)\G
# *************************** 1. row ***************************
#            id: 1
#   select_type: SIMPLE
#         table: livestream_tags
#    partitions: NULL
#          type: ALL
# possible_keys: NULL
#           key: NULL
#       key_len: NULL
#           ref: NULL
#          rows: 10692
#      filtered: 10.00
#         Extra: Using where

# Query 4: 0 QPS, 0x concurrency, ID 0x050F7D44808F43E5D33D0B90BCF57CC9 at byte 46979
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: all events occurred at 2023-11-25T07:20:26
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count          0       2
# Exec time      4    16ms     8ms     8ms     8ms     8ms   300us     8ms
# Lock time      0     2us     1us     1us     1us     1us       0     1us
# Rows sent     49  14.64k   7.32k   7.32k   7.32k   7.32k       0   7.32k
# Rows examine   2  14.64k   7.32k   7.32k   7.32k   7.32k       0   7.32k
# Query size     0      50      25      25      25      25       0      25
# String:
# Hosts        isucon1
# Users        isucon
# Query_time distribution
#   1us
#  10us
# 100us
#   1ms  ################################################################
#  10ms
# 100ms
#    1s
#  10s+
# Tables
#    SHOW TABLE STATUS LIKE 'livestreams'\G
#    SHOW CREATE TABLE `livestreams`\G
# EXPLAIN 
SELECT * FROM livestreams\G
# *************************** 1. row ***************************
#            id: 1
#   select_type: SIMPLE
#         table: livestreams
#    partitions: NULL
#          type: ALL
# possible_keys: NULL
#           key: NULL
#       key_len: NULL
#           ref: NULL
#          rows: 7395
#      filtered: 100.00
#         Extra: NULL

netdata

http://localhost:19993/#menu_services;after=1700896826076;before=1700896906083

pprof

go tool pprof -http=0.0.0.0:1080 http://isucon3/pprof/11250720