Shared posts

02 Nov 13:15

Louis C.K. on the 2016 election

by Jason Kottke

On Conan last night, Louis C.K. had some things to say about the 2016 presidential election.

If you vote for Hillary you’re a grownup; if you vote for Trump you’re a sucker; if you don’t vote for anyone, you’re an asshole.

Tags: 2016 election   Louis C.K.   politics   TV   video
21 Oct 19:49

Breakfast

by Jason Kottke

A quick short film about how different people in LA approach breakfast, from the woman who nibbles to the professional bodybuilder who eats 30 egg whites and a cup of grits on his off day.

Me? I almost never eat breakfast and have been unwittingly following an intermittent fasting regimen for many years.

Tags: food   video
29 Jun 07:07

Comic: The RegurgiStation

by Tycho@penny-arcade.com (Tycho)
New Comic: The RegurgiStation
09 Jun 20:10

Tracking down a performance hit

by jonskeet

I’ve been following the progress of .NET Core with a lot of interest, and trying to make the Noda Time master branch keep up with it. The aim is that when Noda Time 2.0 eventually ships (apologies for the delays…) it will be compatible with .NET Core from the start. (I’d expected to be able to support netstandard1.0, but that appears to have too much missing from it. It looks like netstandard1.3 will be the actual target.)

I’ve been particularly looking forward to being able to run the Noda Time benchmarks (now using BenchmarkDotNet) to compare .NET Core on Linux with the same code on Windows. In order to make that a fair comparison, I now have two Intel NUCs, both sporting an i5-5250U and 8GB of memory.

As it happens, I haven’t got as far as running the benchmarks under .NET Core – but I am now able to run all the unit tests on both Linux and Windows, using both the net451 TFM and netcoreapp1.0.

When I did that recently, I was pretty shocked to see that (depending on which tests I ran) the tests were 6-10 times slower on Linux than on Windows, using netcoreapp1.0 in both cases. This post is a brief log of what I did to track down the problem.

Step 1: Check that there’s really a problem

Thought: Is this actually just a matter of not running the tests in a release configuration, or something similar?

Verification: I ran the tests several times, specifying -c Release on the command line to use the release build of both NodaTime.Test.dll and NodaTime.dll. Running under a debugger definitely wasn’t an issue, as this was all just done from the shell.

Additionally, I ran the tests in two ways – firstly, running the whole test suite, and secondly running with --where=cat!=Slow to avoid the few tests I’ve got which are known to be really pretty slow. They’re typically tests which compare the answers the BCL gives with the answers Noda Time gives, across the whole of history for a particular calendar system or time zone. I’m pleased to report that the bottleneck in these tests is almost always the BCL, but that doesn’t help to speed them up. If only the “slow” tests had been much slower on Linux, that might have pointed to the problems being in BCL calendar or time zone code.

The ratios vary, but there was enough of a problem under both circumstances for it to be worth looking further.

Step 2: Find a problematic test

I didn’t have very strong expectations one way or another about whether this would come down to some general problem in the JIT on Linux, or whether there might be one piece of code causing problems in some tests but not others. Knowing that there are significant differences in handling of some culture and time zone code between the Linux and Windows implementations, I wanted to find a test which used the BCL as little as possible – but which was also slow enough for the differences in timing to be pronounced and not easily explicable by the problems of measuring small amounts of time.

Fortunately, NUnit produces a TestResult.xml file which is easy to parse with LINQ to XML, so I could easily transform the results from Windows and Linux into a list of tests, ordered by duration (descending), and spot the right kind of test.

I found my answer in UmAlQuraYearMonthDayCalculatorTest.GetYearMonthDay_DaysSinceEpoch, which effectively tests the Um Al Qura calendar for self consistency, by iterating over every day in the supported time period and checking that we can convert from “days since Unix epoch” to an expected “year, month day”. In particular, this test doesn’t rely on the Windows implementation of the calendar, nor does it use any time zones, cultures or anything similar. It’s nicely self-contained.

This test took 2051ms on Linux and 295ms on Windows. It’s possible that those figures were from a debug build, but I repeated the tests using a release build and confirmed that the difference was still similar.

Step 3: Find the bottleneck

At this point, my aim was to try to remove bits of the test at a time, until the difference went away. I expected to find something quite obscure causing the difference – something like different CPU cache behaviour. I knew that the next step would be to isolate the problem to a small piece of code, but I expected that it would involve a reasonable chunk of Noda Time – at least a few types.

I was really lucky here – the first and most obvious call to remove made a big difference: the equality assertion. Assertions are usually the first thing to remove in tests, because everything else typically builds something that you use in the assertions… if you’re making a call without either using the result later or asserting something about the result, presumably you’re only interested in side effects.

As soon as I removed the call to Assert.AreEqual(expected, actual), the execution time dropped massively on Linux, but hardly moved on Windows: they were effectively on a par.

I wondered whether the problem was with the fact that I was asserting equality between custom structs, and so tried replacing the real assertions with assertions of equality of strings, then of integers. No significant difference – they all showed the same discrepancy between Windows and Linux.

Step 4: Remove Noda Time

Once I’d identified the assertions as the cause of the problem, it was trivial to start a new test project with no dependency on Noda Time, consisting of a test like this:

[Test]
public void Foo()
{
    for (int i = 0; i < 1000000; i++)
    {
        var x = 10;
        var y = 10;
        Assert.AreEqual(x, y);
    }
}

This still demonstrated the problem consistently, and allowed simpler experimentation with different assertions.

Step 5: Dig into NUnit

For once in my life, I was glad that a lot of implementation details of a framework were exposed publicly. I was able to try lots of different “bits” of asserting equality, in order to pin down the problem. Things I tried:

  • Assert.AreEqual(x, y): slow
  • Assert.That(x, Is.EqualTo(y)): slow
  • Constructing an NUnitEqualityComparer: fast
  • Calling NUnitEqualityComparer.AreEqual: fast. (Here the construction occurred before the loop, and the comparisons were in the loop.)
  • Calling Is.EqualTo(y): slow

The last bullets two bullets were surprising. I’d been tipped off that NUnitEqualityComparer uses reflection, which could easily differ in performance between Windows and Linux… but checking for equality seemed to be fast, and just constructing the constraint was slow. In poking around the NUnit source code (thank goodness for Open Source!) it’s obvious why Assert.AreEqual(x, y) and Assert.That(y, Is.EqualTo(x)) behave the same way – the former just calls the latter.

So, why is Is.EqualTo(y) slow (on Linux)? The method itself is simple – it just creates an instance of EqualConstraint. The EqualConstraint constructor body doesn’t do much… so I proved that it’s not EqualConstraint causing the problem by deriving my own constraint with a no-op implementation of ApplyTo… sure enough, just constructing that is slow.

That leaves the constructor of the Constraint abstract base class:

protected Constraint(params object[] args)
{
    Arguments = args;

    DisplayName = this.GetType().Name;
    if (DisplayName.EndsWith("`1") || DisplayName.EndsWith("`2"))
        DisplayName = DisplayName.Substring(0, DisplayName.Length - 2);
    if (DisplayName.EndsWith("Constraint"))
            DisplayName = DisplayName.Substring(0, DisplayName.Length - 10);
}

That looks innocuous enough… but maybe calling GetType().Name is expensive on Linux. So test that… nope, it’s fast.

At this point I’m beginning to wonder whether we’ll ever get to the bottom of it, but let’s just try…

[Test]
public void EndsWith()
{
    string text = "abcdefg";
    for (int i = 0; i < Iterations; i++)
    {
        text.EndsWith("123");
    }
}

… and sure enough, it’s fast on Windows and slow on Linux. Wow. Looks like we have a culprit.

Step 6: Remove NUnit

At this point, it’s relatively plain sailing. We can reproduce the issue in a simple console app. I won’t list the code here, but it’s in the GitHub issue. It just times calling EndsWith once (to get it JIT compiled) and then a million times. Is it the most rigorous benchmark in the world? Absolutely not… but when the difference is between 5.3s on Linux and 0.16s on Windows, on the same hardware, I’m not worried about inaccuracy of a few milliseconds here or there.

Step 7: File a CoreCLR issue

So, as I’ve shown, I filed a bug on GitHub. I’d like to think it was a pretty good bug report:

  • Details of the environment
  • Short but complete console app ready to copy/paste/compile/run
  • Results

Exactly the kind of thing I’d have put into a Stack Overflow question – when I ask for a minimal, complete example on Stack Overflow, this is what I mean.

Anyway, about 20 minutes later (!!!), Stephen Toub has basically worked out the nub of it: it’s a culture issue. Initially, he couldn’t reproduce it – he saw the same results on Windows and Linux. But changing his culture to en-GB, he saw what I was seeing. I then confirmed the opposite – when I ran the code having set LANG=en-US, the problem went away for me. Stephen pulled Matt Ellis in, who gave more details as to what was going wrong behind the scenes.

Step 8: File an NUnit issue

Matt Ellis suggested filing an issue against NUnit, as there’s no reason this code should be culture-sensitive. By specifying the string comparison as Ordinal, we can go through an even faster path than using the US culture. So

if (DisplayName.EndsWith("Constraint"))

becomes

if (DisplayName.EndsWith("Constraint", StringComparison.Ordinal))

… and the equivalent for the other two calls.

I pointed out in the issue that it was also a little bit odd that this was being worked out in every Constraint constructor call, when of course it’s going to give the same result for every instance of the same type. When “every Constraint constructor call” becomes “every assertion in an entire test run”, it’s a pretty performance-critical piece of code. While unit tests aren’t important in terms of performance in the same way that production code is, anything which adds friction is bad news.

Hopefully the NUnit team will apply the simple improvement for the next release, and then the CoreCLR team can attack the tougher underlying problem over time.

Step 9: Blog about it

Open up Stack Edit, start typing: “I’ve been following the progress”… :)

Conclusion

None of the steps I’ve listed here is particularly tricky. Diagnosing problems is often more a matter of determination and being unwilling to admit defeat than cleverness. (I’m not denying that there’s a certain art to being able to find the right seam to split the problem in two, admittedly.)

I hope this has been useful as a “start to finish” example of what a diagnostic session can look and feel like. It wasn’t one physical session, of course – I found bits of time to investigate it over the course of a day or so – but it would have been the same steps either way.

Smug, satisfied smile…


23 May 17:53

The Last Days of Disco, Elizaveta Porodina



The Last Days of Disco, Elizaveta Porodina

15 May 20:01

Edward Hopper on this day in 1967, Other people’s deaths



Edward Hopper on this day in 1967, Other people’s deaths

31 Mar 16:40

Microsoft Makes Xamarin Free In Visual Studio, Will Open Source Core Xamarin Tech

by manishs
An anonymous reader cites a report on VentureBeat: Microsoft today announced that Xamarin is now available for free for every Visual Studio user. This includes all editions of Visual Studio, including the free Visual Studio Community Edition, Visual Studio Professional, and Visual Studio Enterprise. Furthermore, Xamarin Studio for OS X is being made available for free as a community edition and Visual Studio Enterprise subscribers will get access to Xamarin's enterprise capabilities at no additional cost. The company also promised to open source Xamarin's SDK, including its runtime, libraries, and command line tools, as part of the .NET Foundation 'in the coming months.' Plenty of developers will find this announcement exciting. Xamarin being free is a big deal.

Share on Google+

Read more of this story at Slashdot.

26 Oct 16:49

Hey girl, Hillary 1969



Hey girl, Hillary 1969

24 Oct 16:15

Mid-day news: A Wings-Canucks preview; ESPN rankings and suspension talk

by George Malik

Of Red Wings-related note this afternoon:

The Wings and Canucks have yet to take part in their morning skate, but the Canucks website's Daniel Fung has penned a preview of tonight's game (10 PM EDT on FSD/CBC/97.1 FM):

Keys to the Game

Canucks: The bottom-9 has to produce. Coach Desjardins has admitted his reluctance to reunite the Sedins and Vrbata was because he didn't want to be a one-line team. Vrbata and the twins delivered on Thursday night but the onus is on the rest of the forwards to produce as well so opponents have to worry about something other than shutting down the Sedin line.

Canucks: Build on Thursday's PP success. After bumping their long man-advantage slump against the Capitals, Vancouver's power play figures to get another boost with the return of Weber to the line-up. Weber was tied for second on the team with five power play goals last season and provides a right-shot, one-timer option that has sorely been missing for most of this season.

Red Wings: Get the early jump. Visiting teams have gotten off to strong starts in every game so far this season at Rogers Arena and the Red Wings will want to follow that same formula to success. Considering all three of Detroit's wins this season have come when they've opened the scoring, the opening goal tonight will be a critical one.

VanCityBuzz's Ian Lusher also notes that the Canucks are 0-2-and-2 at home this season...

Continue reading "Mid-day news: A Wings-Canucks preview; ESPN rankings and suspension talk"

05 May 15:02

OtterBox Symmetry Series Folio Cases Now Available for iPad Air 2 and iPad Mini 3 [iOS Blog]

by Joe Rossignol
OtterBox today announced the availability of its new Symmetry Series folio cases for iPad Air 2 and iPad mini 3 in black with faux leather or white with a tan fabric cover. The cases feature a one-piece protective shell and slim folio that wraps around to cover the screen, alongside a micro suede interior cover to keep the tablet's display free of scratches.

OtterBox Symmetry Series Folio
The Symmetry Series cases for iPad double as both protective cases and multi-position stands with 360-degrees rotation for landscape and portrait viewing. The cases also automatically wake and sleep the iPad screen when the folio is opened and closed, and have certified drop protection in case your iPad takes a tumble.

OtterBox Symmetry Series folio cases for iPad Air 2 and iPad mini 3 can be purchased through the accessory maker's website for $69.95 and $59.95 respectively. OtterBox makes the number-one selling cases in North America and was one of the earlier providers of cases and accessories for iPhone, iPad and other products by both Apple and competitors.






10 Apr 04:00

Napoleon

"Mr. President, what if the unthinkable happens? What if the launch goes wrong, and Napoleon is not stranded on the Moon?" "Have Safire write up a speech."
04 Jan 04:48

Little legs

09 Nov 21:33

Winter is coming, Dozier Bell

















Winter is coming, Dozier Bell

26 Oct 15:40

Century Old Antarctic Expedition Notebook Found Underneath Ice

by samzenpus
An anonymous reader writes During his second expedition to Antarctica, British explorer Robert Scott—and most of his team—died from overexposure to the elements. Over 100 years after their deaths, an artifact from his journey has surfaced. New Zealand's Antarctic Heritage Trust reports that they have found a notebook which tracked Scott's last Terra Nova Expedition. According to the Antarctic Heritage Trust, the notebook belonged to a surgeon, photographer and zoologist named George Murray Levick, who accompanied Scott at the unfortunate Terra Nova expedition. Executive Director Nigel Watson said, "It's an exciting find. The notebook is a missing part of the official expedition record. After spending seven years conserving Scott's last expedition building and collection, we are delighted to still be finding new artifacts."

Share on Google+

Read more of this story at Slashdot.








24 Oct 15:32

Questions For Khan

by Paul

Q: Do you think the Wings will trade Dylan Larkin for Tyler Myers? I hope not. I like Myers' size and right shot but I hope they don't sacrifice the future for him.

A: My guess is they won't part with Larkin in their efforts to acquire Myers. They're committed to building through the draft. They relinquished a young center (Calle Jarnkrok) last season because they felt they needed a veteran center (David Legwand) to help them reach the playoffs.

They have a couple of other promising centers in the system in Tomas Nosek and Mattias Janmark, but Larkin, their top pick in 2014 (15th overall), by several accounts, has the potential to be much better. It's no surprise the Sabres are seeking him, after being told top prospect Anthony Mantha isn't going anywhere.

The Red Wings will have to relinquish something of value to land the young (24), 6-foot-8, puck-moving defenseman Myers. At 1-7, the Sabres are well on their way to reaching their goal of gaining the most lottery balls for the Connor McDavid draft in June, so they shouldn't be in any hurry to get rid of all their best players.

more questions for Ansar Khan of Mlive including one on Weiss...

02 Oct 23:00

How #3DPrinting went from pipe dream to your desktop #3DPrinting #3DThursday

by Pedro Ruiz

digital-trends

3D printers are all the rage with enthusiasts, but they didn’t just materialize out of nowhere like the sculptures they produce. Here’s the untold story of how the next big boom in technology came to be over 30 years.

read more on:
digitaltrends.com


649-1
Every Thursday is #3dthursday here at Adafruit! The DIY 3D printing community has passion and dedication for making solid objects from digital models. Recently, we have noticed electronics projects integrated with 3D printed enclosures, brackets, and sculptures, so each Thursday we celebrate and highlight these bold pioneers!

Have you considered building a 3D project around an Arduino or other microcontroller? How about printing a bracket to mount your Raspberry Pi to the back of your HD monitor? And don’t forget the countless LED projects that are possible when you are modeling your projects in 3D!

22 Sep 21:11

Rebecca Green

19 Sep 17:43

Design Crush

15 Sep 19:22

Mondays.

15 Sep 16:49

Pantone

14 Sep 21:15

Science!

14 Sep 18:33

Design Crush

12 Sep 17:11

Chicago in the Fog by Michael Salisbury

by Christopher Jobson

Chicago in the Fog by Michael Salisbury fog cityscapes Chicago

Chicago in the Fog by Michael Salisbury fog cityscapes Chicago

Chicago in the Fog by Michael Salisbury fog cityscapes Chicago

Chicago in the Fog by Michael Salisbury fog cityscapes Chicago

Chicago in the Fog by Michael Salisbury fog cityscapes Chicago

Chicago in the Fog by Michael Salisbury fog cityscapes Chicago

Local photographer Michael Salisbury snapped some excellent photos of the fog swallowing Chicago this summer. You can see more over on his Flickr stream and on Instagram. Some of these are available as prints on Crated.

08 Sep 02:10

Calvin and Hobbes

05 Sep 00:37

Parallel universe

03 Sep 21:48

Definition

29 Aug 21:24

Via, um Playboy



Via, um Playboy

27 Aug 13:30

A Pair of Kissing Porcelain Vases by Johnson Tsang

by Christopher Jobson

A Pair of Kissing Porcelain Vases by Johnson Tsang porcelain ceramics

A Pair of Kissing Porcelain Vases by Johnson Tsang porcelain ceramics

A Pair of Kissing Porcelain Vases by Johnson Tsang porcelain ceramics

A Pair of Kissing Porcelain Vases by Johnson Tsang porcelain ceramics

A Pair of Kissing Porcelain Vases by Johnson Tsang porcelain ceramics

A Pair of Kissing Porcelain Vases by Johnson Tsang porcelain ceramics

A Pair of Kissing Porcelain Vases by Johnson Tsang porcelain ceramics

Ceramic artist Johnson Tsang (previously) created a pair of porcelain vases that when cut along the edges reveal the profiles of people. Smoosh two together and you have instant ceramic love. See more of Tsang’s process over on his blog, and if you liked this also check out the Profilograph by Pablo Garcia.

26 Aug 16:39

Design Crush

22 Aug 16:30

Design Crush