Release incoming, believe it or not

So, I was working away at SMR, debugging the new implementation, then work became ultra busy for a long time (like, minimum twelve hour days) and I lost my mental state.

What I’ve decided to do for now is strip out the SMR stuff, and the benchmark tool, *and just get a release out*.

I’ve just done the necessary and the test application has just passed under debug.

I no longer have access to an ARM platform, but I’ve ordered (tried to order – Amazon foiled my best efforts) a quad-core Pi, and I’ve applied to the GCC compile farm, to get access to 64 bit ARM and POWER.

So for now, it’ll be Windows and Linux, 32 bit and 64 bit, user-mode and kernel-mode. The Linux build in theory works for Android too, but not tested – I’ll set up a build platform for that, but not yet.

So now – I need to make everything build and pass its tests on all platforms, polish the code (need a good polish – been so much work everywhere for so long) and then write the docs.

Amazon rejects Tor Brower, with a certain (inadvertant) prejudice

Bloody Amazon.

I’ve moved over fully now to Tor Browser.

I order a Raspberry Pi, to use for the 32 bit ARM platform.

Hour or two later, in bed, an email – suspicious activity, password cleared (you’ll need to reset it), all pending orders cancelled.

I swear and go to sleep.

Morning. Reset email. Find there’s no record of the order, half of which was made up of specific items with serial number I hunted up on the web and no longer have. Replicate work done. Re-send order.

Four hours later, an email – suspicious activity, password cleared (you’ll need to reset it), all pending orders cancelled.

I contact Amazon.

The guy tells me he needs to issue an “account reopen” form and it’ll take one to two days.

I explain I had already reset my password and that had worked just fine.

He says, and I quote, “that is the reason why we need to use the account reopen form”.

I explain to him about Tor and that I want Amazon to stop fubar-ing my account because my IP looks odd.

He looks into it and tells me yes, it’s likely to be Tor, and no, there’s nothing we can do about it, asks me if there’s anything else and moves to end the chat.

In the meantime, I try resetting my password again.

I can reset it – but I *can’t* log in.

I tell him.

He says “yes, this is why we need to use the account reset form”.



So – Amazon reject orders made via Tor, and with some (inadvertant) prejudice – try it twice and you’re locked out of your account for a day or two.

Firefox has jumped the shark

For reasons arcane I am setting up a Windows VM, and I’ve just come to install the latest Firefox.

I have discovered that firefox now installs, by default, a permanent background process which nominally at any rate automatically updates the browser.

However, FF can just as well perform this check when it runs. There is no need – no justifying need – for it to have a *process* permanently running on a machine. I am *very* much of the view that it is incredibly suspect for any on-demand application to attempt to get a *permanent* process running, and that it is doing so for reasons other than actual practical need. Realview comes to mind – remember them? Skype does this too, as does Google with its Google Talk plugin, and Oracle do this with Java. You’re in bad, bad company, Firefox.

It gets worse. FF has just started up. The init screen is “Sign in to Firefox and you’re good to go” – and this is present as a MANDATORY step. There is NOTHING to indicate this is optional and everything about how it is done makes it look to the user like this is the next, mandatory step.

My stomach is turning over. This is disgusting. Repellent. This is what I expect and experience from Google.

Man, Firefox is out now. Slow and bloated was bad but not terminal – but this? I won’t use Chrome for the same reasons I won’t use Firefox; an unmet expectation of decent, honourable conduct. You know as well as I do they are if you log in recording against your account all of your on-line browsing; and I wonder now if all browsing is being recorded anyway, just not against an account, if not logged in?

I need to install a firewall on my machine so I can monitor outgoing traffic – rather than defend against incoming traffic!

So, the others. Chrome – ha ha ha. IE is the pits. Chromium, maybe?

(Addendum. On install, I unchecked “make FF default”. I see now having installed not only has FF been made default, but it also checks to see if default on every start. I had this fucking problem before from one of the big dodgy companies too – Skype I think it might have been – it would royally ignore the default setting you picked during install. You’d think it was just incompetence, but it feels like arrogance or even intentional evil – I mean, I’m installing here on a brand new default Windows 7 install. Any quality control worth a dime would have found this. Reminds me of MS and the Windows 98 uninstaller being broken and they never noticed).

(Addendum two. Turning off browsing history in FF now requires a browser restart. That’s new. What have they been doing now with tracking/recording your browsing so that this restart is necessary?)


Some acquaintances are making a trip and posting pics and short videos on Instagram. I wanted to support them a bit, and was going to make a burner account and post a video.

Well, huh – turns out to *create an account* you need to *install an app on your phone*. You can’t make an account just on the web-site.

Installing an app – that’s so far off the map that I’m horrified and appalled it’s mandatory, because it’s rapacious. An app is a license to spy. It’s not a web-browser, where you can wipe the cookies; it’s a binary, which most likely is configured to run all the time, running on your personal portable self-monitoring device, which can report the hell it likes back to the mothership.

And you gotta install this, bro, to get an account.

Paypal and the sharp pain in my head

Sequence of evets;

1. Ebay
2. Buy now
3. Paypal
4. Checkout as guest
5. Fill in shipping address
6. Fill in card details
7. Fill in billing address

Hit submit.

“Cookies are off.”

Why in the name of all that’s holy with THIRTEEN THOUSAND EMPLOYEES could you not tell me that BEFORE I HAVE COMPLETED THE ENTIRE BUYING PROCESS.

So then it became interesting. I had already tried to order once before and bailed, because I had seen I was paying sales tax – so I hunted down the retailer, which has its own site, checked it was in NJ, and so this time when I was ordering via Ebay/PP I was shipping to work in NY.

So I now given PayPal’s poor web-site behaviour wanted to buy directly – screw PP. They do *not* get their margin from this transaction from me after that!

I found the item on the retailers own site. It’s the same item – I think it the same actual stock item which is on sale in Ebay, because both on Ebay and the site it says “one left”. On Ebay, 95 USD. On the site itself, 78 USD.

Is that an Ebay/PayPal premium? like, I’m paying *extra* for this experience?

SMR design

So, I wanted to write down the new SMR design.

First, an SMR state is instantiated. As usual, you can have as many as you want, they’re independent. Each thread which is using an SMR state has its own SMR thread state. That SMR thread state is associated with a single SMR state (by a function call).

Threads typically use lock-free data structure APIs, to perform their lock-free work which is using SMR. When such an API function is called, the thread passes in its SMR thread state (this contains a pointer to the SMR state it is associated with).

When a data structure begins some lock-free work (popping from a freelist, etc) it calls a macro to enter a lock-free section, and when it’s done, it calls another macro to leave the lock-free section. These macros set state in the SMR thread state. As such, we know when a thread is in a lock-free section (the entry flag is raised, the exit flag is not) and we know if the thread has been idle since we last looked at it (both flags have not changed).

The SMR API functions which perform the SMR work are manually called by the user; they are not called behind the scenes.

There are two SMR API functions for performing work. The first tried to advance the generation counter (more on this below); the second releases all releasable allocations for the calling thread.

The SMR state maintains a generation counter. This begins at 0 and wraps (unsigned int; we do the necessary math to handle when we wrap).

When an allocation is submitted to SMR (which is to say, has exited a data structure and now we need to know no threads are pointing to it), the current generation counter is recorded.

When the user calls the function to try to advance the generation counter, the function examines the SMR thread state for every thread associated with that SMR state.

If since the last examiniation every thread has either been idle, or has exited one or more lock-free sections, then we know that every allocation with an earlier generation count cannot be pointed at by any thread – as such, we advance the generation counter.

When the user has a thread call the other SMR API function, it scans the allocations submitted by the current thread to SMR and if their generation count is older than the current count, releases them.

That’s the broad overview, and it hasn’t changed.

What’s new though is that I’ve made changes to make the first SMR API functon (advancing the generation counter). This function needs to allow foward progress for any thread calling it – i.e. no matter what other threads are in this function, no matter what state it is in, when a new thread comes to it, it needs to be able to complete the operation and advance the generation counter.

To achieve this the function now has two stages; setting and clearing. In the first stage, setting, the work being done is scanning the SMR thread states to see if they have all been idle or exited a lock-free section. When this is found to be so, the generation counter is then advanced, and the function moves to the second stage, clearing, where it revisits the SMR thread states and updates the information they contain (lowers the flag for having exited a lock-free section, etc).

Part of implementing this means that the generation count and the flags are now in the same word, so they can be atomically set together; for when in the settings phase we check an SMR thread state, we need to be sure we are checking the flags for the expected (and so correct) generation in the SMR thread state.


Made the new SMR compile.

There’s an outstanding design issue, which is how to handle new threads, since they will not have the correct generation count.

I know basically what I’m going to do – there will be a flag, one of the bit in the generation count / flags word, which indicates a new thread, and it’ll get special handling.


Bringing on the MongoDB rage here.

I’ve just spent an hour – wasted an hour – due to really, really bad interface design, and a lack of documentation. Those are *bad* reasons to spent time on a problem.

The default port for “mongo”, the command line client, is 27017. However, if you have a replica set, your mongo servers are also running something called “mongos”, which handles replication, inter-node communication.

It turns out on the server I have mongos is running on port 27017, and MongoDB on port 27018 – and it also turns out if you fire up the command line client again a mongos server, *it will connect*… only the commands you then try and run, which work when you’re connected to a MongoDB, fail with error messages like “can’t use local on mongos”, and Googling for this finds nothing useful.

So, basically, there’s this fake mongodb-a-like server running on your system which you can connect to and issue commands to and they all fail with errors which don’t explain the problem (unless you already know what the problem is).

This remins me of the Samsung web-site. For quite a long time, they had *two* web-sites for drivers, one real and up-to-date, the other old and not maintained, and Googling would lead you to the old site, where you would then scratch your head, wondering where the hell the drivers were for your new phone.

This isn’t the only problem I’ve had with MongoDB. I came earlier to set up a replica set. The intructions on their site *do not work*. Just do not work. D O N O T W O R K. I had to Google the necessary to configure the set.

I would say MongoDB is quite a bit above average in terms of docs for an open source project. There is at least a doc page for every command, even if the content is minimal. This is why for production work I avoid all but the most mature open source projects. The actual experience of trying to use open source in general typically is problematic, and utterly outweighs any advantages you might be obtaining.

Linux’s email server config is C’s function pointer declaration syntax

The worst part of Linux is setting up email servers.

A long time ago, I set up postfix and dovecot for the first time. It took a week.

Now, years later, I want to add a new system user (“alerts”) and have him receive email.

The postfix part was fine – got it right first time and it worked; it’s just another virtual email address, after all.

The dovecot part?

Not so good. I’ve tried for an hour and I’ve *given up*. There’s an error about “permisson denied” and utterly unhelpful. Googling reveals half-a-dozen contradictory solutions, where those I did try made no difference whatsoever. It is not reasonably possible to figure out complex systems without error information or meaningful documentation, which is every single bloody Linux email server in one sentence.

SMR design flaw and improvements

So, the freelist rapid push/pop test, using SMR, revealed an SMR bug, which in turn revealed the changes I made to the SMR function for advancing the generation counter, such that that function became multi-threaded (rather than being a critical section bounded by CAS flag) were broken.

What I’ve come up with now instead is the idea that there is a “setting” phase, where threads set their SMR state flags, and then when a thread sees that the generation counter can be advanced, we then have a “clearing” phase, where threads calling the generation-advance function act not to check to see if the generation counter can be advanced, but rather they check to see if all the per-thread flags have been cleared, so that we’re then in the correct state for threads to start the work again of indicating the SMR state so we can again see if the generation counter can be advanced.

The whole point of all this is to ensure any single thread entering the check function can make forward progress – before, this was not the case. I think the design is sound, although I’ve not yet implemented, because…

…I’ve realised in the course of this there is a design flaw, and I’ve not yet resolved it. The handle idle threads, I have it so that when a thread enters a lock-free section, it sets a flag – “LOCK_FREE_IN_PROGRESS” – and lowers that flag on exit. Design flaw is that the code only uses a store barrier, so there’s no guaranteee that flag is visible to other threads (who have issued a load barrier) until an atomic operation is performed – which typically occurs in the act of *performing* the lock-free work being done, i.e. *after* we’ve read in and are using sensitive memory addresses.

Any real SMR has to support idle threads, so I have to think of a solution.

Two steps forward, one step backwards, the mantra of all lock-free design work 🙂