Does 1 Millisecond Matter?

by Jon Davis 6. July 2008 20:31

I'm casually skimming an ASP.NET book for review purposes and I came across mention of the connection factory classes in ADO.NET 2.0.

I forgot about these; I've always seen abstract, app-specific DAL base classes that get implemented with a SQL, Access, or other database-based implementation, but I've never seen anyone use DbProviderFactories.

The book claims that these factory classes provide database neutrality in instantiating a database connection, so that you can use SqlConnection but also OdbcConnection, et al, without changing or recompiling any of the codebase, "without affecting the application's performance!"

No performance hit? Is it not using reflection? I fired up Reflector to introspect these classes, namely System.Data.Common.DbProviderFactories, System.Data.Common.DbConnection, System.Data.Common.DbCommand, and System.Data.Common.DbDataReader. Reflection is used. It's fine, relflection is there for a reason, but when used in any loop it is also notoriously slow (at least 10x the invocation time of a strongly referenced invocation). I suppose if the application has a very lightweight load, it might not matter.

I wrote and ran a performance comparison test in a console app. First I just ran two near-identical methods seperately, each in a loop (1000x), one method using DbProviderFactories and one just using SqlConnection, and both using SELECT to return all rows in a single-row, 4-column table. Then I realized it would be good to measure the performance of the last run of each, because the first few runs and especially the very first run will be expectedly slower due to runtime caching and JITing.

Here's the end result:

Factory:        23739 ticks / 2ms (total @ 1000x: 2331ms)
SqlClient:      11233 ticks / 1ms (total @ 1000x: 1321ms)

Now the question becomes, does 1 millisecond difference per connection instance matter, considering how high that number's gonna go when it goes over the wire and both data load and business logic is going to increase things to anywhere from 10ms to 1000ms?

Perhaps not. There is a difference, but it is subtle. The debate is kind of like the debate about "" versus String.Empty.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , ,

Software Development | C#

Intellectual Honesty

by Jon Davis 6. July 2008 16:47

In 1998, when I was working at a fulfillment company called K/P Corporation as a web developer, the several offices scattered throughout California routinely held meetings, exchanged e-mails sent both from the bottom up and from the top down, brought in trainers, and even distributed inspirational books company-wide for our enjoyment.

One time after a typical round of corporate meetings and e-mail announcements, the president of the company tried to list a number of key behavioral patterns and attitudes he wanted the company to have. Usually this stuff goes in one ear and out the other--yeah yeah, "work hard", "be respectful", "don't poop in your pants", who hasn't heard this stuff before--one of these things stood out to me, because it was something I wasn't used to hearing.

It was "intellectual honesty -- don't be afraid to share what you know".

I've noticed that not all American cultures behind the doors of corporations have standardized on a philosophy of intellectual honesty over the last decade. I suppose human nature hasn't changed for the better at all since the history of mankind. Time isn't our friend in this regard. Traditional respect has degraded over time. The elderly respectables have been laid to dust, and the brats of yesterday have assumed their roles.

I've been expanding on the term "intellectual honesty" over the years, identifying more and more elements that I think describe what it should really mean:

  • Be unafraid to share what you know.
  • Don't hoard knowledge.
  • Accept criticism about your understanding.
  • Be teachable.
  • Be willing to teach.
  • Be willing to be wrong.
  • Acknowledge correction.
  • Sharing it is as important as doing it.

A lot of this, but not all of it, relates closely with the idea, "seek humility in yourself with everyone below you".

This is an extremely difficult philosphy to follow because it requires you to minimize self and maximize teamwork.

The opposite of intellectual honesty smells a lot like body odor, looks like a giant, dark wolf ("I am a servant of The Nothing!"), and a corporate environment that doesn't encourage intellectual honesty might be described more like:

  • The veteran of proprietary knowledge cannot be fired because he alone understands.
  • Disagreements are intolerable. 
    • The veteran of proprietary knowledge who alone understands the legacy codebase automatically wins all arguments about the newer codebase without consideration of the disagreement.
    • Don't even consider the plausibility of, or answer to resolve, the arguments of the individual who questions the strategies of leadership's new directions.
    • Shun the individual who dares to question authority, even when he does it in a one-on-one private meeting.
    • Don't resolve the occasional serious disagreement by evaluating the premise. Just isolate the disagreer and call him "disrespectful" and "high maintenance".
  • Speak about critical team, technology, or business decisions in hushed tones (".. msh, msh, ...... took my stapler ... shm, msh.."), in a dark corner, of another room, with the doors closed, with no one invited except the leader and the leader's leader.
  • Shun the newer individual who likes to innovate.
  • Send negative "stop wasting time on this" e-mails to any individual who shares new discoveries.
  • No underling grunt could possibly know more about any individual thing than management!

An individual is often intellectually dishonest as a selfish defensive strategy. Often this ugly beast bears its teeth and attacks when people are faced with personalities opposite of their own. People who can't handle someone putting an ounce of emotion into their words often find it very difficult to be intellectually honest. Other people will impose their opinions but will hold their ears and run away when hearing someone share something that differs with their own philosophies, even if what they're hearing is perfectly sensible. This situation is called cognative dissonance, and mastery of pushing past cognative dissonance is one of several important skills used to carry out intellectual honesty, second only after plain and simple humility.

Fear is a huge cause of a lack of mastery over cognative dissonace,

  • fear of humiliation,
  • fear of losing rank,
  • fear of losing respect,
  • fear of losing control, and
  • fear of unplanned changes to scope

Some of these fears are reasonable, but they should all be fought and avoided.

  • A humble person cannot be humiliated for being wrong, because he already accepted that he is not omniscient God.
  • A wise person will recognize that the loss of rank, if temporary, is either unlikely or else probably appropriate.
  • An experienced person already knows that he loses tons of respect if he doesn't practice intellectual honesty.
  • A responsible person recognizes that part of responsibility to "keep things under control" is making sure that everyone who can benefit from knowledge or from correction can benefit (has access to such benefits).
  • An adept and agile person will have prepared, both mentally and logistically, to adjust to changes of scope.

Do I think I'm intellectually honest? That's a bit like asking if I think I'm humble; you can't answer that either way without lying. But it is certainly a philosophy worth striving for. Not to mention the hopes and expectations that an employmentt environment might strive for it, too.

But kudos to the Open Source Software movement and community. While many proponents of traditional Linux and other "dark knowledge to be known only by the sorcerer" are not regarded as such, the notion of "share, and join us as we all strive to improve" seems to be the core philosophy of excellent open source software.

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

280 Slides

by Jon Davis 1. July 2008 09:41

Wow. As a StumbleUpon user, I thought I'd seen it all. Apparently not!

http://280slides.com/

(Works best if you use anything other than IE. IE doesn't puke but it does choke.)

The most interesting thing about it is that the Javascript is actually pre-processed from an Objective-C-like language that is Cocoa inspired.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:


 

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

Jon Davis (aka "stimpy77") has been a programmer, developer, and consultant for web and Windows software solutions professionally since 1997, with experience ranging from OS and hardware support to DHTML programming to IIS/ASP web apps to Java network programming to Visual Basic applications to C# desktop apps.
 
Software in all forms is also his sole hobby, whether playing PC games or tinkering with programming them. "I was playing Defender on the Commodore 64," he reminisces, "when I decided at the age of 12 or so that I want to be a computer programmer when I grow up."

Jon was previously employed as a senior .NET developer at a very well-known Internet services company whom you're more likely than not to have directly done business with. However, this blog and all of jondavis.net have no affiliation with, and are not representative of, his former employer in any way.

Contact Me 


Tag cloud

Calendar

<<  August 2020  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456

View posts in large calendar

RecentPosts