Elixir, Phoenix and Windows: Some insights on my 1000┬Ás problem

On Saturday I wrote about “Elixir, Phoenix and Windows: No faster responses than 1000 microseconds?“. I described two problems I had with Phoenix in Windows: My response times seem to be stuck at 1000 microseconds and Powershell couldn’t display the μ sign. I dug into some code and the mailing lists and found (with a lot of help) some answers.

1000 Microseconds on Windows?

The response times in Phoenix are often measured in Microseconds. Yet on Windows you won’t see any requests faster than 1000 Microseconds. That’s not because of a slower OS, but a not as precise as needed timer:

On Windows a developer has several options to get the system time. According to windowstimestamp.com there are (including the precision):

  • The time service (1 ms)
  • The performance counter (between 1 ms and 1 μs)
  • The GetSystemTimeAsFileTime API (100 ns)

The highest precision (100 nano seconds) can be achieved with the GetSystemTimeAsFileTime API (or the GetSystemTime API, which is the same data but differently formatted).

Actually this is the API  the Erlang VM (which provides the run time for Elixir and Phoenix) is using. So in theory we should be able to get more precise data out of these API. Yet the Erlang VM only returns millisecond as smallest unit. I’m pretty there are reasons for it, but I don’t understand them. If you are curious (and don’t fear a little bit C code) go ahead and look at the implementation of the timing in Erlang: sys_time.c in Erlang VM

1000┬Ás instead of 1000μs?

The second problem I had on saturday was the missing μ sign in my Powershell environment. I got hinted that I have to set the code page of Powershell to UTF8:

This fixed the problem for me. Unfortunately this introduced another, more grave bug to me: On putting out special characters in iex.bat, iex now fails to react completely. Until this bug is fixed, I strongly advise against this fix.

Elixir, Phoenix and Windows: No faster responses than 1000 microseconds?

If you read around phoenix developers you often hear stuff like “Awesome, requests served in under xxx microseconds!”. Yet if I try the Phoenix framework, I only have this results:

With special emphasis on [info] Sent 200 in 1000┬Ás . Here we have two problems:

  1. It looks like the command line doesn’t know the μ sign and replaces it with ┬Á.
  2. Did it really take 1000 microseconds to serve the request? I’m not sure, but I NEVER have a request faster than that. Sometimes I have a slower request (163 milliseconds on startup for example) but never faster than 1000 microseconds.

Locating the error source

Lets find the culprit: I use the Powershell to start the Phoenix app. Can Powershell show the μ sign?

Powershell using the μ sign
It can!
Powershell showing off and uses the the μ sign as variable name
Variables with the μ sign are possible as well

As a matter of fact, you can use the μ sign as variable, if you want to.

So Powershell is good. What’s the problem then? Looking into the mix.ps1 we can see that it executes the mix.bat, which executes the elixir.bat which either executes erl.exe or werl.exe. So lets have a quick look if the cmd (*.bat files are executed by cmd) is capable of the microsecond sign.

Also the command line is can show the sign
Also the command line can show the sign

So the problem isn’t the command line either. I printed the final executed call to erl.exe and executed this command without the cmd as middle man. The problem remained. So I assume it is a problem with either the erl.exe (if I use the –werl command line switch, werl.exe gets executed, the phoenix app gets started but no info is shown in werl.exe), Elixir, Phoenix or some of the plumbing in between.

Lets test Elixir. I created a new Elixir app mix new micro_second_test  and wrote a single function in it:

When starting the application with iex.bat -S mix  and executing the function we get this result:

So we can rule out Phoenix as Elixir already has that problem. What about erl.exe?

Erlang can show the μ sign. So the culprit is either Elixir or the plumbing. I will open an GitHub Issue for this problem. For the second problem (never showing less than 1000μs) I am not sure how to check. I think it could be in the cowboy web server, or in the Plug.Conn. But I have no clue…

Elixir, postgres and chocolatey

You try to use the phoenix getting started guide on windows and the task “mix ecto.create” fails with an useless error? Chances are your postgresql database isn’t available with the ecto default credentials “postgres”:”postgres”. Try to logon to the database with the credentials “postgres”:”Postgres1234″ and change the password for the user to “postgres”. Also, don’t forget to change the password of the Windows user “postgres”.

Update 15.11.2015: You also have to change the logon information for the service, otherwise postgresql won’t start after an restart.

Long version

If you happen to start with elixir and phoenix you will probably install postgres at some point. If you also happen to use Windows AND are a user of chocolatey (which you should be!) it could happen that you run in a nasty, not very helpful error message when you try to use the phoenix getting started guide on the mix task:

The error states exactly nothing:

Which is not that helpful. Because of the error message you can’t exactly google for that particular error. (I mean, yeah you could look the codepoint up but… really?)

Because the ecto tasks failed and ecto is the database mapper, I tried to connect to my recently installed postgres database. Which immediately made my mistake clear: ecto expects an user “postgres” with the password “postgres” for the database connection. But these credentials didn’t work!

I tried to find the default password for postgres (“postgres” being the only answer I found) but failed after a quick googling. So I uninstalled the postgres package via chocolatey

from my computer (which unfortunately didn’t work… I deleted the folder afterwards :-/ ) and reinstalled it.

On the installation log I found the default password afterwards:

I logged on to the database and changed the password:

Afterwards I changed the password for the windows user, “postgres” created on the installation accordingly.

Now the mix task works as expected.

Windows 7 – HowTo change system HDD to SSD (With built in tools only)


  • Current Laptop or PC
  • New SSD
  • External Harddisk (for backup, so it’d better be fast and big)
  • One empty DVD (or the recovery disc)
  • Bunch of screwdrivers


  • Shrink your HDD partition to a size smaller than the SSD (*)
  • Create a recovery disk
  • Create a system image with Windows backup on the external Harddisk
  • Replace your HDD with the shiny new SSD
  • Boot with recovery disk
  • Choose to restore from a system backup

(*) The first part is realy important. I ran in a nasty trap when I changed my disks: I shrunk my system partition to fit on the SSD, but while I recovered, the recovery tool told me there wasn’t enough space on my target disk. The problem was my own lazyness: I created a new partition on the HDD where I moved all the not needed files.

The system backup tool tries to recover your whole system, not only your system partition. So be sure that all partitions on your HDD in sum aren’t bigger than your SSD

HowTo shrink the partitions: microsoft.com

HowTo shrink if there are “unmovable” files: brandonchecketts.com

Setting up Wifi on Ubuntu 12.04 Server via command line (yeah, finally some technical stuff )


Setting up a wireless adapter on Ubuntu server 12.04 LTS via CLI isn’t THAT easy. Plug’n’Play doesn’t simply work. Good thing there is Google. And a lot of helpful sites.


Insert the stick (or boot with it) and connect automaticly to the preferred network

Continue reading Setting up Wifi on Ubuntu 12.04 Server via command line (yeah, finally some technical stuff )

Improve energy consumption with Ubuntu and Lenovo IdeaPad Z370 (sandy bridge-chipset)

Update 2015-03-15: As Antiplex mentioned in the comments, the resources are slighlty out of date. An update is pending

I use my laptop (Lenovo Z370, with Ubuntu 11.10) a lot in the college. Unfortunatly there aren’t enough plugs in the wall for all students and I’m not willing to bring a plug board with me every time. So my approach to the problem was to improve the energy consumption of my laptop. I already had an energy plan with display dimming after two minutes and deactivate bluetooth by default (I don’t have any bluetooth gadget, so why bother).

Continue reading Improve energy consumption with Ubuntu and Lenovo IdeaPad Z370 (sandy bridge-chipset)

Backspace in Firefox and Linux

Anyone who is used to firefox under windows (and probably mac) is also used to the backspace key. under windows, firefox will go one page backwards if you hit backspace.

Under Linux if you hit backspace, there happens… nothing. Which is disgusting.

I found a website (german) which describes how to change the behavior:

Continue reading Backspace in Firefox and Linux

How to install HandBrake on Ubuntu 11.10

If not already happened: Install the synaptic package manager (search for synaptic in the Ubuntu software center)

Download this package according to your architecture. If you are not sure which architecture you need, try amd64 or i386. This are the two most used architectures.

Install the package by double clicking.

Open a terminal and execute sudo add-apt-repository ppa:stebbins/handbrake-releases

Open synaptics package manager, go to preferences / package sources / other software. There should be two entrys like “http://ppa.launchpad.net/stebbins/handbrake-releases/ubuntu”. Mark the first one and click on “change”. Alter the distribution code from “oneiric” to “natty”. Do the same for the second entry. Apply the changes

Back in synaptic, click on reload. Now you can search for handbrake in the package search


Ubuntu 11.10 + Lenovo Ideapad Z370

Two days ago I’ve updated Ubuntu to 11.10 and it worked well.

I started from scratch, so I won’t have to deal with “old” problems:

Here is my setup:

  • Plain vanilla Lenovo Z370
  • Harddrive was replaced by a 60 Gb Sata2 SSD
  • Ubuntu 11.10 (Desktop edition)
  • I installed the IdeaPad Driver Package (get it here) to get rid of a lot of the “Keycode 240”

On the pro side:

  • The sd-card reader works out of the f**king box!
  • The key manager works!
  • Fn + F1 = Suspend to ram!
  • Fn + F2 = Switch the Backlite off
  • Fn + F5 = Switch all wireless connections off
  • Fn + F8 = Activates Num “block”
  • Fn +F9-F12 = Media keys (Play, Stop, Next, Previous) tested in Banshee
  • Fn + Arrow left + Arrow right = Louder and quiter

On the down side:

  • Special keys 1-3 kill the deskop
  • Special keys 4-5 didn’t work
  • Frequently sended “keycode 240” interupts the standby
  • Fn functions:
  • Fn + Esc = Nothing happens (should disable the camera)
  • Fn + F4 = No function (should do …)
  • Fn + F6 = No function (should disable the touchpad)
  • Fn + Arrow Up, Arrow Down (is a little bit buggy) (Should adjust the intensity of the backlite)


  • HDMI connection with my 23″ Monitor
  • Fn + F3 = Switch between display modes (for beamer and external displays)


  • The new Ubuntu feels like it uses more energy (which I can’t prove right now)