Slide 1

Slide 1 text

ࡾ୐༔հ / Pepabo R&D Institute, GMO Pepabo, Inc. 2018.06.12 Fukuoka.go#11 ۙࣅۙ๣୳ࡧΤϯδϯ SannyΛࢧ͑Δٕज़

Slide 2

Slide 2 text

ϓϦϯγύϧΤϯδχΞ ࡾ୐༔հ!NPOPDISPNFHBOF (.0ϖύϘגࣜձࣾϖύϘݚڀॴ IUUQCMPHNPOPDISPNFHBOFDPN

Slide 3

Slide 3 text

1. Motivation 2. Sanny 3. Sanny inside 3 ໨࣍

Slide 4

Slide 4 text

1. Motivation

Slide 5

Slide 5 text

• େن໛ͳECαΠτͷ৘ใաଟ໰୊ͷղܾͷͨΊɼ঎඼ͷࣗಈਪન͸ඞਢػೳ • ঎඼ಉ࢜ͷྨࣅੑΛݩʹਪન͕ߦΘΕΔͨΊɼػցతʹൺֱՄೳͳई౓ͱͯ͠ ଟ࣍ݩͷ࣮਺ϕΫτϧར༻͢Δɽಛ௃ྔɽ • ਂ૚ֶशͷൃలʹΑΓɼ͜Ε·Ͱద੾ͳಛ௃ྔΛಋ͘͜ͱ͕೉͔ͬͨ͠ը૾΍ ςΩετΛߴਫ਼౓ͳಛ௃ྔ΁ม׵͢Δ͜ͱ͕Ͱ͖ΔΑ͏ʹͳ͍ͬͯΔɽ 5 ਪનػೳͱಛ௃ྔ

Slide 6

Slide 6 text

• m࣍ݩͷϕΫτϧxΛn࣍ݩͷϕΫτϧy΁ࣸ૾͢Δؔ਺fΛਪఆ͢Δֶशख๏ 6 χϡʔϥϧωοτϫʔΫ: Ϟσϧ x1 x2 xm b W y1 y2 yn 1 2 o1 = σ( m ∑ i=0 w1i xi + b1 ) h 3 o = σ (Wx + b) w11 w12 . . w1m w21 w22 . . w2m . . wh1 wh2 . . whm x1 x2 . . xm + b1 b2 . . bh x f y h wh1 wh2 x1 x2 ೖྗ͝ͱʹॏΈXΛ৐ࢉόΠΞε ͨ͠΋ͷΛ׆ੑԽؔ਺ʹ௨͢ શϊʔυʹର͢Δॲཧ͸ߦྻͱͯ͠ૢ࡞Ͱ͖Δ

Slide 7

Slide 7 text

Similar images search system using ANN 7 Feature Similar items ANN [2048]float64 query response Deep CNN index Features [n][2048]float64 Deep CNN register find similar features

Slide 8

Slide 8 text

• େن໛ͳECαΠτͰѻ͏ಛ௃ྔ͸ɼେن໛͔ͭߴ࣍ݩϕΫτϧͷू߹ͱͳΔ • ਪનػೳͰ͸ɼ͜ͷू߹͔Βݕࡧ࣭໰σʔλʹྨࣅ͢Δ͍͔ͭ͘ͷϕΫτϧΛ ೚ҙͷڑ཭ؔ਺Λ࢖ͬͯ୳ࡧ͢Δɽۙ๣୳ࡧɽ • ۙ๣୳ࡧʹ͓͍ͯɼਖ਼֬Ͱ͸͋Δ͕ɼσʔλ਺ͱ࣍ݩ਺ʹൺྫͯ͠ܭࢉྔ͕૿ Ճ͢Δઢܗ୳ࡧ͸ݱ࣮తͰ͸ͳ͍ • ۭؒ෼ׂ΍ہॴੑӶහܕϋογϡͳͲͷํࣜʹΑͬͯܭࢉྔΛ࡟ݮ • ಛʹେن໛͔ͭߴ࣍ݩϕΫτϧू߹ʹରͯ͠͸ɼਫ਼౓Λ٘ਜ਼ʹͯ͠ܭࢉྔΛ཈ ͑Δۙࣅղ͕༻͍ΒΕΔɽۙࣅۙ๣୳ࡧɽ 8 ਪનػೳͱۙࣅۙ๣୳ࡧ

Slide 9

Slide 9 text

2. Sanny

Slide 10

Slide 10 text

• ਪનػೳʹ͸ɼఏҊ಺༰ͷత֬͞ͱॆ෼ͳԠ౴଎౓͕ٻΊΒΕΔɽ • ਫ਼౓ͱ଎౓Λཱ྆͢Δۙࣅۙ๣୳ࡧͷ࢓૊Έ͕ඞཁɽ • ଟछଟ༷ͳۙࣅۙ๣୳ࡧͷΞϧΰϦζϜ΍ͦΕΒΛ࣮૷ͨ͠ϥΠϒϥϦ͕ެ։ɼ ར༻͞Ε͍ͯΔɽ • ΞϧΰϦζϜ͝ͱʹ௕ॴ୹ॴ͕͋ΓɼݸʑͷΞϧΰϦζϜվળ͸ޮՌ͕ݶఆత 10 ۙࣅۙ๣୳ࡧͷվળͱ՝୊ • ҰํͰɼଟ͘ͷΞϧΰϦζϜ͸ɼॲཧର৅σʔλ਺ͱ࣍ݩ਺ʹੑೳ͕ґଘ͢Δ • ୳ࡧ͋ͨΓͷॲཧର৅ͷॖখ͕ɼશͯͷΞϧΰϦζϜʹޮՌత

Slide 11

Slide 11 text

• ঎඼ಛੑΛΑ͘දݱ͓ͯ͠Γߴਫ਼౓ʹྨࣅ౓͕ൺֱՄೳͳߴ࣍ݩ͔ͭີͳϕΫ τϧͷू߹Λର৅ͱͨۙ͠ࣅۙ๣୳ࡧ • ֶशࡁΈCNNΛಛ௃நग़ثͱͯ͠ར༻ͯ͠ը૾͔ΒಘΒΕΔಛ௃ྔू߹ • ςΩετΛ෼ࢄදݱ΁ม׵͢ΔWord2vec͔ΒಘΒΕΔಛ௃ྔू߹ • ͜ΕΒ͕ɼݕࡧ࣭໰σʔλ(ΫΤϦ)ʹର͢Δߴ࣍ݩϕΫτϧू߹ͷۙ๣୳ࡧ݁ Ռͷ্Ґू߹͕ɼΫΤϦͱߴ࣍ݩϕΫτϧू߹Λ೚ҙͷ࣍ݩ਺Ͱ౳෼ͨ͠෦෼ ϕΫτϧ୯ҐͰۙ๣୳ࡧͨ݁͠Ռͷ্Ґू߹ͱྨࣅ͠΍͍͢͜ͱʹண໨ 11 ఏҊख๏ ෦෼͕ྨࣅ͢Ε͹શମ͕ྨࣅ͢ΔՄೳੑ͕ߴ͍σʔλಛੑ

Slide 12

Slide 12 text

• ΫΤϦͱߴ࣍ݩϕΫτϧू߹Λ೚ҙͷ࣍ݩ਺Ͱ౳෼ͨ͠෦෼ϕΫτϧ୯ҐͰฒ ߦʹۙ๣୳ࡧͨ݁͠Ռͷ࿨ू߹Ͱ͋Δۙ๣ީิ͔Βɼ࠶౓ۙ๣୳ࡧΛߦ͏ɽ 12 ఏҊख๏ R@ R@ R@ 9@ 9@ 9@ /SFDPSET // R@ Y@O Y㱨9@ // R@ Y@O Y㱨9@ // R@ Y@O Y㱨9@ \ ^ \ ^ \ ^ BSHNJOE R Y Y㱨\ ^ 㱮 㱮 ෼ղલ ෼ղޙ ᶃ௿࣍ݩۭؒͷฒߦͨۙ͠๣୳ࡧ ᶄݻఆ਺ͷۙ๣ީิͷू໿ ᶅۙ๣ީิͷઢܗ୳ࡧ ᶃ ᶄ ᶅ ଎౓վળ ᶃ ᶄ ᶅ 2VFSZ

Slide 13

Slide 13 text

13 Sanny: ఏҊख๏ͷ࣮૷ 4BOOZ 4BOOZ 4BOOZ // // 㱮 // // ᶃ ᶄ ᶅ 2VFSZ "MHPSJTN "MHPSJTN "MHPSJTN • ΫΤϦฒͼʹ୳ࡧର৅σʔλͷ೚ҙ࣍ݩ΁ͷ౳෼ͱ݁Ռͷू໿Λ୲౰͢Δ • ෦෼ϕΫτϧͷۙ๣୳ࡧΞϧΰϦζϜ͸໰Θͳ͍ • ෦෼ϕΫτϧ͝ͱͷ୳ࡧॲཧ͸ಠཱͷͨΊ෼ࢄߏ੒͕Մೳ

Slide 14

Slide 14 text

ύϑΥʔϚϯε 14 • ॎ࣠͸୳ࡧඵ਺ͷٯ਺දࣔɼ্ʹ ߦ͘΄Ͳߴ଎ɽԣ࣠͸ద߹཰ɽ • ݩͷΞϧΰϦζϜʹରͯ͠ఏҊख๏ Λద༻ͨ͜͠ͱͰਫ਼౓ɼ଎౓ͷվ ળ͕ݟΒΕͨ ʰSanny: େن໛ECαΠτͷͨΊͷਫ਼౓ͱ଎౓Λཱ྆ͨ͠෼ࢄՄೳͳۙࣅۙ๣୳ࡧΤϯδϯʱ https://blog.monochromegane.com/blog/2018/05/16/wsa_2_sanny/

Slide 15

Slide 15 text

3. Sanny inside

Slide 16

Slide 16 text

Euclidean distance

Slide 17

Slide 17 text

• SannyͰ͸ۙ๣ީิͷू߹͔ΒϢʔΫϦουڑ཭ʹΑΔۙ๣୳ࡧΛߦ͏ • ࣍ݩ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C7X4A+7FhaAouBAX/oEbN/6Ai36CdFnBjQtv04Bosd6QzJkz95zcO1fSFWZahDRcXF//wOCQe9gzMjo27vVNTKZNrWLINCVrimZkJdGkClNpymKWQrO6QcWypNCMVNpon2eq1DCZpu5aNZ3mymJRZQUmixZSQkjPs6XjPFs4iOR9ARImdvi7Ae+AADgR03xPsA+HoIEMFSgDBRUsxAqIYOIjAA8EdORyUEfOQMTscwqn4EFtBbMoZojIlvBbxJ3gsCru256mrZbxLwq+Bir9ECSv5J60yAt5IG/k80+vuu3RrqWGq9TRUj3vPZtOfvyrKuNqwdG3qodCwuxOZQ3yiHU19xaFTM8eLSjAqt0bw151m2l3LXd8qicXreRaIlifJ7ekif3eoPMzOqvVd/kuThOXOC7+93C6QToS5kmYjy8HouvO4NwwA3MQwumsQBS2IAYp+37P4QquuVluk9vmdjqpnMvRTMGP4NJfLgiZEg==

Slide 18

Slide 18 text

• CPU໋ྩͷ͏ͪɼҰͭͷ໋ྩͰෳ਺σʔλΛॲཧͰ͖Δ΋ͷ • x86ΞʔΩςΫνϟϓϩηοαͩͱSSE໋ྩ܈΍AVX໋ྩ܈ͳͲ • AVXͩͱ256bit௕ͷϨδελΛར༻Ͱ͖ΔͨΊɼ32bitͷσʔλΛ8ݸฒྻʹ ॲཧͰ͖Δ 18 SIMD (Single Instruction Multiple Data)

Slide 19

Slide 19 text

19 Hello, SIMD CJU CJU CJU CJU 4*.%6OJU CJU CJU CJU CJU CJU x = float32 * 16 y = float32 * 16 z = float32 * 16 const size_t n = 16; float *x, *y, *z; // Align with 256bit x = (float *)_mm_malloc(sizeof(float) * n, 32); y = (float *)_mm_malloc(sizeof(float) * n, 32); z = (float *)_mm_malloc(sizeof(float) * n, 32); __m256 *vz = (__m256 *)z; __m256 *vx = (__m256 *)x; __m256 *vy = (__m256 *)y; const size_t end = n / 8; for(size_t i=0; i

Slide 20

Slide 20 text

Euclidean distance using SIMD and cgo 20 /* #cgo CFLAGS: -mavx -std=c99 #include #include #include #include float avx_euclidean_distance(const size_t n, float *x, float *y) { __m256 *vx = (__m256 *)x; __m256 *vy = (__m256 *)y; __m256 vsub = {0}; __m256 vsum = {0}; const size_t end = n / 8; for(size_t i=0; i

Slide 21

Slide 21 text

Euclidean distance using SIMD and cgo 21 func MmMalloc(size int) []float32 { size_ := size size = align(size) ptr := C._mm_malloc((C.size_t)(C.sizeof_float*size), 32) hdr := reflect.SliceHeader{ Data: uintptr(unsafe.Pointer(ptr)), Len: size, Cap: size, } goSlice := *(*[]float32)(unsafe.Pointer(&hdr)) if size_ != size { for i := size_; i < size; i++ { goSlice[i] = 0.0 } } return goSlice } func MmFree(v []float32) { C._mm_free(unsafe.Pointer(&v[0])) } func align(size int) int { return int(math.Ceil(float64(size)/8.0) * 8.0) }

Slide 22

Slide 22 text

Euclidean distance using SIMD and cgo 22 func EuclideanDistance(size int, x, y []float32) float32 { size = align(size) dot := C.avx_euclidean_distance((C.size_t)(size), (*C.float)(&x[0]), (*C.float)(&y[0])) return float32(dot) } BenchmarkEuclideanDistance-8 30000 59465 ns/op 0 B/op 0 allocs/op BenchmarkEuclideanDistanceGoroutine-8 2000 1034087 ns/op 479 B/op 5 allocs/op BenchmarkHypot-8 50000 34059 ns/op 0 B/op 0 allocs/op BenchmarkEuclideanDistanceAVX-8 5000000 359 ns/op 0 B/op 0 allocs/op Benchmark (2048dim)

Slide 23

Slide 23 text

TCP Connection

Slide 24

Slide 24 text

• SannyͰ͸֤෦෼ϕΫτϧू߹͔Βͷۙࣅۙ๣୳ࡧ݁ՌΛۙ๣ީิͱͯ͠ू໿ ͢Δɽ • ෼ࢄߏ੒ͷ৔߹͸ωοτϫʔΫӽ͠ʹΫΤϦͱ୳ࡧ݁Ռͷ΍ΓͱΓ͕ൃੜ͢Δɽ ·ͨɼΫΤϦ͸සൟʹൃߦ͞Εɼ୳ࡧʹ͸زڐ͔ͷॲཧ࣌ؒΛཁ͢Δɽ • TCPίωΫγϣϯଟॏԽͷ՝୊ղܾҊͱͯ͠୯Ұ઀ଓʹ͓͚ΔԾ૝తͳૹड৴ ͷଟॏԽ -> HTTP/2όΠφϦϑϨʔϛϯάϨΠϠ • ϓϩτίϧΦʔόʔϔουͷআڈͱϓϩτίϧґଘ͔Βͷ୤٫Λ໨ࢦͨ͠ɼΑ ΓݶఆతͰߴ଎ͳιέοτ௨৴ͷݕ౼ 24 αʔόؒ૬ޓ௨৴ʹ͓͚ΔϘτϧωοΫͱͦͷղܾࡦ

Slide 25

Slide 25 text

• ୯ҰίωΫγϣϯͷԾ૝ଟॏԽΛఏڙ • ΞϓϦέʔγϣϯ͸ಠࣗͷ؆ܿͳϓϩτίϧʹΑͬͯετϦʔϜܦ༝Ͱσʔλ Λૹड৴͢Δ 25 Smux (Socket Multiplexer) ʰGoݴޠͰTCP΍ιέοτ௨৴ΛଟॏԽɼߴ଎Խ͢Δsmux(ιέοτϚϧνϓϨΫα)Λͭͬͨ͘ʱ https://blog.monochromegane.com/blog/2018/05/03/smux/ 3FRVFTU Payload Header Frame 3FRVFTU Stream 1 Stream 2 Payload Header 3FTQPOTF Payload Header 3FTQPOTF Payload Header Payload Header Stream 1 Payload Header Stream 2 Payload Header Stream 1 Payload Header Stream 1 Payload Header Stream 2 TCP Connection Req Res

Slide 26

Slide 26 text

Smux (Socket Multiplexer) 26 // smux server server := smux.Server{ Network: "tcp", // or "unix" Address: "localhost:3000", // or "sockfile" Handler: smux.HandlerFunc(func(w io.Writer, r io.Reader) { io.Copy(ioutil.Discard, r) fmt.Fprint(w, "Hello, smux client!") }), } server.ListenAndServe() // smux client client := smux.Client{ Network: "tcp", // or "unix" Address: "localhost:3000", // or "sockfile" } body, _ := client.Post([]byte("Hello, smux server!")) fmt.Printf("%s\n", body) // "Hello, smux client!" Server Client

Slide 27

Slide 27 text

ύϑΥʔϚϯε 27 • smux, HTTP/1.1, HTTP/2ͷϕϯνϚʔΫ • ίωΫγϣϯ਺ or ετϦʔϜ਺Λ૿Ճ͞ ͤͳ͕ΒҰఆ਺ͷϦΫΤετΛࡹ࣌ؒ͘ Λܭଌ • αʔόαΠυॲཧ୅ସʹ਺ेmsͷsleep • ख๏ʹΑͬͯଟॏ౓૿Ճʹ൐͍ੑೳ͕಄ ଧͪʹͳΔͳ͔smux͕ߴ͍ੑೳΛࣔͨ͠

Slide 28

Slide 28 text

ઌߦ࣮૷ΛؚΊͨύϑΥʔϚϯε 28 • ઌߦ࣮૷ͱͯ͠hashicorp/yamax, xtaci/ smux(ssmux)ΛՃ͑ͨධՁ • yamaxʹରͯ͠͸ಉ౳Ҏ্͕ͩssmux͕ ༏लͰ͋ͬͨ • ະ࣮૷ͷϑϩʔ੍ޚͳͲΛ࣮૷ࢀߟʹύ ϑΥʔϚϯεݟ௚͠Λݕ౼

Slide 29

Slide 29 text

4. ·ͱΊ

Slide 30

Slide 30 text

• ۙࣅۙ๣୳ࡧΛߴ଎Խ͢ΔͨΊɼσʔλಛੑʹண໨ͨۙ͠ࣅۙ๣୳ࡧΤϯδϯ SannyΛ࣮૷ͨ͠ • ࣮૷؍఺Ͱͷߴ଎ԽͷͨΊɼϢʔΫϦουڑ཭ܭࢉͰSIMDԋࢉΛɼTCP઀ଓ ͷԾ૝ଟॏԽΛ࠾༻ͨ͠ • ύϑΥʔϚϯεվળ͸༷ʑͳϨΠϠͰՄೳͳͷͰ෯޿͘ݕ౼Ͱ͖Δ • Goݴޠ͔Βѻ͑Δͷ͕࠷ߴͰ͢Ͷ 30 ·ͱΊ

Slide 31

Slide 31 text

No content