RAID 1 (mirror) read speed as fast as RAID 0 (stripe)

To our big surprise, the new Intel Raid controller on the Motherboard Intel DX79TO (ver. AAG28805-401) with Intel X79 Express Chipset shows awesome read performance.

The raid model is Intel Rapid Storage Technology enterprise 3.0 (Intel Rapid Storage enterprise – SATA Option ROM – 3.0.1.1370, 2003-2011), which in Microsoft Windows is reported as “Intel C600 Series Chipset SATA RAID Controller”.

Usually, with old Intel RAID models (till ICH10R?), RAID 1 mirror reads only from the one drive at the same time. The last time we tested this, was November 2010 with Intel RAID controller ICH10R.

Now, our test shows, that the new Intel RAID 1 reads from the both mirror drives simultaneously. Writing speed stays the same, however reading speed is twice as fast. Basically, you get read performance the same as from RAID 0 stripe.

Our test setup.

For more details, see the screenshots at the end of this post.

Test results.

HD Tune for SSD shows 957.0 MB/s

HD Tune for SSD shows 957.0 MB/s

HD Tune for HDD shows 182.0 MB/s

HD Tune for HDD shows 182.0 MB/s

9 folders with 20 GB test files. 213.85 MB/s Seagate HDD RAID 1 speed.

9 folders with 20 GB test files. 213.85 MB/s Seagate HDD RAID 1 speed.

Hash & CRC SSD RAID 1 reading speed 1.03 GB/s

Hash & CRC SSD RAID 1 reading speed 1.03 GB/s

FAR Manager SSD RAID 1 reading speed 911.87 MB/s. Little slower, because of NUL device.

FAR Manager SSD RAID 1 reading speed 911.87 MB/s. Little slower, because of NUL device.

FAR Manager HDD RAID 1 reading speed 206.61 MB/s.

FAR Manager HDD RAID 1 reading speed 206.61 MB/s.

Windows Expirience Index via winsat for both drives

Windows Expirience Index via winsat for both drives

Conclusion.

It is possible to get a stunning HDD/SSD read performance with consumer grade hardware. Also, note that in this setup the SSD reading speeds exceeds 1000 MB/s or 1 GB/s. The whole setup costs about $1500.

Winsat for both drives, text version:

C:\Windows\system32>winsat disk -drive d
Windows System Assessment Tool
> Running: Feature Enumeration ''
> Run Time 00:00:00.00
> Running: Storage Assessment '-drive d -ran -read'
> Run Time 00:00:05.89
> Running: Storage Assessment '-drive d -seq -read'
> Run Time 00:00:04.16
> Running: Storage Assessment '-drive d -seq -write'
> Run Time 00:00:04.48
> Running: Storage Assessment '-drive d -flush -seq'
> Run Time 00:00:03.39
> Running: Storage Assessment '-drive d -flush -ran'
> Run Time 00:00:10.89
> Running: Storage Assessment '-drive d -hybrid -ran -read -ransize 4096'
NV Cache not present.
> Run Time 00:00:00.00
> Running: Storage Assessment '-drive d -hybrid -ran -read -ransize 16384'
NV Cache not present.
> Run Time 00:00:00.00
> Disk Random 16.0 Read 2.73 MB/s 4.5
> Disk Sequential 64.0 Read 151.95 MB/s 7.1
> Disk Sequential 64.0 Write 170.69 MB/s 7.2
> Average Read Time with Sequential Writes 2.495 ms 6.8
> Latency: 95th Percentile 48.211 ms 1.9
> Latency: Maximum 228.174 ms 7.2
> Average Read Time with Random Writes 11.562 ms 4.1
> Total Run Time 00:00:29.69
C:\Windows\system32>
C:\Windows\system32>
C:\Windows\system32>
C:\Windows\system32>
C:\Windows\system32>winsat disk -drive c
Windows System Assessment Tool
> Running: Feature Enumeration ''
> Run Time 00:00:00.00
> Running: Storage Assessment '-drive c -ran -read'
> Run Time 00:00:00.22
> Running: Storage Assessment '-drive c -seq -read'
> Run Time 00:00:02.45
> Running: Storage Assessment '-drive c -seq -write'
> Run Time 00:00:02.16
> Running: Storage Assessment '-drive c -flush -seq'
> Run Time 00:00:00.59
> Running: Storage Assessment '-drive c -flush -ran'
> Run Time 00:00:00.59
> Running: Storage Assessment '-drive c -hybrid -ran -read -ransize 4096'
NV Cache not present.
> Run Time 00:00:00.02
> Running: Storage Assessment '-drive c -hybrid -ran -read -ransize 16384'
NV Cache not present.
> Run Time 00:00:00.00
> Disk Random 16.0 Read 252.32 MB/s 8.0
> Disk Sequential 64.0 Read 892.28 MB/s 8.4
> Disk Sequential 64.0 Write 491.88 MB/s 8.1
> Average Read Time with Sequential Writes 0.226 ms 8.5
> Latency: 95th Percentile 0.432 ms 8.7
> Latency: Maximum 2.235 ms 8.8
> Average Read Time with Random Writes 0.228 ms 8.8
> Total Run Time 00:00:06.39

Posted in Computers | Tagged , , | Leave a comment

Executing very large script on Microsoft SQL Server 2008 R2 fails

I was trying to execute very large .sql script in Microsoft SQL Server 2008 R2, that runs on Microsoft Windows Server 2008 R2.

First I tried to copy/paste script into Microsoft SQL Server Management Studio. The server has plenty of memory about 5 GB RAM, and script file is about 150 MB in size and line count is about 1 million, so I do not see problem here. Copy/paste part went ok, however after executing script and after long wait, Management Studio surrendered with “Query completed with errors”:
Microsoft SQL Server Management Studio
------------------------------
Cannot execute script.
------------------------------
ADDITIONAL INFORMATION:
Insufficient memory to continue the execution of the program. (mscorlib)
------------------------------
OK
------------------------------

bl-sql-1

Next I tried various combinations of T-SQL command line tools:
osql -S iDGZdb-dev -i test2.sql -U myuser
sqlcmd -S IDGZDB-DEV -i test2.sql -U myuser
osql -t 100000 -a 65535 ...

Still no success. Various errors appeared in console. Running locally on SQL server:
[SQL Server Native Client 10.0]
Shared Memory Provider: No process is on the other end of the pipe.
[SQL Server Native Client 10.0] Communication link failure

Running on remote machine:
[SQL Server Native Client 10.0]
TCP Provider: An existing connection was forcibly closed by the remote host.
[SQL Server Native Client 10.0]Communication link failure

Tried to search for Google and didn’t find any solution. There were many forums where users ask for help about this issue, but no single answer. Suggested “failed network equipment” is nonsense, if I run script locally, there should be no network involved.

Looked in the System event log under Application logs on the Windows Server where SQL Server resides. Luckily there was an error from the SQL Server:
Log Name: Application
Source: MSSQLSERVER
Date: 2013.02.04. 17:37:41
Event ID: 7836
Task Category: Server
Level: Error
Keywords: Classic
User: N/A
Computer: iDGZdb-dev
Description:
A fatal error occurred while reading the input stream from the network. The maximum number of network packets in one request was exceeded. Try using bulk insert, increasing network packet size, or reducing the size of the request. The session will be terminated.
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="MSSQLSERVER" />
<EventID Qualifiers="49152">7836</EventID>
<Level>2</Level>
<Task>2</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2013-02-04T15:37:41.000000000Z" />
<EventRecordID>223808009</EventRecordID>
<Channel>Application</Channel>
<Computer>iDGZdb-dev</Computer>
<Security />
</System>
<EventData>
<Binary>...some hex stuff...</Binary>
</EventData>
</Event>

But unfortunately, the error reveals very little about the problem. Didn’t get this part of suggestion “… or reducing the size of the request”. The request of 150 MB is too big for the latest edition of MS SQL? Seriously?

Note: Ok, ok… Microsoft SQL Server 2012 is out, and I am not an expert in this area, however, if MySQL can handle scripts in size of gigabytes and Oracle too, then I must be doing something very wrong, but again, then where are all suggestions in the net? Even StackOverflow has only guesses about “network equipment”.

Next, I tried to increase the packet size as suggested in System log message. More statements were executed from the SQL script, however, it still stopped with a memory error:
There is insufficient system memory in resource pool 'internal' to run this query.
Network packet size (bytes): 32576

How I solved this? I surrendered, and instead of wasting time with weird T-SQL error messages, I wrote a little C# script, that executes my file line by line. All of my SQL statements were one-liners. It took me about 1/2 hour to write this script and execute it.

Here is relevant code fragment:
SqlConnection connection = new SqlConnection(Properties.Settings.Default.YourConnectionString);
connection.Open();

System.IO.StreamReader file = new System.IO.StreamReader(yourFilename);
while ((line = file.ReadLine()) != null)
{
    try
    {
        SqlCommand command = new SqlCommand(line, connection);
        command.ExecuteNonQuery();
    }
    catch (Exception ex)
    {
        LogErrorSomewhere(ex.Message, line);
    }
}

file.Close();

P.S. If you know, how to execute a such script using standard SQL tools, then you are welcome to leave me a comment.

Posted in Databases, Programming | Tagged , , , | 1 Comment

Building OpenSSL with Visual Studio 2010 for x64 / Win64 causes error

visual-studio-2010-x64-cross-tools-command-prompt

Today I was trying to build the latest OpenSSL 1.0.1c with Visual Studio 2010. Following instructions form the INSTALL.W32, I was able to successfully build the 32-bit version. Trying the same with 64-bit (x64) version, again following the official instructions from INSTALL.W64.
To build for Win64/x64:
> perl Configure VC-WIN64A
> ms\do_win64a
> nmake -f ms\ntdll.mak
> cd out32dll
> ..\ms\test

The first line ‘perl Configure VC-WIN64A’ went without any errors:
Configuring for VC-WIN64A
no-ec_nistp_64_gcc_128 [default] OPENSSL_NO_EC_NISTP_64_GCC_128 (skip dir)
no-gmp [default] OPENSSL_NO_GMP (skip dir)
no-jpake [experimental] OPENSSL_NO_JPAKE (skip dir)
no-krb5 [krb5-flavor not specified] OPENSSL_NO_KRB5
no-md2 [default] OPENSSL_NO_MD2 (skip dir)
no-rc5 [default] OPENSSL_NO_RC5 (skip dir)
no-rfc3779 [default] OPENSSL_NO_RFC3779 (skip dir)
no-sctp [default] OPENSSL_NO_SCTP (skip dir)
no-shared [default]
no-store [experimental] OPENSSL_NO_STORE (skip dir)
no-zlib [default]
no-zlib-dynamic [default]
...
...
...
SIXTY_FOUR_BIT mode
DES_INT used
RC4_CHUNK is unsigned long long
Configured for VC-WIN64A.

The second line ‘ms\do_win64a’ always returned errors:
ml64 -c -Foms\uptable.obj ms\uptable.asm
Microsoft (R) Macro Assembler (x64) Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.


Assembling: ms\uptable.asm
ms\uptable.asm(356) : error A2088:END directive required at end of file
ms\uptable.asm(356) : fatal error A1010:unmatched block nesting : _lazy18

Luckily I found solution in cyber-lynx.livejournal.com
Translation from Russian:
To prevent this, need to change file ms\do_win64a.bat like this: instead of

perl ms\uplink-x86_64.pl masm > ms\uptable.asm
ml64 -c -Foms\uptable.obj ms\uptable.asm

write

perl ms\uplink-x86_64.pl masm > ms\uptable.asm
ping 127.0.0.1
ml64 -c -Foms\uptable.obj ms\uptable.asm

It seems like race condition to me. Command ‘ping 127.0.0.1′ just adds a pause between two commands.

Thanks to Белая рысь (cyber_lynx)! Source: http://cyber-lynx.livejournal.com/40001.html

Posted in Programming | Tagged , , , | Leave a comment

Did you know that IP addresses (IPv4) can be written in shorter representations?

Did you know that IPv4 addresses can be written in shorter representations, like IPv6 addresses?

Everyone have seen form of IPv6 represented as “shorter form”:
Example from IPv6:

  • 2001::7334
  • ::1
  • ::

You can use our free tool ipv6-literal.com to convert these addresses to long form. The result is:

  • 2001:0000:0000:0000:0000:0000:0000:7334
  • 0000:0000:0000:0000:0000:0000:0000:0001
  • 0000:0000:0000:0000:0000:0000:0000:0000

What admins / programmers usually do not know, is that the same principle applies to IPv4 addresses:

  • 127.1
  • 1
  • 192.168.257
  • 192.168.65535
  • 192.168.65535
  • 192.168
  • 10.1

To test these, use built in ping command. I used ping in Windows 7 and Ubuntu 10, and the result addresses are:

  • 127.1 -> 127.0.0.1
  • 1 -> 0.0.0.1
  • 192.168.257 -> 192.168.1.1
  • 192.168.65535 -> 192.168.255.255
  • 192.168 -> 192.0.0.168
  • 10.1 -> 10.0.0.1

As a bonus, you can try to ping other IP address representations:

  • ping 0x7F000001 – hex
  • ping 010 – octal, does not work in Ubuntu
  • ping 2130706433 – decimal

Why it works this way? Because network funcions built into OS support a such behavior, for example:

Have a fun, and remember, that year of IPv6 is near.

Posted in Computers, OS, Programming | Tagged , , , , | Leave a comment

C# / .NET MessageBox is hidden behind the Form

Imagine calling the following C# code:MessageBox.Show(this, "Some text...", "Title", MessageBoxButtons.OKCancel);

After executing this line, the Message Box is not visible, it seems like hidden behind your form, without input focus, mouse clicks cause default beeps, and it suddenly appears if you click Alt or F10 key.

It turns out I had a custom drawing routine for one of the form’s controls (OwnerDraw / OnPaint), and I was changing the property that was causing the redraw cycle. Make sure, that in your OnPaint / DrawItem / DrawSubitem / etc. you are not invalidating your Control.

Also, if you are using .NET ListView control, it has a bug.

Because of a bug in the underlying Win32 control, the DrawItem event occurs without accompanying DrawSubItem events once per row in the details view when the mouse pointer moves over the row, causing anything painted in a DrawSubItem event handler to be overpainted by a custom background drawn in a DrawItem event handler. See the example in the OwnerDraw reference topic for a workaround that invalidates each row when the extra event occurs. An alternative workaround is to put all your custom drawing code in a DrawSubItem event handler and paint the background for the entire item (including subitems) only when the DrawListViewSubItemEventArgs.ColumnIndex value is 0.

http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.drawitem%28v=vs.80%29.aspx

This is not limited to MessageBox using C# / .NET framework. This also happens very often, with Win32 & WinAPI, with a Form class, etc.:

Posted in Programming | Tagged , , , | Leave a comment

String.format in Java has weird rounding by default

I was participating in one of our Android projects, and while testing I discovered, that our program acted weird — app displayed one value, but acted like the value was different. The value was 1.45, and our Java Android app displayed 1.4 instead of 1.5.

The source looked something like:
double d = 1.45;
String val = String.format(Locale.US, "%.1f", d) + "%";

I am still a beginner in Java, and at first I believed, that String.format rounds down by default. This was till I saw, that value 1.55 is rounded up by default.

Digging into Java documentation I found, that String.format uses RoundingMode HALF_EVEN by default:

Rounding mode to round towards the “nearest neighbor” unless both neighbors are equidistant, in which case, round towards the even neighbor. Behaves as for RoundingMode.HALF_UP if the digit to the left of the discarded fraction is odd; behaves as for RoundingMode.HALF_DOWN if it’s even. Note that this is the rounding mode that statistically minimizes cumulative error when applied repeatedly over a sequence of calculations. It is sometimes known as “Banker’s rounding,” and is chiefly used in the USA. This rounding mode is analogous to the rounding policy used for float and double arithmetic in Java.

http://docs.oracle.com/javase/6/docs/api/java/math/RoundingMode.html

Of course other beginners are also discovering this Java Rounding.

Unfortunately Android does not support setRoundingMode, so currently using the following workaround:
double d = (double)Math.round(((double)percents) * 10f) / 10f;
String val = String.format(Locale.US, "%.1f", d) + "%";

Posted in Programming | Tagged , | 1 Comment

PowerShell in Unicode, Windows 8 RP and Windows Server 2012 RC

PowerShell 3.0 under Windows 8

I was testing our software with latest version of Microsoft Windows — Windows 8 Release Preview and Windows Server 2012 Release Candidate (Windows Server 2012 RC Datacenter).

There was some changed behavior in very specific cases for some rarely used Windows API. I also found some race conditions, that showed up in Windows 8, but all this was trivial to fix.

The strange problem appeared in capturing console output from PowerShell in UTF-8 or Unicode (UTF-16). We are using CreateProcess Windows API function with redirected pipes. And strangely all output is converted from Unicode to ASCII. We are using OutputEncoding UTF-8:
[Console]::OutputEncoding = [Text.Encoding]::Utf8See example here: Unicode in PowerShell – example #2.

Windows 8 is using a new version of PowerShell — v3, so I tried to use compatibility command line switch -version 2.0, and this solved the problem.

Most probably this is a bug in Microsoft PowerShell — PowerShell somewhere is converting all output to ASCII. The question remains, will this be fixed in RTM or we will be unable to use Unicode output in PowerShell v3.

P.S. Currently I am unable to test this under Windows 8 RTM or Windows Server 2012 RTM, because for MSDN subscribers, Windows 8 and 2012 will be available on August 15, 2012.

Posted in Computers, OS | Tagged , , , , | Leave a comment

Visual Studio Form Editor: To prevent possible data loss before loading the designer, the following errors must be resolved

This is not the first time. I have seen this error message in the past (probably multiple times), and every time I look to this error and I do not understand, why it appeared and how to fix it. I read the text, projects not referenced, projects have been built… wait… yes, projects must be built, otherwise Inherited Forms can not be shown. Building the projects with base classes solved the problem.

Visual Studio Form Editor: To prevent possible data loss before loading the designer, the following errors must be resolved: The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following clasess in the file: MyClass.cs — The base class MyBaseClass.cs could not be loaded. Ensure the assembly has been referenced and that all projects have been built.

Posted in Programming | Tagged , , | 1 Comment

Spammed by WordPress comment stealing bot with Facebook profile

Some time ago (1/2 year, may be 1 year) strange comments started to appear in our WordPress comment moderation queue. They all contained some random comments from random places, they all had the similar URL:
http://www.facebook.com/profile.php?id=XXXXXXXXXXXXXXX
where XXXXXXXXXXXXXXX is profile ID, that is changing from one comment to another. I didn’t click on the fake profiles, do not have time to research who are behind this.

Today regular chunk of SPAM in moderation queue, again with fake Facebook profiles, again bypassed CAPTCHA somehow (Chinese clickers perhaps), but one particular comment grabbed my attention. It is comment from post about old tabled unboxing.
Here is a comment:

Author : Bagas (IP: 92.99.196.92 , 92.99.196.92)
E-mail : rkleinschmidt@SOMETHING–HEALTH–related–WAS–here.org
URL : http://www.facebook.com/profile.php?id=XXXXXXXXXXXXXXX
Whois : http://whois.arin.net/rest/ip/92.99.196.92
Comment:
I buy few unit from amazon , at first i think the $199 is good deal , but actllauy this player is worst , the touch screen really slow and hard to scroll , and the app , i think all junk app , please consider don’t think $199 is a good deal , better u add another bucks for really goods item.

The strange thing is that this comment seems like absolutely legitimate user commenting on Archos tablet. Yes, touch screen is slow, there are junk apps, etc.

I did a quick Google search, and instantly found original site, where this comment was stolen:
http://www.yugatech.com/personal-computing/archos-7-home-tablet/

It is blog post about Archos tablet. And comment is from “June 25, 2010 at 5:32 pm”. It is also running on the WordPress engine.

So the theory:

  • The Comment Stealing BOT (CSB) finds random WordPress blog;
  • CSB then finds some random posts;
  • CSB somehow searches the internet, using keywords from my blog post;
  • CSB finds some WordPress blog and grabs some random comments;
  • Sometimes it succeeds, and comment looks like real user post;
  • It tries to promote some Facebook pages;
  • If you are managing multiple blogs, you spot this pattern instantly.

Of course other WordPress users are noticing this too:

Posted in Web | Tagged , , | 1 Comment

Your program is returning ErrorLevel 128 (exit code)

Here is a scenario:

  • You have written a program;
  • You run it;
  • First line of the program never gets executed;
  • ErrorLevel (exit code) 128 is returned.

You search Google for solution, but nothing useful is found. This happened to me. Problem was — Windows was running out of memory on my virtual computer. This can happen on physical machine too.

Later I found MS support article. User32.dll or Kernel32.dll fails to initialize:

Sometimes an application that is executed by either CreateProcess() or CreateProcessAsUser() fails and you receive one of the following error messages:
Initialization of the dynamic library \system32\user32.dll failed. The process is terminating abnormally.
Initialization of the dynamic library \system32\kernel32.dll failed. The process is terminating abnormally.
The failed process returns the exit code 128 or
ERROR_WAIT_NO_CHILDREN

Posted in OS, Programming | Tagged , , | Leave a comment