Posts Tagged ‘osx’

Installing Nginx-GridFS on OSX

Wednesday, October 7th, 2009

Follow these steps to install mdirolf’s GridFS module for NginX on OSX. Linux coming soon.

cd ~/src # your sources directory
mkdir nginx_gridfs && cd nginx_gridfs
git clone git://github.com/mdirolf/nginx-gridfs.git  
wget http://sysoev.ru/nginx/nginx-0.7.62.tar.gz
tar -zxvf nginx-0.7.62.tar.gz
 
sudo port install boost pcre++ spidermonkey scons # macports!
 
cd nginx-0.7.62/
 
# i put mongodb at /mongodb - alter to fit your installation
export MONGO_INCLUDE_PATH=/mongodb/include/mongo/ 
export LIBMONGOCLIENT=/mongodb/lib/libmongoclient.a
export BOOST_INCLUDE_PATH=/opt/local/include/
export LIBBOOST_THREAD=/opt/local/lib/libboost_thread-mt.a
export LIBBOOST_FILESYSTEM=/opt/local/lib/libboost_filesystem-mt.a 
export LIBBOOST_SYSTEM=/opt/local/lib/libboost_system-mt.a 
 
./configure --add-module=/Users/sho/src/nginx_gridfs/nginx-gridfs
make
sudo make install

In nginx.conf:

server {
    listen       80;
    server_name  localhost;
 
    location / {
        root   html;
        index  index.html index.htm;
    }
 
    location /gridfs/ {
        gridfs;
        gridfs_db database-name;
 
        # these are the default values:
        mongod_host 127.0.0.1:27017;
        gridfs_root_collection fs;
    }
 
    # blah
 
}

You should now be able to start nginx using /usr/local/nginx/sbin/nginx and navigate to 127.0.0.1/gridfs/#{file_name}.

UPDATE: for snow leopard, python is in /usr/bin, so you may need to symlink it like this for scons to find it:

$ sudo ln -s /usr/bin/python2.5 /opt/local/bin/python2.5

Also, nginx is updated to 0.8.30 now; these instructions work for the latest version too.

UPDATE 2: Currently the best version of this to use is my branch, which simply pulls together a number of different patches to make a working version. Well, works for me, anyway!

Shockingly bad memory performance under Snow Leopard

Monday, October 5th, 2009

I don’t know what caused it, but sometime after upgrading to Snow Leopard the performance of my laptop has dropped through the floor. It’s really bad, especially with video – this 2yo mac can’t play a youtube clip without CPU going to 100% and jerking unwatchably.

I’ve been busy so hadn’t had much chance to investigate, but one thing or another led me to suspect memory performance, so today I ran Xbench. As you’ll see, the results speak for themselves.

Memory Test 15.31

System 23.78

Allocate 116.31 427.14 Kalloc/sec
Fill 70.52 3428.64 MB/sec
Copy 9.67 199.83 MB/sec

Stream 11.28

Copy 10.55 217.93 MB/sec
Scale 10.50 216.93 MB/sec
Add 12.76 271.83 MB/sec
Triad 11.61 248.39 MB/sec

That is shockingly bad and a full order of magnitude lower than expected. There’s something seriously wrong here.

The ram is 2×2GB Kingston 667MHz. It was working fine before and continues to work, just 10x slower than it should. Any ideas?

update: i’m going to list some details to make it easier for others with similar issues to find this post by search.

ram details:

BANK 0/DIMM0:

Size: 2 GB
Type: DDR2 SDRAM
Speed: 667 MHz
Status: OK
Manufacturer: 0×7F98000000000000
Part Number: 0×393955353239352D3031312E4130304C4600
Serial Number: 0×160AA70D

BANK 1/DIMM1:

Size: 2 GB
Type: DDR2 SDRAM
Speed: 667 MHz
Status: OK
Manufacturer: 0×7F98000000000000
Part Number: 0×393955353239352D3031312E4130304C4600
Serial Number: 0×160AE80F

system details:

Model Name: MacBook Pro
Model Identifier: MacBookPro2,2
Processor Name: Intel Core 2 Duo
Processor Speed: 2.33 GHz
Number Of Processors: 1
Total Number Of Cores: 2
L2 Cache: 4 MB
Memory: 4 GB
Bus Speed: 667 MHz
Boot ROM Version: MBP22.00A5.B07
SMC Version (system): 1.12f5

UPDATE: removing one of the 2GB modules returns speed to normal:

Results 126.95
System Info
Xbench Version 1.3
System Version 10.6.1 (10B504)
Physical RAM 2048 MB
Model MacBookPro2,2
Drive Type FUJITSU MHW2120BH
Memory Test 126.95
System 145.21
Allocate 274.47 1.01 Malloc/sec
Fill 111.52 5422.41 MB/sec
Copy 124.24 2566.05 MB/sec
Stream 112.77
Copy 104.49 2158.22 MB/sec
Scale 106.87 2207.96 MB/sec
Add 121.81 2594.72 MB/sec
Triad 119.98 2566.73 MB/sec

This machine is actually only able to address 3GB of memory; previously it ignored the other 1GB without consequence. Seems it might not be without consequence anymore.

Sucks to only have 2GB of memory but the system is now so much more responsive it’s actually a huge win. I’ll continue like this until further information emerges.

CPU History

Monday, September 21st, 2009

Like having a running graph of CPU usage in your dock, but hate Activity Monitor’s 10%+ overhead?

Try CPUHistory, an ultra-lightweight replacement which uses more like 0.3%. Great stuff.

Snow Leopard Review

Friday, August 28th, 2009

I’m actually delighted with Snow Leopard. It’s really noticeably faster, especially Finder. And a terminal crash bug I experienced hasn’t re-occurred in a week of constant use, hopefully making it a weird once-off, an artefact of the upgrade.

But this has happened about 10 times now:

Snow Leopard

I wonder if I should have performed a clean install. Oh well, that is always an option should it be necessary. I wonder if it is possible to just re-index mail or something? It is happening when Mail.app saves a draft. Hm, now my suspicious eye turns towards the Drafts folder.

Thanks to commentors for pointing out they have not had problems, I am happy the OS is being received universally well – all I need is to fix this one thing!

UPDATE: Nuking my old drafts folder seems to have completely solve the problem.

UPDATE 2: That didn’t actually solve the problem; it crashed several times since then. However, 10.6.1 has really solved the problem, and I am now as happy as Larry.

The 10A435 screenshots are fake

Sunday, August 23rd, 2009

The recently circulated screenshots of Snow Leopard build 10A435 are almost certainly fake.

This section of the Quicktime Preference menu looks copy/pasted to me:

Quicktime X Menu

Note the anomaly in the antialiasing in the drop shadow on the left edge. Here’s a zoom:

Zoom of Quicktime X Menu

Looks fake to me. The “Preferences” item has been pasted in from another application, and the lower half portion of the original menu pasted below it, creating the mismatch – the background is darker above, where it was copied from. There is no other plausible explanation for that anomaly in the drop shadow.

Nice try!

Of course, this strongly implies that 10A432 is indeed the GM, for better or worse. It’s surprisingly rough around the edges, but hopefully they can polish it up a bit quickly.

Compiling PowerDNS on OSX 10.5.7

Wednesday, June 24th, 2009

Want to play with PowerDNS? On a Mac? You’ll need to do something like this. Make sure you read all the way to the end before continuing.

1. Download boost from sourceforge. The link for the version I used, 1.39.0, is here.

2. Extract the file somewhere. Mine was just in downloads.

3. Download and extract the source (at the top) of PowerDNS. I used version 2.9.22, from here.

4. navigate to the PowerDNS directory and execute the following commands. Change the reference to MySQL to something relevant to your local copy:

$ CXXFLAGS=-I/Users/sho/Downloads/boost_1_39_0 ./configure --with-mysql-includes=/usr/local/mysql-5.0.45-osx10.4-i686/include
$ make
$ sudo make install

That’s it! Built and installed perfectly. Now run pdns_server, and watch it fail with Cannot create semaphore: Function not implemented, because OSX is not fully POSIX compliant. Now wasn’t that a great way to waste time? I certainly thought so. Told you to read all the way to the end.

What’s holding open that port on OSX

Tuesday, June 23rd, 2009

Since I always, ALWAYS forget this, here’s the command to find the process which is holding open, say, port 1900 on osx:

$ lsof -i -P | grep 1900
uTorrent  50937 sho   13u  IPv4  0xaf49b10      0t0    UDP 10.1.1.8:1900

Fucking uTorrent, why the hell is it sitting on 1900? That’s the SSDP/UPnP server-side port, ie. the router should be listening on 1900. Unless it’s planning on advertising SSDP services it can provide, it doesn’t need that port. Wonder what it’s doing.

Oh btw it only shows your processes, sudo if you wanna see ‘em all.

Senuti goes payware

Saturday, February 28th, 2009

Sigh. Another one bites the dust. As of version 0.50.3, Senuti, the popular iPod retrieval program, has gone payware, despite previous versions being GPL-licensed. The Google Code repository has disappeared.

I can’t really get angry at the author, although the temptation is there. I haven’t paid him a cent. He can do what he likes really. He’s obviously put a lot of work into the software, who could blame him for trying to get some reward for his efforts? It was licensed under the GPL, though, and it’s extremely bad form to “disappear” it. I don’t have a copy of the source, so I can’t distribute the 0.50.2 binary I have.

This pisses me off, yes – but it’s not even really anything to do with Senuti. It’s the fact that I can’t copy songs off MY FUCKING IPOD that I OWN. While there was a free program that worked so well, it was easier to ignore. Now that program demands payment and Apple’s contempt for its paying customers is rubbed in my face.

I hate this fucking shit, and the worst thing is that there’s no current acceptable alternative to iTunes/iPod. Maybe soon. Anyway, I will hang on to my copy of 0.50.2 until it stops working – no doubt, planning commercialisation, the author slipped a cutoff date in there somewhere.

For reference, the sha1 hexdigest for the last free release of Senuti (senuti_0.50.2.dmg) is b7c4121e5fbdd96aae1a483311d0fb7ea1915689.

Update: It is somewhat possible the author of Senuti is in breach of the GPL (Senuti uses several GPL libraries – gtkpod (corrected – it’s actually the LGPL libgpod, thanks Wincent) and Adium (stripped from latest distribution) for starters).

Update 2: It seems the offending GPL libraries have been stripped from the current payware distribution, possibly making the software able to be legally distributed after all. All contributors have been removed from the About screen of the new version and the Adium library has disappeared. Still pretty sleazy, but probably not illegal.

Leopard

Wednesday, October 31st, 2007

My leopard upgrade experience was extremely positive. Thankfully, I didn’t experience any of the difficulties some have had – this account by the veritable Wincent Colaiuta filled me with dread, but thankfully none of his woes were visited upon me. I was cautious about upgrading, and waited a couple of days so that early bugs could be found by early adopters, I’m glad that I did, since I did have APE installed (although by what, I have no idea) and I made sure to run disk utility’s repair function on the install disk before attempting the upgrade.

That said, there are a few observations I’ve made:

Mail 3.0

I decided to do a clean install of Mail, since most of my “archive” mail is still sitting on a machine in Japan, and all messages in the local instance of Mail were kept on the server. I also decided to use this opportunity to switch to IMAP exclusively.

The IMAP imports went well, though took an awfully long time, during which Mail.app refused to quit.

I imported my RSS bookmarks from Safari, since I’d prefer to not be distracted by them during web usage. The import went well, though updates of the feeds seem unreliable and it sometimes takes a couple of restarts to “force” an update. Another unexpected behaviour of RSS in Mail.app is its desire to automatically download all attachments in an RSS feed – leading to quite a surprise as it proceeded to start downloading every single railscast from the entire railscast feed, well over a gig of movies, and refused to quit while in process. I had to force quit mail and delete the Railscast archive to avoid the massive, and slow, download.

MacPorts and custom compiled software

I switched to MacPorts some time ago, reducing the need to custom compile software and, more importantly, eliminating (in theory) the dependency hell that custom compilations can sometimes launch you into. I decided to take the opportunity to nuke /opt and reinstall from scratch – the old repository was, well, old, and I was getting the occasional weird error from the still very much in development macports software.

But now – I have a problem. Apple’s taken the laudable step of upgrading the version of ruby installed with the OS. They’ve got a new build of subversion in there too, and even included rubygems – and Rails! What to do? For example, there are two good ways to install MySQL on this system – port install mysql-server, or download and install the binary. Because I wanted to go with Apple’s pre-install of ruby and rubygems/rails, I thought it maybe better if I installed the binary version. But then gem install mysql, for the native ruby mysql bindings, bombs out. Great, dependencies – exact what I’m trying to avoid, and so early in the customisation process, too!

Anyway, for now I am using the Apple installs, mindful of the possible need in the future to just go ahead and port install duplicates over the top of the bundled software. Furthermore, Ruby 1.9 is supposedly around the corner. What will be the recommended upgrade path then?

I can’t really work out why Apple isn’t going with MacPorts officially here. The project is amateur, but it’s certainly “blessed” by Apple – so why not build it into the OS? There are now 3 ways to go installing a lot of open source software on MacOSX – use the included but rapidly outdating and dependency-locked installs, install manually from source, or use the supposedly official MacPorts package management system. All three leave software in different places. Which one gets used will come down to your $PATH. It’s not exactly elegant, and seems like a recipe for hard-to-troubleshoot problems in the future.

That said, I got everything up and running with no real problems, although postgresql refuses to build in the current Port incarnation.

Interface

A lot of what I think about the interface has already been written in the unbelievably long ArsTechnica review of Leopard, but I’ll save you the 2 hours reading that and list my general thoughts:

  • I don’t like the unpredictable, uncustomisable, ugly icons of the new “collection” folders in the dock.
  • I don’t like the loss of the “drill down” folder browsing mode
  • The new dock wastes space and is gratuitous in its eye candy – eye candy which is, if anything, functionally inferior to the preview incarnation
  • I don’t mind the new translucent menubar

Favourite App updates

Safari, Terminal and Mail are hugely improved, and I think this will make most of the positive difference in my daily work with the OS. I like Spaces, too. Spotlight is also much, much better – basically, Spotlight in Leopard is what it should have been all along, which allows me to jettison QuickSilver.

to be continued ..