Slide 1

Slide 1 text

ੜెͷظ຤ࢼݧͭͬͯͯ͘Ϡό͍

Slide 2

Slide 2 text

쎙 쎅 썰 썫 썦 썡썴썦썽 썙 쎡 썟 쎁 썛 쎒 쎀 ஗ 썛 ͋ͷ೔ͷύονΛͳͨ͘͠੨೥ͷ૕ࣦͱ࠶ੜͷ෺ޠ

Slide 3

Slide 3 text

4MBDLͷνʔϜ਺͕രൃ͖ͯͨ͠ !SPTZMJMMZ ݱࡏ͘Β͍ ೖͬͯͳ͍ͱ͜Ζ΋͋Δ

Slide 4

Slide 4 text

଎ ౓ 4 Q F F E δοαΠμΠδ

Slide 5

Slide 5 text

(PךSFHFYQָ鹼ְ

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

$ go run regexp.go 2.07745267s $ ruby regexp.rb 1.709597 $ node regexp.js 0.129

Slide 10

Slide 10 text

(P͕଎͍ͬͯݴͬͨͷ୭ͩΑ

Slide 11

Slide 11 text

> In some areas Go kann keep up with Java but when it comes to string > operations ("regex-dna" benchmark), Go is even much slower than Ruby > or Python. Is the status quo going to improve anytime soon? And why is > Go so terribly slow when it comes to string/RegEx operations? You assume the benchmark is worth something. First of all, Ruby and Python are using C implementations of the regexp search, so Go is being beat by C, not by Ruby. Second, Go is using a different algorithm for regexp matching than the C implementations in those other languages. The algorithm Go uses guarantees to complete in time that is linear in the length of the input. The algorithm that Ruby/Python/etc are using can take time exponential in the length of the input, although on trivial cases it typically runs quite fast. In order to guarantee the linear time bound, Go's algorithm's best case speed a little slower than the optimistic Ruby/Python/etc algorithm. On the other hand, there are inputs for which Go will return quickly and Ruby/Python/etc need more time than is left before the heat death of the universe. It's a decent tradeoff. http://swtch.com/~rsc/regexp/regexp1.html Russ at Golang-nuts IUUQTHSPVQTHPPHMFDPNGPSVNNTHHPMBOHOVUTENBFGK2ZH/:R3UT.+

Slide 12

Slide 12 text

ೖྗจࣈྻͷ௕͞ʹԠͯ͡ઢܗʹॲཧ͕࣌ؒ৳ͼΔ ˠϢʔβʔͷೖྗͱ͔͕Ϡόͯ͘΋ॲཧ͕࣌ؒอূ͞ΕΔ ˠ࠷దͳέʔε ϓϩάϥϚͷೖྗ ͳͲʹରͯ͠͸ ɹ3VCZ΍1ZUIPOʹൺ΂ͯ஗͍

Slide 13

Slide 13 text

SFHFYQ͸ආ͚Α͏ ৽نʹQBDLBHFΛ࢖͏ͱ͖͸DMPOFͯ͠HJUHSFQSFHFYQ҆ఆ

Slide 14

Slide 14 text

(PדTMJDFך⹛涸然⥂ָ鹼ְ

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

ByAppend-4 20000 81987 ns/op 385784 B/op 20 allocs/op ByIndex-4 100000 16803 ns/op 81920 B/op 1 allocs/op

Slide 18

Slide 18 text

ಈతʹTMJDFʹཁૉΛ௥Ճ͢Δͱ Ұఆͷ௕͞Λ௒͑Δͱ࠶֬อ͢Δ

Slide 19

Slide 19 text

ཁૉ਺͕Θ͔͍ͬͯΔ৔߹ͳΒ ͦͷαΠζͷΩϟύγςΟΛ ࣄલʹ֬อ͓ͯ͘͠΂͖

Slide 20

Slide 20 text

(Pד8SJUFS׾ֲתֻ⢪ֲ

Slide 21

Slide 21 text

)551ϨεϙϯεͰ+40/ΛૹΔࡍʹॻ͖͕ͪͳίʔυ

Slide 22

Slide 22 text

func Endpoint( rw http.ResponseWriter, req *http.Request, ) { bytes, err := json.Marshal(model) rw.Write(bytes) } Ұ౓CZUFTMJDFΛੜ੒ͯ͠͠·͍ͬͯΔ

Slide 23

Slide 23 text

func Endpoint( rw http.ResponseWriter, req *http.Request, ) { encoder := json.NewEncoder(rw) encoder.Encode(model) } CZUFTMJDF͕࡞ΒΕͳ͍

Slide 24

Slide 24 text

Bytes-4 200 7007896 ns/op 3915804 B/op 19 allocs/op Writer-4 200 6565790 ns/op 1074462 B/op 5 allocs/op

Slide 25

Slide 25 text

8SJUFSΛแΉ8SJUFSͳͲ΋࡞ΕΔ #BTFH[JQ ͷͰɺ׆༻͢ΔͱΑΓศརͰΘ͔Γ΍͘͢࢖͍͜ͳͤΔ

Slide 26

Slide 26 text

BMMPDճ਺͕ݮΕ͹୯७ʹߴ଎Խʹ΋د༩͢ΔͷͰ ੵۃతʹ׆༻͠·͠ΐ͏ ͲͪΒ͔ͱ͍͑͹ϝϞϦෛՙܰݮ

Slide 27

Slide 27 text

ࡉ͔͍ ੵΈॏͶ ࡉ͔͍ ੵΈॏͶ ࡉ͔͍ ੵΈॏͶ ࡉ͔͍ ੵΈॏͶ

Slide 28

Slide 28 text

଎͘ͳΔ ˣ μΠϨΫτͳتͼ

Slide 29

Slide 29 text

΍͍͖ͬͯ·͠ΐ͏

Slide 30

Slide 30 text

Slide 31

Slide 31 text

෇࿥

Slide 32

Slide 32 text

͜ ͷ Ұ ೥ Ͱ ͷ ۜߦͷಈ͖

Slide 33

Slide 33 text

๺෦৴૊ۜߦഇۀ

Slide 34

Slide 34 text

େ֞৴ۚͱ੢ೱ৴͕ۚ ߹ซ͠େ֞੢ೱ৴ۚʹ

Slide 35

Slide 35 text

෢෦৴ۚɺ๛ӫ೶ڠഇۀ ࠇ෦೶ڠͱࠇ෦ࢢ৴༻೶ڠ ͕߹ซ͠ɺࠇ෦ࢢ೶ڠʹ

Slide 36

Slide 36 text

ͳΜ͔௕͘ͳ͖ͬͯͨΜͰলུ͢Δͱ

Slide 37

Slide 37 text

৴ۚͷഇۀͱ૑ۀ ͙͢Θ͔Δ೥ͷۜߦτϨϯυ ೶ڠͷ߹ซϥογϡ ΞδΞݍࠃ֎ۜߦͷਐग़

Slide 38

Slide 38 text

৴ۚͷഇۀͱ૑ۀ ݹ͔͘Β͋Δ৴ۚͷղࢄͱ ৽ڵͷ৴૊ ࿑૊ ۜߦ͕ ೖΕସΘΔΑ͏ʹಈ͍͍ͯΔ ྫࢁܗݝҩࢣ৴૊ɺࡾॏݝ৬һ৴૊

Slide 39

Slide 39 text

೶ڠͷ߹ซϥογϡ ͍Θ͖ࢢ೶ۀڠಉ૊߹ɺ ܊ࢁࢢ೶ۀڠಉ૊߹ɺͨΉΒ೶ۀڠಉ૊߹ɺ ͍Θ͖த෦೶ۀڠಉ૊߹ɺ;ͨ͹೶ۀڠಉ૊߹ ෱ౡ͘͞Β೶ۀڠಉ૊߹ ˣ ஍۠୯Ґͩͬͨ೶ڠ͕ɺݝ୯ҐʹҠߦͭͭ͋͠Δ

Slide 40

Slide 40 text

೥ʹਐग़͖ͯͨ͠ࠃ֎ۜߦ ϑΟϦϐϯɾφγϣφϧɾόϯΫ ୆৽ᅳࡍ঎ۀ φγϣφϧΦʔετϥϦΞ ΞδΞݍࠃ֎ۜߦͷਐग़

Slide 41

Slide 41 text

ۜߦ৘ใΛ௥͏ͱ ࢿۚݯྲྀಈͬΆ͍΋ͷ͕ݟ͑ͯ ͘͢͝ݏͳؾ࣋ͪʹͳָ͍ͬͯ͠

Slide 42

Slide 42 text

࠷ۜ ߴߦ

Slide 43

Slide 43 text