Upgrade to Pro — share decks privately, control downloads, hide ads and more …

最速のJSONライブラリを求めて

 最速のJSONライブラリを求めて

Masaaki Goshima

August 06, 2020
Tweet

More Decks by Masaaki Goshima

Other Decks in Technology

Transcript

  1. Personal Company ( 前職 ) goccy/go-yaml knocknote/octillery goccy/go-graphviz knocknote/rapidash goccy/go-json

    knocknote/eevee goccy/go-reflect knocknote/vitess-sqlparser goccy/go-jit HPDDZ !HPDDZ  .FSQBZ "SDIJUFDU d .BTBBLJ(PTIJNB HPDDZ
  2. HPDDZHPKTPO • IUUQTHJUIVCDPNHPDDZHPKTPO • FODPEJOHKTPOͱίϯύν͔ͭ࠷଎ Λ໨ࢦͯ͠։ൃ • 'FBUVSFT • JNQPSUจΛ

    FODPEJOHKTPO͔Βࠩ͠ସ͑Δ͚ͩͰ࢖͑Δ • &ODPEF͸؍ଌ͍ͯ͠ΔൣғͰ࠷଎ • %FDPEF͸ಉ͡ίϯηϓτͷ KTPOJUFSBUPSHPΑΓ͔ͳΓ଎͍
  3. .PUJWBUJPO • ݁ہ *'͸ FODPEJOHKTPO ඪ४ ͱಉ͡΋ͷ͕޷͖ • JOUFSGBDF\^Ͱड͚Δઃܭʹ͢Δͱɺઐ༻ܕͰ &ODPEF%FDPEF͢Δ

    ϥΠϒϥϦʹൺ΂ͯ଎౓͕མͪΔ • KTPOJUFSBUPSHPWTGSBODPJTQRUHPKBZ • FODPEJOHKTPOͱίϯύν Ͱ HPKBZΑΓ଎͚Ε͹Ұ൪ྑ͍ͷͰ͸ʁ
  4. 8IZ;FSP"MMPDBUJPO • ;FSP"MMPDBUJPO;FSP($ • ($ 458 ͷ࣌ؒ͸ແࢹͰ͖ͳ͍ • Ξϩέʔγϣϯճ਺ճͱճͰ͸ɺ($͕ൃੜ͢Δɾ͠ͳ͍ʹؔΘΔॏཁͳ෼͔Ε໨ •

    ;FSP"MMPDBUJPO͕ͳͥՄೳ͔ • (PίϯύΠϥ͕ݡ͘ΦϒδΣΫτͷੜଘظؒΛղੳͯ͠ɺ ώʔϓʹ֬อ͢Δඞཁ͕ͳ͍΋ͷ͸ελοΫ֬อʹͯ͘͠ΕΔ Τεέʔϓղੳ
  5. HPKTPOͷΞϩέʔγϣϯํ਑ &ODPEFS • KTPO.BSTIBM࣌ͷΞϩέʔγϣϯճ਺Λ ճ ʹ • Ξϩέʔγϣϯճ਺ͷཧ૝஋͸ .BSTIBM JOUFSGBDF\^

     <>CZUF FSSPS ͳΒճ • ग़ྗ஋ʹඞཁͳ΋ͷ͚ͩΛώʔϓʹ֬อ ՝୊ͱͦͷରࡦ • ड͚औͬͨ JOUFSGBDF\^ܕʹରͯ͠ී௨ʹϦϑϨΫγϣϯ͢Δͱ Ξϩέʔγϣϯ͕ൃੜ͢Δ • ;FSP"MMPDBUJPOͰ ϦϑϨΫγϣϯ ͢Δํ๏ͰରԠ
  6. HPDDZHPSFGMFDU • IUUQTHJUIVCDPNHPDDZHPSFGMFDU • SFGMFDUͱίϯύν • ϦϑϨΫγϣϯૢ࡞Λ ;FSP"MMPDBUJPOͰߦ͑Δ • 'FBUVSFT

    • SFGMFDU5ZQFʹؔ͢Δૢ࡞Λ͢΂ͯ ;FSP"MMPDBUJPOʹ • SFGMFDU7BMVFʹؔ͢Δૢ࡞͸Ξϩέʔγϣϯ͋Γɾͳ͠Λબ΂Δ
  7. QSJWBUFͳॲཧΛࢀর͢Δ͜ͱ΁ͷରࡦ • CVJMEσΟϨΫςΟϒͰ (P಺෦ͷมԽʹ௥ਵ • Ͱ͖Δ͚ͩଟ͘ͷ (PWFSTJPO04Ͱ NBUSJYUFTUΛߦ͏ • JOJU

    ಺Ͱ "1*͕ਖ਼͘͠ಈ͔͘όϦσʔγϣϯ • ৽͍͠ (PWFSTJPOͳͲɺ·ͩ HPSFGMFDUͰݕূ͍ͯ͠ͳ͍Ϗϧυʹର͢Δ Ξϓϩʔν • ࣦഊͨ͠Β QBOJD͢Δ SFGMFDUʹϑΥʔϧόοΫͯ͠΋͍͍͔΋͠Εͳ͍
  8. 6ONBSTIBM ͱ 4USFBN%FDPEFͰํ਑Λม͑Δ • KTPO6ONBSTIBM ͸σίʔυର৅ͷ <>CZUFΛશͯ࠷ॳʹड͚औΕΔ • ౉͞Εͨ <>CZUFͷ

    DPQZͿΜ ճ ͱग़ྗର৅ͷ (PͷΦϒδΣΫτߏஙʹ ඞཁͳͿΜ͚ͩΞϩέʔγϣϯ • KTPO/FX%FDPEFS %FDPEF͸ 4USFBNॲཧͳͷͰɺ ಡΈࠐΈαΠζ͸ࣄલʹΘ͔Βͳ͍ • ಡΈࠐΈ༻ͷόοϑΝ ॳظ஋ CZUF Λ࢖͍੾ͬͨΒ࠶Ξϩέʔγϣϯ • HPDDZHPKTPOͰ͸ KTPO6ONBSTIBMͷ଎౓Λམͱ͞ͳ͍ͨΊʹɺ 6ONBSTIBMͱ 4USFBN%FDPEFͰҟͳΔύεΛ௨ͬͯσίʔυ͍ͯ͠Δ
  9. TZOD1PPMΛ࢖ͬͨ TMJDFͷ࡞੒ • TZOD1PPMΛ࢖ͬͯ TMJDFΛ؅ཧ͢Δ • ܕຖʹผͷ QPPMΛ࡞੒ • Ҏલ࡞ͬͨ

    TMJDFΛ࢖͍ճͤΔͷͰɺ $BQBDJUZΛ֦ு͢Δճ਺͕ݮΔ • ग़ྗ݁Ռʹ࢖͍ճ͍ͯ͠Δ TMJDFΛͦͷ··࢖͏͜ͱ͸Ͱ͖ͳ͍ͷͰɺ DPQZ͢Δ • DPQZ͸ SFGMFDUUZQFETMJDFDPQZΛར༻
  10. "MMPDBUJPO0QUJNJ[BUJPO·ͱΊ • &ODPEFS • KTPO.BSTIBM͸ ฦΓ஋ͷ <>CZUFͷΈώʔϓʹ֬อ • KTPO/FX&ODPEFS JP8SJUFS

    &ODPEF͸ ;FSP"MMPDBUJPOՄೳ • ϦϑϨΫγϣϯૢ࡞͸ HPDDZHPSFGMFDUͰ ;FSP"MMPDBUJPOԽ • %FDPEFS • 6ONBSTIBMͱ 4USFBN%FDPEFͰॲཧΛ෼͚Δ • TMJDF࡞੒ʹ TZOD1PPMΛར༻͢Δ • GVODUJPOWBMVFͷݺͼग़͠͸ VJOUQUSʹม׵͢Δ͜ͱͰճආ
  11. ܕʹԠ࣮ͨ͡ߦ࣌࠷దԽ • (P͸੩తܕ෇͚ݴޠ • ܕͷ಺෦ϨΠΞ΢τ͕࣮ߦ࣌ʹมԽ͢Δ͜ͱ͸ͳ͍ • ܕʹରԠ͢ΔΞυϨε΋ݻఆ HPDDZHPSFGMFDU5ZQF*% JOUFSGBDF\^ VJOUQUS

    • ࠷ॳʹݺͼग़͞ΕͨࡍʹܕʹԠͨ͡ઐ༻ॲཧΛ࡞ͬͯ̎ճ໨͔ΒͦΕΛ ݺͼग़͢ UZQF*%Λऔಘ͠ɺͦΕΛ NBQͷ LFZʹͯ͠ ઐ༻ॲཧΛΩϟογϡ͢Δྫ
  12. HPKTPOͷ࣮ߦ࣌࠷దԽઓུ &ODPEFS • ࠷దԽίʔυͷධՁʹ7JSUVBM.BDIJOFํࣜΛ࠾༻ • ॳճ࣮ߦ࣌ʹड͚औͬͨܕʹ࠷దԽ͞ΕͨॲཧΛ࡞Δ DPNQJMF • ౓໨͔Β͸࠷దԽ͞ΕͨॲཧΛ࣮ߦ ܕݕࠪͷίετ͕ͳ͍

    • ࠷దԽॲཧͰ͸ SFGMFDU͸࢖Θͳ͍ ͢΂ͯϙΠϯλԋࢉ • GPSTXJUDIͰॲཧ͢Δ TXJUDI͢Δճ਺͕গͳ͍΄Ͳ଎͘ͳΔ UZQF5TUSVDU\ " JOU #TUSJOH ^ DPNQJMF SVO type offset int 0 string 8 SFGMFDU4USVDU'JFME0GGTFUͰܭࢉ <>PQDPEF
  13. HPKTPOͷ࣮ߦ࣌࠷దԽઓུ %FDPEFS • جຊઓུ͸ &ODPEFSͱಉ͡ • ॳճ࣮ߦ࣌ʹܕʹԠͨ͡࠷దԽॲཧΛߏங • ౓໨Ҏ߱͸࠷దԽॲཧΛݺͿ ܕݕࠪͷίετͳ͠

    • ࠷దԽॲཧͰ͸ SFGMFDUΛ࢖Θͳ͍ ͢΂ͯϙΠϯλԋࢉ • ϙΠϯλԋࢉΛগ͠঺հ QVJOUQUS • JOU • JOU VOTBGF1PJOUFS Q  • NBQ • SFGMFDUNBLFNBQͰ VOTBGF1PJOUFSΛ࡞Δ • SFGMFDUNBQBTTJHOͰ LFZ WBMVFΛ௥Ճ͍ͯ͘͠ • VOTBGF1PJOUFS VOTBGF1PJOUFS Q NBLFNBQͷฦΓ஋ • QPJOUFS • ͋ΔܕͷϙΠϯλΛ࡞Δͱ͖͸ SFGMFDUVOTBGF@/FXΛ࢖͏
  14. %FDPEFSͷͦͷଞͷߴ଎ԽςΫχοΫ • /6-Λ࢖ͬͯ৚݅൑ఆճ਺ΛݮΒ͢ • ಡΈਐΊΔ౓ʹ DVSTPSMFOHUIΈ͍ͨͳ൑ఆΛ͢Δͱ஗͘ͳΔ • NBLF <>CZUF 

    MFOHUI  ͱ <>CZUF࡞੒࣌ʹऴ୺จࣈͿΜ༨ܭʹ֬อ͢Δ • จࣈछ൑ఆ༻ͷ TXJUDIDBTFʹ /6-Λ௥Ճ • NBQͰݕࡧ͢Δ৔߹͸ BSSBZͰݕࡧ͢Δํ๏΋ݕ౼͢Δ • GPSΑΓ HPUPͷํ͕ύϑΥʔϚϯε͕ྑ͍έʔε͕͋Δ Լͷ GPSΛ࢖ͬͨॻ͖ํΑΓ΋ ࠨͷ HPUPΛ࢖ͬͨॻ͖ํͷํ͕଎͍
  15. ݕ౼தͷߴ଎Խख๏ • TUSVDUΛσίʔυ͢Δࡍɺ+40/0CKFDUͷ ֤LFZ͕ TUSVDUͷϝϯό ʹؚ·Ε͍ͯΔ͔൑ఆ͢Δॲཧ͕ॏ͍ NBQͷ MPPLVQ • ී௨ʹ΍ΔͳΒ͹

    NFNCFS.BQNBQ<TUSJOH>EFDPEFSΛ࡞͓͍ͬͯͯɺ EFD FYJTUTNFNCFS.BQ<LFZ>ͷΑ͏ʹଘࡏ֬ೝ͢Δ • NBQΑΓ΋ TXJUDIͰςʔϒϧΛ࡞Δํ͕଎͍ • HPKBZ͸ TXJUDIDBTFΛϢʔβʹ࡞ΒͤΔ͔Β଎͍ • KTPOJUFSBUPSHP΋ TUSVDUGJFME͕ ݸ·Ͱͷ΋ͷʹݶΓɺTXJUDIDBTFΛ࢖ͬͨ ςʔϒϧΛ࡞͍ͬͯΔ • HPDDZHPKTPOͰ͸ݱࡏ MPPLVQʹ NBQΛར༻͍ͯ͠Δ • HQFSGΛ࢖ͬͨ׬શϋογϡؔ਺ͷಋೖΛݕ౼ (Pʹ QPSU͍ͯ͠Δͱ͜Ζ • +*5ίϯύΠϥͷಋೖ΋ݕ౼ HPDDZHPKJU
  16. HPDDZHPKJU • IUUQTHJUIVCDPNHPDDZHPKJU • +*5ίϯύΠϧϥΠϒϥϦ • ཪଆ͸ (/6MJCKJU IUUQTXXXHOVPSHTPGUXBSFMJCKJU •

    +*5ίϯύΠϧ͞Εͨػցޠ͔Β (Pͷؔ਺ΛݺͿ͜ͱʹ੒ޭ • DHPͰ $͔Β (Pͷؔ਺ΛݺͿͨΊͷ࢓૊ΈΛԠ༻ • ࠷ऴ໨ඪ͸ KJU&WBM TUSJOH ͷΑ͏ͳ "1*Λ଍͢͜ͱ
  17. ·ͱΊ ࢖͏ଆ͕஌͓͖͍ͬͯͨ͜ͱ • Τϯίʔυɾσίʔυର৅ʹ JOUFSGBDF\^ܕ͕͋Δͱɺ࠷దԽॲཧͷԸܙ Λड͚ʹ͍͘ • ଎͞ΛٻΊΔͳΒɺͪΌΜͱܕ෇͚͠·͠ΐ͏ • KTPO.BSTIBMͱ

    KTPO/FX&ODPEFS &ODPEFͰ͸ &ODPEFͷํ͕଎͘ͳΔ Մೳੑ͕͋Δ • *'తʹ &ODPEF͸ ;FSP"MMPDBUJPOʹ͢Δํ๏͕͋ΔͨΊ • KTPO6ONBSTIBMͱ KTPO/FX%FDPEFS %FDPEF Ͱ͸ 6ONBSTIBM ͷํ͕଎͍ • ڊେͳ +40/Λύʔεͯ͠͠·͏৺഑͕ͳ͍ͳΒɺ 6ONBSTIBMʹ͢Δͱྑ͍
  18. 2"