ã¤ã³ãã«ã»AMDã®CPUã¢ã¼ããã¯ããæããï¼ GNU grep ãéãçç±
GNU grepã®å ç¥ä½è ãFreeBSDããã«ã¼ãschoolãã¦ããã
http://lists.freebsd.org/pipermail/freebsd-current/2010-August/019310.html
FreeBSD対GNU grepã®ããã©ã¼ãã³ã¹ãè°è«ãã¦ããã¨æãããã¨ãã¨ã«ã俺ã¯grepã®å代ä½è ã ãã¨åä¹ã£ã¦ç¾ãããç·ãããã
å±¥æ´æ¸(http://duckytech.com/resume.pdf)ãè¦ãã¨ãGNU coreutilsã«è²¢ç®ããå¾ãã¤ã³ãã«ãAMDã§CPUã¢ã¼ããã¯ããå¤ãã¦ããç·ã ãããã¯è©±ãèããæ¹ãããããã ã
FreeBSDã¦ã¼ã¶ã§ãããå½¼ã¯ãªã¹ãã観é²ãã¦ããããã¾ãã¾GNU対BSDã®grepè«äºã«å½ã£ã¦ãã¾ã£ãããã ãBSDã®ãªã¹ãã«GNU grepã®ç§å¯ã解ãã
- æ1ï¼ å ¨ã¦ã®å ¥åãã¤ããè¦ãªãããéã
- æ2ï¼ è¦ããã¤ãã«é¢ãã¦ã¯æ¥µåå°ãªãã¤ã³ã¹ãã©ã¯ã·ã§ã³ãå®è¡ããããéã
GNU grepã¯æåãªãBoyer-Mooreã¢ã«ã´ãªãºã ãã使ã£ã¦ãããããã¯ã¿ã¼ã²ããæååã®æå¾ã®ãã£ã©ã¯ã¿ããã¼ãã«ã¨ç §åããã§ããã ãç¡ç¨ã¨ããã£ãã¤ã³ãããã¨é£ã°ãã¦ãããã®ã ã
(Boyer-Mooreã£ã¦è¨ãã°æç§æ¸ã«ã¯åºã¦ãããå®ç¨ä¾ã¯ãã¾ãè¦ãªãã¢ã«ã´ãªãºã ã ãããããåºå®æååã®ããã®ãã¯ããã¯ã ã¨æã£ã¦ãããã®ãæ£è¦è¡¨ç¾ã«ä½¿ããã¦ããã®ã¯ã¡ãã£ã¨ä»¥å¤ã ã£ãã)
GNU grepã¯ããã«Boyer-Mooreã®å loopãå±éããã(ãã«ã¼ããunrollãããã£ã¦ã©ã訳ããã§ãããï¼) ããã¦Boyer-Mooreã®ãã¼ãã«ã工夫ãããã¨ã«ãã£ã¦å¤ã«ã¼ãã§æ¯åå½ãçµäºãã¹ããçããããã«ãã¦ãããçµæçã«ã¯ããããã®å ¥åãã¤ãã§å¹³åï¼ã¤ä»¥ä¸ã®x86ã¤ã³ã¹ãã©ã¯ã·ã§ã³ã¾ã§æé©åããã¦ããã
Boyer-Mooreã®æé©åã¯ãAndrew Hume and Daniel Sundayãã(åæ)åç §ã
ãµã¼ããéããªã£ããIOãéãããªããã°ãããªãã
- é©åãªã·ã¹ãã ã³ã¼ã«ã使ããã¨ã«ããå ¥åã®ã³ãã¼ãé¿ãã
- æ¹è¡ã§ã®ã©ã¤ã³æããé¿ãã
æ¹è¡ã§åºåãã¨ãªãã¨å ¨ã¦ã®å ¥åãã¤ããè¦ããã¨ã«ãªããæ°åé ããªãããªã®ã§ãBoyer-Mooreã§ããããè¦ä»ããå¾ã§å¢çã¨ãã¦å¿ è¦ãªæ¹è¡ãæ¢ãã
GNU grepãæ¸ããå½æã¯LinuxãUNIXã§read(2)ãããã¨ã«ã¼ãã«å ã§ä½åãªã³ãã¼ãè¡ããã¦ããã®ã§ãmmapã§ã¤ã³ããããèªã¿è¾¼ãã§ãããæè¿ã¯OSãreadã«ãããã®ä½åãªã³ãã¼ãç¡ãããããããmmapã«ããå ¥åããã£ãã©ã«ãããå¤ããã¦ããããããã--mapãªãã·ã§ã³ã§ãããå¼ã³èµ·ããã¨ãã§ãããããã¦ããããä»ã§ãäºå²ç¨ã®ã¹ãã¼ãã¢ãããå¯è½ã«ãããã¨ã示ãã¦ããã (åæåç §)
ã¾ã¨ã
- Boyer-Mooreã使ããå ã«ã¼ããå±é(unroll)ãã
- unbuffered IOã§ã³ãã¼ãé¿ããã(åºåã®IOã¯ãã¾ãæ°ã«ããªããå°ãããã)
- ããããã¿ã¤ããã¾ã§\nãæ¢ããª
- ãã¼ã¸ãµã¤ãºãå¢çã«åããããããã¡ã¼ç®¡çã«ãã£ã¦ã«ã¼ãã«å ã§ã®ã³ãã¼ãé¿ãã
ãããCPUã¢ã¼ããã¯ã(ã«ãªã人)ãuser-landããã°ã©ã ãæé©åããã¨ãããªããã ããããèªãã§å°ã俺ã®grepãéããªã£ãæ°ãããã
ãã¾ãï¼
hex fiend (http://ridiculousfish.com/hexfiend/)ã¨ããããã¯ããã°ã©ã ã®ä½è
ããç¡ãUnixã®è³¢è
ãã¨å¯¾æ±ºãã
http://ridiculousfish.com/blog/archives/2006/05/30/old-age-and-treachery/
GNU grepã«ä¸è¨ä»¥å¤ã®ãåæ¯ããªæé©åããããã¨ãæ´é²ããããã£ããç¬ããã