archive-ca.com » CA » E » EVANJONES.CA

Total: 397

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • Model Checking a Paxos Implementation (evanjones.ca)
    corner conditions This led me to wonder how large of a system could I exhaustively check and how could I be smarter about choice of messages to deliver Thus I wrote a very simple Paxos implementation in Python with two known bugs along with a simple simulator to exhaustively test it The first bug was easy to find It only requires five processes three acceptors two proposers My system is able to exhaustively test this configuration in about 20 minutes However my system struggles to find the second bug The bug requires six processes three acceptors three proposers My system finds the problem after running for 30 hours I gave up on trying to exhaustively check this configuration It took 150 hours 6 5 days to check 615 million execution traces Based on its progress I estimate it would take my system approximately a month using one 3 GHz Xeon CPU to exhaustively test this configuration I also tried checking random execution paths but the bug was undetected after running for one day This reveals the weakness of model checking there are simply too many possible orders of events to search the space exhaustively for anything more than trivial systems Certainly a combination of better algorithms and a better implementation particularly not in Python would be able to exhaustively search my simple Paxos implementation in a reasonable amount of time However it will always be infeasible to exhaustively test larger systems That said this is still a very useful tool as I have written before Larger systems are likely to have more bugs so even simple randomized testing is useful My experience suggests that designing software so it can be easily tested in this fashion is worthwhile Unfortunately if it doesn t find any bugs that does not mean that none exist Details Searching for Bugs My model is very simple Each process is a Python class which handles two methods start called when the system is starting execution and messageReceived called when a message is delivered to the process While executing those methods the Python code can send messages to other processes There is also a validator method called at the end of an execution trace To verify that the state of the system is correct The simulation assumes nothing about the state of the processes or the contents of the messages My first implementation was very simple depth first search over all possible message interleavings This works only for very simple protocols with very few processes It ends up visiting many interleavings which are identical For example if message a goes to process 1 and message b goes to process 2 the message interleavings a b and b a lead to the same result Thus you only need to visit one or the other My next implementation is slightly smarter It is based on the observation that if you deliver message a to process 1 then explore all possible states under that choice then to enter a new

    Original URL path: http://www.evanjones.ca/model-checking-paxos.html (2016-04-30)
    Open archived version from archive


  • Thread-Safe Random Numbers (evanjones.ca)
    is to use rand r However this only maintains an unsigned int worth of state which is not sufficient for good random numbers On Linux glibc provides random r which is ideal as it lets you use a large per thread state However Mac OS X and FreeBSD do not provide it Another alternative is to use nrand48 which exists on all the modern Unix platforms that I have tried Solaris Mac OS X FreeBSD Linux While it only keeps 48 bits of state that is probably good enough for most applications To test the thread safety of the random number generators I wrote a small test program which spawns a number of child threads each of which seed and generate a set of numbers It then compares all the numbers that are generated and counts the number of times a match is found For the parameters I used a perfect random number generator would expect to find 3 5 matches p 4 65661e 10 The table below shows the actual number of matches and the measured probability Random function Linux Mac OS X random 3 p 3 99138e 10 257 p 3 41928e 08 rand 5 p 6 66523e 10 37622 p 5 00546e 06 rand r 0 p 0 0 p 0 nrand48 6 p 7 98276e 10 2 p 2 66092e 10 An interesting note is that on both Mac OS X and Linux rand r produces zero matches very reliably even though it should produce an average of 3 5 I think this is due to a combination of the way I am seeding the generator and the algorithm that is used Either way it seems to suggest that you should not use rand r My conclusion It seems like nrand48 is ideal for my application

    Original URL path: http://www.evanjones.ca/random-thread-safe.html (2016-04-30)
    Open archived version from archive

  • Opt-in Flash (evanjones.ca)
    keep reading the current page while the other pages load CTRL click or Command click However if many pages have Flash objects such as ads my computer slows down Worse yet this consumes laptop battery power for nothing The solution only load Flash objects when you want by clicking on them For Firefox install the FlashBlock extension For Safari you want clicktoflash which was recently released One disadvantage of blocking

    Original URL path: http://www.evanjones.ca/opt-in-flash.html (2016-04-30)
    Open archived version from archive



  • New England Database Day 2009 (evanjones.ca)
    organizing a one day free conference on databases at MIT on Friday January 30th You should attend if you are in the area Last year it was a good mix of academic and industrial participants I ll be presenting a

    Original URL path: http://www.evanjones.ca/nedbday2009.html (2016-04-30)
    Open archived version from archive

  • Subversion Hooks Stored in the Repository (evanjones.ca)
    time including third party dependencies so all I need to do is check out the repository to get the project working One of the more powerful features of version control systems are hooks which let you run arbitrary programs as part of committing a change For Subversion it has always bothered me that the hooks are stored outside the repository This means that you can t track changes to those scripts in the same way that you track the rest of the repository Hence I hacked a simple script to solve this problem My post commit hook script does the following Checks out a directory in the repository into a temporary directory Executes the real post commit hook script stored in the temporary directory Copies the latest version of itself over the previous version in the repository s hooks directory This lets you do a few things First you can put any scripts or configuration that your post commit hook requires into a single directory in your repository Second you can update the post commit hook script itself This means you can install this bootstrap post commit script once then update it just by checking in a new version Of

    Original URL path: http://www.evanjones.ca/svn-hooks-in-repository.html (2016-04-30)
    Open archived version from archive

  • Git Command Shortcuts (aliases) (evanjones.ca)
    personal development projects However Git appears to be more popular and I ve needed to use it The two are very similar but my biggest annoyance is that Mercurial automatically completes commands using the characters you have typed so hg st is a shortcut for hg status Git does not do this by default but you can add shortcuts with git config global alias shortcut command Example git config global

    Original URL path: http://www.evanjones.ca/git-shortcuts.html (2016-04-30)
    Open archived version from archive

  • Random Ubuntu Tips (evanjones.ca)
    partition If you do this there are a number of steps you need to take since the partition s UUID changes The Ubuntu UUID documentation is a helpful reference Add the new UUID to etc fstab Add the new UUID to etc initramfs tools conf d resume This is what broke hibernate on my machine Update your initramfs so it can find the new swap UUID at boot sudo update initramfs u Optional Get udev to regenerate dev disk by uuid udevtrigger Optional Remove old unused entries from the blkid cache blkid g To learn more about how Ubuntu Gnome s hibernate and suspend menu items work see Debugging Gnome Power Manager This includes handy command lines for suspending and hibernating Using these commands is better than using pm hibernate directly because it permits applications like NetworkManager to take action before and after the suspend Wake on LAN Wake on LAN lets me save electricity while having access to my system at all times I can shut my system down then can wake it up when I want access Enable wake on LAN in your system s BIOS Add the following to the eth0 stanza in etc network interfaces to enable wake on LAN on your adapter at boot post up ethtool s eth0 wol g After a reboot or ifdown eth0 ifup eth0 you can run ethtool eth0 and you should see Supports Wake on g Wake on g Make sure your adapter is not turned off at shutdown by adding the following to etc default halt NETDOWN no Now shut down your system Your adapter should still be active check the activity light on the adapter or your switch You can then wake it from another computer on the same network with wakeonlan MAC address The part I

    Original URL path: http://www.evanjones.ca/ubuntu-tips.html (2016-04-30)
    Open archived version from archive

  • A Quick Guide to Confidence Intervals (evanjones.ca)
    you compute the mean μ and standard deviation s For N samples the degrees of freedom df is N 1 You then look up the t value for the value of df and the confidence interval you want from a t table or using the inverse t distribution CDF Finally you get a range μ ts sqrt N μ μ ts sqrt N A good explanation of how to compute confidence intervals can be found at HyperStat Computing the inverse of the t distribution s CDF is challenging as it requires careful numerical methods People do research on this kind of thing Excel contains a function TINV that does this for you Scipy contains scipy stats t ppf which is implemented by some Fortran code JSci is a Java library that has an implementation I ported this implementation to Python which surprisingly was less challenging than I expected My implementation uses the bisection method to find the inverse instead of the Newton Raphson method used in the original JSci code This requires more iterations for the same precision but saved me from having to port the PDF implementation which is the derivative of the CDF required for Newton Raphson My

    Original URL path: http://www.evanjones.ca/confidence-intervals.html (2016-04-30)
    Open archived version from archive