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

Go1.19で採用された Pattern-defeating Quicksort の紹介

po3rin
August 15, 2022

Go1.19で採用された Pattern-defeating Quicksort の紹介

今回はPattern-defeating Quicksortの論文を読んでいき、Goでどのように実装されているか簡単に見ていく

po3rin

August 15, 2022
Tweet

More Decks by po3rin

Other Decks in Programming

Transcript

  1.       MPX NJE IJHI 

         MPX NJE IJHI NJEͳͷͰɺIJHIͱSFQMBDFͯ͠IJHI
  2.       MPX NJE IJHI 

         MPX NJE IJHI       MPX NJE IJHI NJEͳͷͰɺIJHIͱSFQMBDFͯ͠IJHI NJEͳͷͰɺNJE 
  3.       MPX NJE IJHI 

         MPX NJE IJHI       MPX NJE IJHI       MPX NJE IJHI NJEͳͷͰɺIJHIͱSFQMBDFͯ͠IJHI NJEͳͷͰɺNJE  NJEͳͷͰɺMPXͱSFQMBDFͯ͠NJE  MPX 
  4.       MPX NJE IJHI 

         MPX NJE IJHI       MPX NJE IJHI       MPX NJE IJHI       MPX NJE IJHI NJEͳͷͰɺIJHIͱSFQMBDFͯ͠IJHI NJEͳͷͰɺNJE  NJEͳͷͰɺMPXͱSFQMBDFͯ͠NJE  MPX  NJEͳͷͰɺMPXͱSFQMBDFͯ͠NJE  MPX 
  5.       MPX NJE IJHI 

         MPX NJE IJHI       MPX NJE IJHI       MPX NJE IJHI       MPX NJE IJHI       MPX NJE IJHI NJEͳͷͰɺIJHIͱSFQMBDFͯ͠IJHI NJEͳͷͰɺNJE  NJEͳͷͰɺMPXͱSFQMBDFͯ͠NJE  MPX  NJEͳͷͰɺMPXͱSFQMBDFͯ͠NJE  MPX  NJEͳͷͰɺNJE 
  6.       MPX NJE IJHI 

         MPX NJE IJHI       MPX NJE IJHI       MPX NJE IJHI       MPX NJE IJHI       MPX NJE IJHI MPX NJE IJHI       NJEͳͷͰɺIJHIͱSFQMBDFͯ͠IJHI NJEͳͷͰɺNJE  NJEͳͷͰɺMPXͱSFQMBDFͯ͠NJE  MPX  NJEͳͷͰɺMPXͱSFQMBDFͯ͠NJE  MPX  NJEͳͷͰɺNJE  NJEͳͷͰɺIJHIͱSFQMBDFͯ͠IJHI NJE͕IJHIΛ௒͑ͨͷͰऴྃ
  7. 1BSUJUJPOJOHJO1BUUFSOEFGFBUJOH2VJDLTPSU         

     ୯७ͳΫΠοΫιʔτͷ࣮૷Ͱ͸ɺ౳͍͠ൺֱཁૉΛಉ͡ύʔςΟγϣϯʹ഑ஔ͢Δ͜ͱʹ ΑΓϺ O? ͷ࠷ѱͷέʔε͕Ҿ͖ى͜͞Ε·͢ɻ ౳͍͠ཁૉΛޮ཰తʹॲཧ͢Δʹ͸ɺ౳͍͠ཁૉΛूΊͯɺͦΕΑΓେ͖͍ཁૉɺখ͍͞ཁ ૉͷ෼ׂʹͰ͖Ε͹ɺͦͷޙͷιʔτͰ౳͍͠ཁૉΛؚΉύʔςΟγϣϯͷιʔτΛε ΩοϓͰ͖·͢ɻ·͞ʹΦϥϯμࠃض໰୊ͱಉ౳ͷࡾ෼ׂͷߟ͑ํ͕࢖͑ͦ͏Ͱ͢ɻ ͜ͷΑ͏ʹύʔςΟγϣϯΛ෼ׂͰ͖Δͱخ͍͠ 
  8. 1BSUJUJPO-FGU3JHIU  1   1  QBSUJUJPO@SJHIU QBSUJUJPO@MFGU 1BUUFSOEFGFBUJOH2VJDLTPSU͸ͭͷύʔςΟγϣϯ༻ؔ਺Λ૊Έ߹ΘͤͯઌఔͷύʔςΟγϣϯ

    Λୡ੒͠·͢ɻͭ͸ϐϘοτQʹ౳͍͠ཁૉΛࠨͷύʔςΟγϣϯʹάϧʔϓԽ QBSUJUJPOMFGU ͠ɺ΋͏ͭ͸ϐϘοτʹ౳͍͠ཁૉΛӈͷύʔςΟγϣϯ QBSUJUJPOSJHIU ʹάϧʔϓԽ͠·͢ɻ ͜ͷύʔςΟγϣϯͷ૊Έํͷར఺͸ʮཁૉ͕ϐϘοτͷ஋Ҏ্͔Ͳ͏͔ʯͱ͍͏৚݅ҰݸͰ൑ఆͰ ͖Δ͜ͱͰ͢ɻ
  9. #BE1BUJUJPO  ෆྑύʔςΟγϣϯΛෳ਺ճૺ۰͢ΔͷΛճආ͢ΔͨΊʹԼهεςοϓΛߦ͍·͢ɻ w ࠷ॳʹɺΧ΢ϯλʔͱͯ͠MPH αϒγʔέϯε௕ ʹઃఆ͠·͢ w ෆྑύʔςΟγϣϯʹૺ۰͢ΔͨͼʹɺΧ΢ϯλʔΛσΫϦϝϯτ͠·͢ w

    ࠶ؼݺͼग़͠ͷ։࢝࣌ʹΧ΢ϯλʔ͕ͷ৔߹ɺΫΠοΫιʔτͰ͸ͳ͘ɺώʔϓιʔτΛ࢖༻ ࿦จͰ͸͜ͷϐϘοτύʔηϯλΠϧQͷᮢ஋Λͱ͓ͯ͠Γ(P΋ʹͳ͍ͬͯ·͢ɻ ͜ͷεΩʔϜͷར఺͸ɺΞʔΩςΫνϟ͕มߋ͞Εͨ৔߹ ώʔϓιʔτͷ୅ΘΓʹผͷ࠷ѱͷέʔε ͷιʔτΞϧΰϦζϜΛ࢖༻͍ͯ͠Δ৔߹ͳͲ ʹɺͦΕʹ߹ΘͤͯQΛௐ੔Ͱ͖Δ͜ͱͰ͢ (Pͷ৔ ߹͸͕ϋʔυίʔυ͞Ε͍ͯͯมߋ͸Ͱ͖ͳ͍ ɻ
  10. ΤϜεϦʔͰ͸ࢸΔॴͰ(PΛ࠾༻ͯ͠։ൃΛ͍ͯ͠Δɻ΋ͪΖΜ(PΛ࣮຿Ͱ΍ͬͨ ͜ͱ͕ͳͯ͘΋׻ܴɻ ֤छ"1* ΞϓϦέʔγϣϯɺݕࡧɺϨίϝϯυɺϦϥϯΩϯά౳  Ϩίϝϯυ"1* σʔλ࿈ܞ#BUDI 1VTI௨஌ج൫ ֤छศརπʔϧͷ։ൃ (Pͷษڧձ΋։͔Ε͓ͯΓɺݱࡏ͸ʮ࣮༻(PݴޠʕγεςϜ։ൃͷݱ৔Ͱ஌͓ͬͯ

    ͖͍ͨΞυόΠεʯ<>ͷྠಡձ΋։͔Ε͍ͯΔɻιϑτ΢ΣΞΤϯδχΞ͚ͩͰͳ ͘ɺ.-ΤϯδχΞ΋(P͕ॻ͚Δͱ͍͏ҟ࣭ͳ؀ڥɻ ΤϜεϦʔ͸(PͰ։ൃ͍ͨ͠ϝϯόʔΛืूத [3] https://www.amazon.co.jp/dp/4873119693/ref=cm_sw_em_r_mt_dp_G4Z5RYS2FDVTVWXVJEYS?_encoding=UTF8&psc=1