« first day (508 days earlier)      last day (4423 days later) » 

8:04 AM
@Mysticial Do you have any basic guidelines on how to write code that doesn't cause magical slowdowns?
 
um... that's a big topic...
Completely dependent on what you're doing.
 
Anything small enough?
 
For starters, I have a long list of performance gotchas that I keep in mind.
 
Perhaps the most important off that list? :)
 
I don't think I can enumerate them since I wouldn't be able to recall them unless the situation comes up. (at which I can start suspecting things)
The most important one would be cache.
Cache by far I would say...
 
8:08 AM
Alright
 
For the things that I write, register spilling from having too many variables is also big. But I would say it's rarely a problem for OOP applications.
branching and nested indirection is another biggie
function pointers, virtual method calls, all of them can be pretty bad under certain situations
 
Ok. What do you mean about branching?
 
@ScottW I wholly depends. I have recently found floats to be faster than ints (let me find it)
 
@ScottW There's generally two major factors of speed at this level. Latency vs. throughput. Integer arithmetic has lower latency than floating-point (except for division) But floating-point throughput is as high as (sometime even higher than) integer thanks to SIMD
@Pubby If-statements, loops, anything that affects the flow of a program.
 
@Mysticial My Top 1: "To avoid magical slowdowns, profile" - that way, at least the slowdowns will not be 'unseen' (might be harder to explain, of course, but good profilers show cache utilization too)
 
8:12 AM
Processors are good running large blocks of straight-line code.
And not so much if it's full of branches.
 
@sehe Any recommendations on a good profiler?
 
@sehe In general, profilers don't really tell me anything that I don't already know. But that's probably because I have enough experience to sorta know what's wrong when it becomes apparent.
 
@Mysticial How does one decide when to have 2 loops instead of one (like that one question)?
 
@Pubby That... was one of the harder ones... I wouldn't have suspected it - let alone believed it until I reproed it on my own machine.
 
@Pubby I use iperf, oprofile and valgrind (all linux specific, though). VTune seems to be good for Windows (with Intel?) I hear
 
8:16 AM
They free?
 
@Mysticial Yeah. By that token, no slowdowns are magical for you
@Pubby All of them AFAICT (need to check VTune)
 
The true answer to that loop question actually turned out to be outside of my knowledge at the time. Although I had already suspected alignment within a minute of seeing that question.
 
@Mysticial: The Q was 'how to avoid magical slowdowns' - the generic solution is to convert 'magical slowdowns' into 'explicit/visible slowdowns'
 
@sehe Generally, I can "feel" when something isn't right. And that's when I start digging.
 
@Mysticial One more thing, is allocating in powers of two only problematic when it reaches the size of the cache?
 
8:19 AM
@Pubby Allocating isn't the problem itself. It all boils down the addresses that you access and in what pattern.
 
Assuming I'm just iterating through
 
@Pubby I might suggest interesting reading: pi.pdf by a certain gentlemen we know
 
The dumbest "magical slowdown" I've encountered myself was because I forgot to add "-O2" to the compiler options. It took me about 5 min. to realize that something wasn't right...
 
@Mysticial I had that happen on occasion. Though it didn't take me 5 minutes to find my numbers were off, it took me about 3 minutes to realize my program was taking too long and abort it
 
The most notorious "magical slowdown" I've encountered took 2 days to fix.
It had nothing to do with my code...
It turns out that when I changed my hard drive configuration, one of the hard drives was rejecting one of the adapters, and effectively cut the bandwidth to it in half... sigh...
 
8:25 AM
@Mysticial that's mean
 
As for how I figured out the denormal question. It's something I regularly encounter when I'm doing micro-benchmarks. Whenever I forget to zero the dataset, the performance tanks because uninitalized data tends to have a high probability of being denormal.
 
Agreed the most magical of slowdowns happen outside your periferal vision - outside your program, mostly. Filesystem is a good one. logging is another one (even if disabled).
 
Though I did spend about 15 min. staring at the disassembly of the two snippets side-by-side thinking "what the fuck?!?!" before I finally started to suspect denormals.
 
@Mysticial Things like that: you need to experience them once in order to recognize them in the wild. Perhaps twice to anticipate them. Or just once, if you're performance-minded.
In fact, this is one of the reasons to linger on SO/C++: you get nuggets of experience that is hard to get in your own limited field of work, and you can store them off as 'latent' knowledge, a poor but valid substitute for the experience
I suppose this is what college is (should be?) all about as well, largely.
 
@sehe Definitely, my C/C++ has gotten a lot more, should I say "pedantic" since I've joined SO.
I bet when Jon Skeet answered the timezone question, he was in a very similar situation as I was when I answered the denormal question.

Read the question: WHAT THE FUCK?!?! Are you serious?!?!
Play around with it a bit... figure it out and get really excited -> post answer...
 
8:35 AM
@Mysticial For me too, in a good way. I stuck to what I knew way more before SO. Now I have become much more confident to use things like boost, allocators, etc. It is about knowing your stuff (even) better, I feel
 
I also learned what a trigraph is. :)
 
Don't forget digraphs ;)
 
And that is, after 10 years of doing intensive C++ hacking (built my own iterators, container adaptors, back when there was (virtually) no boost and basic template support). So there should be a basis of hands-on, lowlevel understanding, in my opinion
 
Actually, you probably should forget them
 
@ScottW There is no substitute for hacking. I can tell you, since I started 'working' on SO, I put in a lot of 'extra-curricular' programmer hours just to consolidate the knowledge I was trying to gain (mainly everything C++0x/11)
 
8:38 AM
There's two other very good "WTF-type" performance questions that I've answered. But neither of them were well suited to an average reader, so neither of them got highly upvoted.
 
@Mysticial Which ones? I want to read them :)
(probably, already have...)
 
35
Q: C++ vs Java? Why does the ICC generate slower code than VC?

thesaintThe following is a simple loop in C++. The timer is using QueryPerformanceCounter() and is quite accurate. I found Java to take 60% of the time C++ takes and this can't be?! What am I doing wrong here? Even strict aliasing (which is not included in the code here) doesn't help at all... long long...

It's a TL;DR... by far
8
Q: Why c++ program compiled for x64 platform is slower than compiled for x86?

KolKirI've wrote program, and compiled it for x64 and x86 platform in Visual Studio 2010 on Intel Core i5-2500. x64 version take about 19 seconds for execution and x86 take about 17 seconds. What can be the reason of such behavior? #include "timer.h" #include <vector> #include <iostream> ...

Too much assembly and low-level stuff.
26
Q: Why does compiler inlining produce slower code than manual inlining?

Johannes GererBackground The following critical loop of a piece of numerical software, written in C++, basically compares two objects by one of their members: for(int j=n;--j>0;) asd[j%16]=a.e<b.e; a and b are of class ASD: struct ASD { float e; ... }; I was investigating the effect o...

Also too much obscure low-level stuff
 
Morning
 
@ScottW Well... k, I'm stretching it... :P
 
I some how managed to forget to eat breakfast this morning
I didn't notice until my GF asked what I had
 
8:43 AM
@thecoshman burned...
 
@Mysticial not sure if that really works in this situation
my GF loves eating cereal for all meals
 
good morning everyone
 
@ScottW And also. Don't under-estimate the the power of WTF-type questions of any kind, performance or not. If you run down the list of top questions, many of them (excluding the non-constructive ones) are WTF-type.
 
really not in a working sort of mood... still
 
Jon Skeet's top answer is a WTF-type.
The Trigraph question is a WTF-type.
If you look on the month-tab. Two of the top 3 questions are WTF-type.
*well, the denormal question is still there as one of the two.
This one is also WTF-type if you don't know floating-point.
This one is arguably the biggest WTF-type I've seen on SO.
 
8:49 AM
@ScottW Exactly my thought. This man has a big ambition - 57 is way more than I ever expect. I'm not hoping for reddit/slashdot scale. I just hope to be recognized by the few fellow niche fequenters (like on the Vim question yesterday). Whopping +75 rep
 
this is probably a weird question, but what do you all think about a gui widget manager that monitors average per-event processing time at the widget level, and for the n highest processing times calls the appropriate event handler in a new thread, where n is some user-defined value (perhaps # of cores)?
 
Anyways, 3AM here, need to sleep. night
 
std::future excited me :)
 
@kmore I think it would be unintuitive for the programmer, and hard to make robust.
if you want to do something like that, ditch the monitoring, and just handle all events in a thread pool
 
@kmore lets just hope that std::future can learn from std::past
9
 
8:53 AM
then the default case is that events can be handled by another thread, so the programmer won't be surprised when it happens
it'll also be more efficient, because it saves all the monitoring and bookkeeping, and gives you a better scheduling algorithm to boot
 
@jalf: I suppose that would work fine, too. it'd just be awful for the "paint" event that gets stuck by a longer one
 
problem is that nearly every GUI framework is inherently singlethreaded, and trying to call into them from multiple threads is going to break everything. So you'll more or less have to write your entire GUI framework from scratch
 
@Mysticial Nice. Never saw that one
Someone is starring all my messages :)
3
 
9:06 AM
@Mysticial this one takes the biscuit:
> I think everything is much more deeper that this. If you multiply this number by the height of Pyramid of Khufu and then multiply every third number by 2012 you will get exactly 1/666 length to the Alpha Centauri. – serg Jul 17 '09 at 15:15
 
9:26 AM
@kmore first, that's how it has worked for the past 30 years on every OS under the sun, so I don't think that'd be a problem. Second, it'd only get stuck if all threads in the thread pool are busy with a long-running event handler
 
9:39 AM
@jalf yup, that whole point seemed to elude me at 4 in the morning
 
10:04 AM
oh god this coffee is foul
I think I shall just do with out
 
10:17 AM
u meen aw-foul
 
Why does "fucking" always come up when Europe is asleep?
 
@CheersandhthAlf no I literately mean it is a bird that is commonly refereed to as foul
 
where?
 
in The Assembly on The Stack Exchange Network Chat, 2 days ago, by Ivo Flipse
Please note that anything you say is this room can and will be used against you in any Meta discussion
^ this room gives me the creeps.
 
10:29 AM
ooops, just printed out a largish document that I already had a copy of say on my desk :S
 
@thecoshman I once did that with my slow-ass ink-jet printer. It was extremely annoying.
 
The slow Android Facebook app is slow
@ScottW I haven't tried it yet. I haven't found it yet, now that I think about it...
 
you fool of a took, that's rofl
 
10:45 AM
although, why exactly does the Pakistani Defence site have smileys, I don't know.
perhaps they rofl at the Government's stupid policies?
 
@IntermediateHacker I am worried, very worried
 
10:56 AM
@IntermediateHacker it shouldn't - there's humor, there's transparancy - much as opposed to Teacher's Lounge or some Mod meeting :)
 
I know I am not an English masters, but it is grating on me the way this document keeps using 'in case' rather then 'if'
 
@IntermediateHacker link? no smileys over here
 
@sehe the rofl smiley he posted before is hosted on the forums section of the website.
 
@sehe defence.pk/forums/images/smilies/cute/rofl.gif <--
weird, isn't it? I thought the army didn't have any sense of humour.
 
11:21 AM
sigh... there is a strong case for sentry guns that automatically target phones that ring for more then a minute ¬_¬
 
11:54 AM
@thecoshman an EMP generator could be more effective
 
@CheersandhthAlf but that would fuck my phone too
and balls am I carrying around a half tonne of lead
any way, time for a pre lunch coffee :D
 
Hi all, may I ask a design pattern question?
 
^ Not exactly the ordinary Norwegian "lapskaus", this version is like the luxury edition, he he :)
 
I thought to use a strategy pattern to exchange a function (having different behaviour). But now, I think I cannot use it because inside the function I need access to variables/members that should be in the parent class. Is this more a factory pattern?
 
12:12 PM
hey guys
 
i'd say it sounds more like the "parameters" pattern. the idea of this pattern is to declare so called formal arguments, and pass so called actual arguments in the call. suitable google-foo should be able to find a diagram?
 
@spikey std::function<Ret(Arg...)>?
 
if that doesn't help, use a managed abstract singleton with a factory envelope?
 
@DeadMG hmm.. I am not using stl but you mean to pass the needed data as a parameter to the strategy-function. So I put the data in the context class.
 
12:18 PM
@spikey If you're not using the Standard library, then come back when you are.
9
 
ok, did I miss the room rules? hmm. nothing writen about stl. but thank you anyway.
 
it's not in the room rules
but if you want me to help you, then I'm not going to waste my time when there's a perfectly good Standard class that does what you need
else would simply be a waste of my time
 
void always makes me feel so empty
 
eh
I woke up to a bunch of memories of being endlessly harassed at 15 and 16
don't think void has a handle on that
 
argh, I’m having a dispute with James Kanze and I think I fundamentally fail to understand what he wants to say
 
12:24 PM
@DeadMG harassed by who?
 
perhaps one of you can explain or has an example pertaining to this?
See comment discussion here:
0
A: C# Garbage Collection -> to C++ delete

Konrad RudolphYour problem is that you are using pointers in C++. This is a fundamental problem that you must fix, then all your problems go away. As chance would have it, I got so fed up with this general trend that i posted the following tweet yesterday: @klmr: I’ve created slides for a “Modern C++ St...

 
@TonyTheLion Various peers.
 
meh, why didn't you harass them back?
 
@KonradRudolph My experience was that he didn't understand what I had to say.
 
(To be clear, I think he may have a point but I don’t see it and he doesn’t provide an example)
 
12:33 PM
the point he's making is that shared_ptr doesn't work for objects which have a death condition other than "When nobody is left pointing to them"
which is true, but really besides the point
 
I agree with @KonradRudolph. And I'm reminded of the discussion on shared_ptr in the second panel on GoingNative. There STL explained ownership as a directed acyclic graph (where weak_ptr can be used to break cycles).
But the point is that logical relations and object lifetime are related.
Although now I'm not sure if I can relate STL's remarks to the discussion you are having now.
Ah well..
 
ask him to come visit the chat
 
James?
 
yes
 
Konrad should do that if he wants to. It's his discussion :)
I'm at work currently.
 
12:39 PM
@DeadMG I can actually not imagine something like that, do you have any example? I can assume an object (e.g. a socket) "dying" logically, but that's a completely different problem than the actual object lifetime. std::weak_ptr is a perfect example of this imho.
 
@KillianDS He would use an example like a window object, I believe.
 
@DeadMG Yeah, I thought so, a destroyed window is imho just another object state imho and has nothing to do with the object lifetime. But we'll see if he gives an answer to Konrad :)
 
I just realized that I could encapsulate the message loop in an object, store it in a shared_ptr and share it among all windows. Destroying all windows results in the message loop being destroyed, which leads lead to application close (due to reaching the end of the main function).
 
well, IMO, a destroyed window is a destroyed Window object
 
lol Linux Mint came with Firefox 5, so I did an apt-get update followed by an apt-get upgrade. The upgrade finished with this error message:
Errors were encountered while processing:
 /var/cache/apt/archives/gstreamer0.10-plugins-bad_0.10.22-3_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Do I need to worry?
 
12:44 PM
but there's certainly no need for it to be anything except unique_ptr
 
@FredOverflow can you install other packages?
 
@FredOverflow That's lousy error reporting.
 
# apt-get install sl <— most awesome package
 
@rubenvb I see a steam locomotive now. Am I hallunicating?
 
12:49 PM
@rubenvb yep that one.
 
anyone here know wince?
 
@janneob you?
 
@janneob it's same win32
 
only more brokener
and limiteder
 
Oh great, after the update, I can no longer see the crosses in configuration dialogs. That is, I cannot tell whether or not I have checked a box. I wanted to post a screenshot here, but apparently, "Image type png is not supported". WTF?
 
12:52 PM
can i ask question about the wince image?
 
I got to go, check ya later guys
 
I'll try the Windows method: restart the system and hope everythings works then.
 
@FredOverflow serves you right for using a derivative of a derivative of Debian.
 
@janneob there is the SO for questions
 
@Abyx SO?
 
12:54 PM
yep, SO.
 
what is SO?
 
aka stackoverflow.com
 
ok, thanks
 
@janneob the site you had to visit to get here.
 
12:55 PM
@janneob come here again, if you'll have another "can i ask question" question
 
thank you
 
no prob
 
@ScottW I thought I was going to play Minecraft but the server appears to be offline :P
 
lol, after the update, Linux wouldnt even allow me to restart the system due to missing rights. Are you fucking kidding me?
 
12:59 PM
And now when I boot Linux from the hard drive, I cannot even log in, because the user list looks funny. Must be the same graphics bug that prevented me from seeing the crosses in Firefox.
 
strange how you have so much trouble with Linux, I just installed it and it worked
 
Y U SO HARD ON BEGINNERS, LINUX?
 
@TonyTheLion why Obama? nearly every country have one
 
@TonyTheLion Oh, installing was the easy part. Its the update that went wrong.
 
1:00 PM
@Abyx first thing that came to mind
 
@TonyTheLion now try to restart it
 
@Abyx I have many times, never a problem
 
@TonyTheLion Which distro?
 
ubuntu
 
@TonyTheLion so it's insecure linux
 
1:01 PM
@Abyx wut?
how's that even relevant?
 
@TonyTheLion Are you able to watch DVDs?
 
@FredOverflow I don't watch DVD's on Linux
only on my win machine
 
@TonyTheLion Are you able to watch AVI files and listen to MP3s?
 
@FredOverflow donno, never tried
 
@ScottW dunno, probably most of them, what else should they do? just solve sudokus
 
1:05 PM
while ubuntu user interface may suck, it installed nearly ok. the only thing missing was keyboard support, could not type e.g. €. fixed that by googling up a config file.
@FredOverflow i haven't tried but i think mplayer works great in lunix
 
0
Q: Undefined Reference? But I've implemented the function

IntermediateHackerThe Code window.h typedef struct { WNDCLASS* wc; HWND hwnd; WNDPROC proc; } PRO_Window; PRO_Window* PRO_WindowCreate(int width, int height, const char* title); window.c I don't think this is important though... PRO_Window* PRO_WindowCreate(int width, int height, const char* titl...

 
@FredOverflow Mint/Ubuntu has "restricted codecs" packages, which include mp3/avi stuff
Otherwise just use VLC, it eats everything.
VLC on Windows does not sound as good as MPC-HC though. It's really a big difference :(
 
@IntermediateHacker i downvoted
 
@CheersandhthAlf no prob.
 
@StackedCrooked STL = Stephen T Lavavej? Never heard of that guy, I might have some reading to do.
 
1:10 PM
@IntermediateHacker maybe one is extern "C", anyway reduce it to SSCCE
 
@KonradRudolph Indeed. He's the std implementor for Visual Studio.
 
ah, cool
 
@IntermediateHacker thanks. i am pretty harsh about such things. because it's problem for many readers, generated by one poster.
 
@StackedCrooked So I guess you are referring to this talk?
Or the panel discussion?
By the way, missed opportunity. Shaded glasses? Where’s the eyepatch?
 
1:13 PM
ah cool
 
@KonradRudolph he is (1) one-eyed, (2) has evidently read "a fire upon the deep" and its prequel, and (3) maintains the STL at Microsoft.
 
pity I actually have to work now :(
 
don't really know about the one-eyed thing but i seem to remember that
 
@KonradRudolph There is a question on when it is appropriate to use shared_ptr. The amazing thing is that four different persons give four different answers. And they are all correct.
 
@CheersandhthAlf So in summary, total badass? ;)
 
1:14 PM
@KonradRudolph yes :-) he also used to maintain a g++ + tools distro, i think. at his pham nuwem web site.
+ makes video lectures that some people find very illuminating (i haven't seen them)
@StackedCrooked the simple answer is, use shared_ptr where you would use a potato.
 
I found his talk a little hard to follow. He goes deep in the implementation details and he speaks very fast.
@CheersandhthAlf If feel that this must either be a very smart or a very dumb joke.
 
@StackedCrooked you know, potatoes can be used for almost anything.
 
problem solved. I'm an idiot. -_-
next time I'll try to solve it myself before running to SO.
 
?
was it the const?
 
> California accidentally became the first state to legalize pornography. ಠ_ಠ
I don't believe that one can accidentally legalize porn
 
1:24 PM
perhaps they where trying to be the second, but rushed it a bit
 
@TonyTheLion depends on the various different definitions of "porn" involved, perhaps not just by different parties or in geographical locations, but perhaps also over time. note that current western society, in particular the US, is extremely prudish compared to most cultures that have been and do exist on planet Earth. and this is a relatively recent phenomenon, just in the last few hundred years
 
Americans are prudish. Examples are: Republican presidential candidates, NippleGate, and other numerous law suits against "Family TV stations" where some minor obscenity happened.
 
NippleGate?
 
@DeadMG michael jackson's sister accidentally displayed a nipple in a tv show. as we all know seeing such thing is dangerous to males in the age group 7 through 17
 
1:34 PM
oh noes?
 
and there were numerous repeats in Hollywood and elsewhere.
@CheersandhthAlf the Prude Police would have that upper age be drawn to 21 I suppose, as if that helps prevent all the teenage pregnancies. Prime example: under age daughter of.... Sarah Palin.
The US is a joke, in this sense.
 
is there any sense in which they are not?
 
Hmmm. Is that a trick question?
 
@DeadMG comedy :P
 
@thecoshman most US Comedy is born out of their prudishness/prudence/prudeliciousness (huh?)
Stand up comedy that is. Although I did enjoy Robin Williams a lot.
 
1:41 PM
Americans have very slap stick approach to comedy, it needs to be very obvious to them when to laugh
 
1:51 PM
@rubenvb Meh, just re-installed Linux Mint Debian, took only 5 minutes, and I'm simply not gonna care about updates. Firefox 5 ftw xD
I got g++ 4.6.1 that's all that really matters to me.
 
Firefox 5 is stoneage.
Isn't there a debian Firefox update repo or something. There should be...
 
@rubenvb Firefox 5 was released June last year.
 
Mint does look nice
 
@FredOverflow wow they did do a number on those releases didn't they ;-)
 
Why on earth did they do that, anyway?
 
1:55 PM
Still, 5 vs my current 13pre sounds awfully old...
@FredOverflow to compete with Chrome I guess (and maybe force websites to undo their per-version-of-browser hacks)
 
yeah, Chrome kicked everyone's ass with it's versioning as well as it's UI
 
the versioning suckz
unfortunately firefox adapted that too
what is the most recent version of chrome? 38?
 
Chrome's versioning is the best
 

« first day (508 days earlier)      last day (4423 days later) »