Ooh! My gu-uts, my guts.

Sunday, April 26

Cool

For Those Who Don't Care So Much About Benchmarking High-Level Languages Down To The Nanosecond...

More slightly creepy music videos.

Posted by: Pixy Misa at 07:33 PM | No Comments | Add Comment | Trackbacks (Suck)
Post contains 20 words, total size 1 kb.

Geek

Needs For Speeds

Testing various libraries and patterns on Python 2.7.9 and PyPy 2.5.1

Test Python PyPy Gain
Loop 0.27 0.017 1488%
Strlist 0.217 0.056 288%
Scan 0.293 0.003 9667%
Lambda 0.093 0.002 4550%
Pystache 0.213 0.047 353%
Markdown 0.05 0.082 -39%
ToJSON 0.03 0.028 7%
FromJSON 0.047 0.028 68%
ToMsgPack 0.023 0.012 92%
FromMsgPack 0.02 0.013 54%
ToSnappy 0.027 0.032 -16%
FromSnappy 0.027 0.024 13%
ToBunch 0.18 0.016 1025%
FromBunch 0.187 0.016 1069%
CacheSet 0.067 0.046 46%
CacheGet 0.037 0.069 -46%
CacheMiss 0.017 0.015 13%
CacheFast 0.09 0.067 34%
CachePack 0.527 0.162 225%
PixyMarks 13.16 40.60 209%


Notes
  • The benchmark script runs all the tests once to warm things up, then runs them three times and takes the mean.  The PixyMark score is simply the inverse of the geometric mean of the scores.  This matters for PyPy, because it takes some time for the JIT compiler to engage.

    Tests were run on a virtual machine on what I believe to be a Xeon E3 1230, though it might be a 1225 v2 or v3.

  • The Python Markdown library is very slow. The best alternative appears to be Hoep, which is a wrapper for the Hoedown library, which is a fork of the Sundown library, which is a fork of the unfortunately named Upskirt library.   (The author of which is not a native English speaker, and probably had not previously run into the SJW crowd.)

    Hoep is slower for some reason in PyPy than CPython, but still plenty fast.

  • cPickle is an order of magnitude slower than a good JSON or MsgPack codec.

  • The built-in JSON module in CPython is the slowest Python JSON codec. The built-in JSON module in PyPy appears to be the fastest.  For CPython I used uJSON, which seems to be the best option if you're not using PyPy.

  • CPython is very good at appending to strings. PyPy, IronPython (Python for .Net) and Jython (Python for Java) are uniformly terrible at this. This is due to a clever memory allocation optimisation that is tied closely to CPython's garbage collection mechanism, and isn't available in the other implementations.

    I removed the test from my benchmark because for large strings it's so slow that it overwhelms everything else.  Instead, append to a list and join it when you're done, or something along those lines.

  • I generally see about a 6x speedup from PyPy.  In these benchmarks I've been focusing on getting the best possible speed for various functions, using C libraries wherever possible.  A C library called from Python runs at exactly the same speed as a C library called from PyPy, so this has inherently reduced the relative benefits of PyPy.  PyPy is still about 3x faster, though; in other words, migrating to PyPy effectively turns a five-year-old mid-range CPU into 8GHz next-gen unobtainium.  

  • If you are very careful about selecting your libraries.  There's an alternate Snappy compression library available.  It's about the same speed under CPython, but 30x slower under PyPy due to inefficiencies in PyPy's CTypes binding.

  • uWSGI is pretty neat.  The cache tests are run using uWSGI's cache2 module; it's the fastest caching mechanism I've seen for Python so far.  Faster than the native caching decorators I've tested - and it's shared across multiple processes.  (It can also be shared across multiple servers, but that is certain to be slower, unless you have some seriously fancy networking hardware.)

    One note, though: The uWSGI cache2 Python API is not binary-safe.  You need to JSON-encode or Base64 or something along those lines.

  • The Bleach package - a handy HTML sanitiser - is so slow that it's useless for web output - you have to sanitise on input, which means that you either lose the original text or have to store both.  Unless, that is, you have a caching mechanism with a sub-microsecond latency.

  • The Bunch package on the other hand - which lets you use object notation on Python dictionaries, so you can say customer.address rather than customer['address'] - is really fast.  I've been using it a lot recently and knew it was fast, but 1.6us to wrap a 30-element dictionary under PyPy is a pretty solid result.

  • As an aside, if you can retrieve, uncompress, unpack, and wrap a record with 30 fields in 8us, it's worth thinking about caching database records.  Except then you have to worry about cache invalidation.  Except - if you're using MongoDB, you can tail the oplog to automatically invalidate cached records.  And if you're using uWSGI, you can trivially fork that off as a worker process.

    Which means that if you have, say, a blogging platform with a template engine that frequently needs to look up related records (like the author or category for a post) this becomes easy, fast, and almost perfectly consistent.  
more...

Posted by: Pixy Misa at 01:28 PM | No Comments | Add Comment | Trackbacks (Suck)
Post contains 1403 words, total size 15 kb.

Friday, April 24

Cool

A Brief Musical Interlude



Posted by: Pixy Misa at 12:17 AM | Comments (2) | Add Comment | Trackbacks (Suck)
Post contains 4 words, total size 1 kb.

Thursday, April 23

Geek

And Now For Something Educational

Ish.

Posted by: Pixy Misa at 10:39 AM | Comments (3) | Add Comment | Trackbacks (Suck)
Post contains 6 words, total size 1 kb.

Wednesday, April 22

Cool

LDW

Needs to happen.

more...

Posted by: Pixy Misa at 09:47 PM | Comments (2) | Add Comment | Trackbacks (Suck)
Post contains 29 words, total size 1 kb.

Life

Went Outside Today

Pepsi restocked.  Back to work.

Posted by: Pixy Misa at 02:03 PM | No Comments | Add Comment | Trackbacks (Suck)
Post contains 8 words, total size 1 kb.

Tuesday, April 21

Life

Uh-Oh

I just checked the fridge, and there's only one bottle of Pepsi left.  I might have to go outside.

Which might not seem to be much of an issue, except that where I live is smack in the middle of the biggest storm to hit the Sydney region in a decade.

Not the most violent, but in terms of covering a large area, dumping huge amounts of water over everything in sight, blowing down trees, and generally continuing to cause havoc for two full days so far, definitely the biggest.

I can't actually remember the Parramatta River (the main river flowing into Sydney Harbour) flooding before.  I'm worried about the Nepean River, which is where we usually get major flooding in weather like this.  (Miles and miles from where I live, but the one place we do get significant flooding in Sydney.)

Posted by: Pixy Misa at 11:49 PM | Comments (6) | Add Comment | Trackbacks (Suck)
Post contains 143 words, total size 1 kb.

Cool

In Space

Perhaps the most subtly dramatic space photo I've ever seen.

/images/SamCristoforetti.jpg?size=720x&q=95

Posted by: Pixy Misa at 02:38 PM | No Comments | Add Comment | Trackbacks (Suck)
Post contains 12 words, total size 1 kb.

Tuesday, April 14

Cool

Cities: Raillines

Actually Cities: Skylines with a couple of mods from the Steam Workshop.  The interesting thing is that Cities: Skylines was never designed to do this at all; rather, it was designed so that inventive users could customise it.

And they did.

Posted by: Pixy Misa at 10:13 PM | Comments (3) | Add Comment | Trackbacks (Suck)
Post contains 43 words, total size 1 kb.

Sunday, March 29

Blog

Sorry About The Site Glitches

Our statistics database filled up. This wasn't immediately obvious from the logs, and since it was due to a size limit being set too low rather than running out of server resources, it wasn't obvious from the state of the server.


It's been addressed now, the server processes have been restarted to clean up any hung connections, and all should be well with the world.

Posted by: Pixy Misa at 10:40 AM | Comments (13) | Add Comment | Trackbacks (Suck)
Post contains 70 words, total size 1 kb.

<< Page 2 of 375 >>
70kb generated in CPU 0.04, elapsed 0.0944 seconds.
54 queries taking 0.0647 seconds, 278 records returned.
Powered by Minx 1.1.6c-pink.