BazQux(ããºã¯ãã¯ã¹)ã¯ãGoogle Reader ã®ä»£æ¿ã¨ãã¦å¯ãã«æ³¨ç®ããã¦ãã RSS ãªã¼ãã§ããå®è£ ã¨éç¨ãä¸äººã§ãã£ã¦ãã Vladimir Shabanov ããã«ããã¨ãBazQux ã®ã¦ãªã¯ã
- é«éã§ãã
- ããã°ã®ã³ã¡ã³ãã表示ã§ãã
- è¤æ°ã®ãã¥ã¼ããã
- ã¢ãã¤ã«ã«å¯¾å¿ãã¦ãã
ãªã©ãããã§ãã
BazQux ã®ããã³ãã¨ã³ãã¯ãUr/Web ã§è¨è¿°ãããã³ã¼ãããçæããã JavaScriptãããã¯ã¨ã³ã㯠Haskell ã ããã§ããé«éãªã®ã¯ãHaskell ã®ãããã§ãã㨠Vladimir ããã¯è¨ã£ã¦ãã¾ããæã ãéçºãã¦ãã HTTP ã¨ã³ã¸ã³ã® Warp ã使ããã¦ããããã§ãã
ç¾å¨ãå㯠Haskell 用の HTTP/2 ライブラリã®ä½æã«åãçµãã§ãããå¿ è¦ãªæè¡ã調ã¹ã¦ããéç¨ã§ãredditでの議論ã®ãã¨ãæãåºãã¾ãããä»åãããããèªãã§ã¿ãã¨ãåãå®è£ ãã¦ãã DNS ライブラリã使ã£ã¦ããããADNS (ã®ã©ããã¼ã§ãã hsdns)ã¨æ¯ã¹ã¦å®å®ãã¦ãããã®ã®ããã¡ã¤ã³ãæ¤ç´¢ã§ããªããã¨ãããã¨æ¸ããã¦ãã¾ããã
åãDNSã©ã¤ãã©ãªãæ¸ããã®ã¯ãä¸å®å®ãªADNSãè¦éã£ããããªã®ã§ãå®å®ãã¦ããã®ã¯å½ç¶ã¨ãã¦ããã¡ã¤ã³ã®æ¤ç´¢çãæªãç¹ã¯æ°ã«ãªãã¾ãããããã§ãVladimir ããã«ã¡ã¼ã«ãæ¸ããã¨ãããããã«è¿äºãè¿ã£ã¦ãã¾ãããå½¼ã®ã³ã¼ãã¨å®éã®ãã¡ã¤ã³ãªã¹ããè¦ãã¦ããã£ãã¨ããã
- DNSã©ã¤ãã©ãªã®ä½¿ãæ¹ãééã£ã¦ãã
- MVarãå¤ç¨ãã¦ãã¦æ§è½ãæªãã (Vladimir ã¯ãããã¯ããã«ããã¯ã§ã¯ãªãã¨è¨ã£ã¦ãã)
- HashMapã§æã£ã¦ãããã£ãã·ã¥ãå®æçã«æåããã¦ãªãã®ã§ã¡ã¢ãªããããã使ããã
ã¨ãããã¨ãåããã¾ããã
奮ãç«ã£ã¦ãã¾ã£ãåã¯ã使ã£ã¦ãããããåããã¾ããã§ããããããããã« concurrent-dns-cache ã¨ããã©ã¤ãã©ãªãä½ãå§ãã¾ãããè¨è¨ã®ãã¤ã³ãã¯ä»¥ä¸ã®éãã
- DNSã©ã¤ãã©ãªãæ£ãã使ã
- ã»ããã©ã STM ã§å®è£
ãã
- é«ä¸¦è¡ãªç¶æ³ã§ã¯ MVar ããããã¯ã
- ãã£ãã·ã¥ã¯ Priority Search Queue ã§æã¤
- åªå 度ã«æå®ããæå»ã§æåãã§ããããã¡ããããã¡ã¤ã³åã§æ¤ç´¢ãã§ããã
- ãã¡ã¤ã³åã ShortByteString ã¨ãã¦æ±ã
- ByteString 㯠pinned ãªãã¸ã§ã¯ããªã®ã§ãã¡ã¢ãªãæçåããããã®ãã Vladimir ãã㯠Text ã使ã£ã¦ããããShortByteString ã®æ¹ãã¡ã¢ãå©ç¨å¹çããã
- é«éãªæ¤ç´¢ãå®ç¾ããããã«ãã¼ã®ç¬¬ä¸è¦ç´ ã¨ãã¦ããã·ã¥å¤ãæã¤
concurrent-dns-cache ã¯ããã§ãã BazQux ã«æ¡ç¨ããã以åããããã¡ã¤ã³ã®æ¤ç´¢çãé«ããå°ãªãã¡ã¢ãªã§å®å®ãã¦åãã¦ããããã§ããé«æ§è½ã§é«ä¸¦åã§å®å®ãã¦ãããããã¯ã¼ã¯ã³ã¼ãããã°ããå®è£ ã§ããã®ã Haskell ã®ããç¹ã®ä¸ã¤ã§ããã
ä»åã®çµé¨ã¯ HTTP/2 ã®å®è£ ã«ãå½¹ç«ã¡ããã§ããã£ãããç¾å ´ã®äººã¨è°è«ã§ããã®ã¯ã®ã¯æ¥½ããçµé¨ã§ããã
ä»å°ãæ©ãã§ãããã¨ã¯2ã¤ã
ä¸ã¤ç®ï¼ãã¼ã®å®ç¾©ã¯ä»¥ä¸ã®ããã«ãªã£ã¦ãã¾ãã
type Hash = Int data Key = Key !Hash -- making lookup faster !ShortByteString -- avoiding memory fragmentation -- Haskell 2010 says: Derived comparisons always -- traverse constructors from left to right. deriving (Eq,Ord,Show)
å®éã®ãã¼ãããã·ã¥å¤ã¨ä¸ç·ã«ããããã¨ã§ã(MapããHashMapã¸ã®å¤æ´ã¨ã¯éã£ã¦)ã³ã³ããã®æ§é ãå¤ãããã¨ãªããæ¤ç´¢é度ãé«éã«ãã¾ããã¿ããªä½¿ãããã¨ã¯æãã¾ãããã©ã¤ãã©ãªã«ããã«ã¯å°ããããã®ã§ãã©ããããããªãã¨ããæãã§ããã¾ã ãã³ããã¼ã¯ãåã£ã¦ããªãã®ã§ãããæ¬å½ã«æç¨ãããªãå°ããã¦ãã©ã¤ãã©ãªã«ããããããã¾ããã
äºã¤ç®ï¼Priority Search Queue ã®æ¬å®¶æ¬å ã®ã©ã¤ãã©ãªã§ãã PSQueueã«ã¯ãããåªå é ä½ä»¥ä¸ã®è¦ç´ ãåãåºã API ã¯ããã®ã§ãããè¦ç´ ãåãããã£ãæ¨ãè¿ã API ã¯ããã¾ãããããã§ãå㯠GHC ã®ã½ã¼ã¹ã³ã¼ããã PSQ.hs ãã³ãã¼ãã¾ãããPSQueue ã® API ã¯ãã¾ããããªãããPSQ.hs ã¯ãã¼ã¨åªå é ä½ã®åãåºå®ã§ãã両è ã® API ã¯ã¾ã£ãéãã®ã§ãPSQueue ã PSQ.hs ã§ç½®ãæãã¦ãã¼ã¸ã§ã³ã¢ããããã¨ãããã¨ãã§ãã¾ããã
ãããããPriority Queue ããã¼ãã®å¥åã§ãããã¨ãç¥ããªã人ã¯å¤ãæ··ä¹±ã®å ãªã®ã§ãsearch-heap ã¨ããåã®å¥ã©ã¤ãã©ãªã§ãªãªã¼ã¹ãããããªããã©ããããããªããã¨ããæãã§ãã