packages feed

pacman-memcache (empty) → 0.1.0.0

raw patch · 4 files changed

+89/−0 lines, 4 filesdep +basedep +deepseqdep +directory-treesetup-changed

Dependencies added: base, deepseq, directory-tree

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c)2011, Krzysztof Skrzętnicki++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Krzysztof Skrzętnicki nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ pacman-memcache.cabal view
@@ -0,0 +1,33 @@+Name:                pacman-memcache+Version:             0.1.0.0+Synopsis:            Read whole Pacman database which pushes it into the memory cache+Description:         Pacman is Linux package manager. It is used by Arch Linux.+                     It's database is rather slow because it contains thousands of little files,+                     which takes an enormous time to process.+                     +                     The easiest way to speed up operations on database is force all those files into memory cache.+                     This is the purpose of this program: it reads whole package database,+                     where it will reside until kernel decides to remove this files from cache.++                     Three subsequent runs of pacman:+                     > pacman -Ss foo  0,37s user 0,66s system 2% cpu 41,459 total+                     > pacman -Ss foo  0,16s user 0,08s system 98% cpu 0,238 total+                     > pacman -Ss foo  0,15s user 0,08s system 97% cpu 0,237 total++                     Using pacman-memcache:+                     > pacman-memcache  1,11s user 0,53s system 6% cpu 26,312 total+                     > pacman -Ss foo  0,15s user 0,09s system 19% cpu 1,260 total+                     > pacman -Ss foo  0,15s user 0,08s system 97% cpu 0,235 total+++License:             BSD3+License-file:        LICENSE+Author:              Krzysztof Skrzętnicki+Maintainer:          Krzysztof Skrzętnicki+Category:            System+Build-type:          Simple+Cabal-version:       >=1.2++Executable pacman-memcache+  Main-is:             pacman-memcache.hs+  Build-depends:       base >= 3 && < 4, directory-tree < 0.9.2, deepseq < 1.2
+ pacman-memcache.hs view
@@ -0,0 +1,24 @@+module Main where++import Control.DeepSeq+import System.IO+import System.Directory.Tree+ +main = do+  tree <- readDirectoryWith readFile' "/var/lib/pacman/sync"+  tree `deepseq` return ()++instance (NFData a) => NFData (AnchoredDirTree a) where+    rnf (fp :/ dt) = rnf (fp,dt)++instance (NFData a) => NFData (DirTree a) where+    rnf (Failed p1 p2) = rnf p1+    rnf (Dir p1 p2) = rnf (p1,p2)+    rnf (File p1 p2) = rnf (p1,p2)++readFile' fn = do+  h <- openFile fn ReadMode+  s <- hGetContents h+  let slen = (length s)+  slen `deepseq` hClose h+  return slen