« first day (563 days earlier)      last day (4384 days later) » 

5:00 PM
What's the hibbidy?
 
@Fanael I don't keep the source code to Windows and a kernel-mode profiler lying around.
 
@stdOrgnlDave That's possible using streaming SSE writes. It saves the bandwidth of moving the data from memory into the CPU. But you still have to send the zeros from the CPU to memory.
 
user784668
@DeadMG I was thinking about something more open, you know.
 
@Fanael What's the point in profiling a different operating system to the one I'm using?
 
user784668
@DeadMG How was I supposed to know what you're using?
 
5:02 PM
@DeadMG And if you did, M$ would hunt you down and... either hire you, or shoot you.
 
@Mysticial "send the zeros from the CPU to memory"?
 
Not necessary zeros, but whatever you're writing. They still need to go from CPU to memory.
 
user784668
@DeadMG Anyway, the NT kernel is zeroing pages in a background job, it doesn't do it when allocating one, unless it runs out of zeroed pages.
 
@Fanael I don't have to be using Windows for it to be a valid point that not all kernels are insta-profilable
 
@Mysticial I always thought it would be neat if RAM had a thingy the CPU could do to zero out entire pages at once.
 
5:06 PM
@MooingDuck That would definitely be nice. My 64GB machine takes almost a minute to allocate 60GB of ram. All because of the OS zeroing.
 
@Mysticial I'm looking for memory-to-memory
 
@stdOrgnlDave Current commodity hardware doesn't have memory-to-memory transfer capability. So it all goes through the CPU if you need to memcpy().
 
@Mysticial If you're desperate, have you considered writing your own kernel addition?
 
@Mysticial: K, here's my test code: ideone.com/i5QMt. You usually glance at my code and find 5+ bad assumptions, did I fail benchmarking this time too?
 
@DeadMG I just reuse memory manually. So it's a solved problem for me.
 
5:09 PM
@MooingDuck Considering that both functions could be trivially optimized as return (char)count;
 
@MooingDuck I'm in class right now, so it's hard for me to give my full attention to it. Gimme 20 min.
 
@DeadMG I'm checking the asm now, MSVC didn't optimize out the allocations. They call operator new[] and _alloca_probe_16 respectively.
@Mysticial np, you have no obligations
for my run of MSVC10, the alloca version is 668.3x faster when you subtract the nofunc times.
 
run again, cause I came back with only 6x
 
@DeadMG 6x is big too, in tight loops
 
only 6x, lol. Of course it's a highly contrived example.
 
5:13 PM
actually a little closer to 8x, but not the point
@MooingDuck Right. But why the fuck would you not use a custom allocator?
 
@Mysticial I admit to that. 99.99% of the time I would replace alloca with new (and have done so)
 
using new[] and delete[] directly is un-representative
 
@DeadMG I don't have one, other than the ones that come with VS that I can't figure out how to use.
 
@MooingDuck It's easy to write a memory arena allocator. You can download one. You can also get object pools&stuff from Boost.
 
nofunc took 0.016 (-798386064)
allocator took 20.765 (-798850848)
alloca took 0.047 (-799315632)
(When you subtract nofunc, that's a 668x difference)
@DeadMG I should.
 
5:15 PM
@MooingDuck My allocator comes back at just 0.3
 
@DeadMG hmm, wonder why mine is performing so bad
 
running from within the IDE?
 
@DeadMG facepalm yes. Thank you.
 
welcome to the debugging allocator
 
nofunc took 0.031 (-798386064)
allocator took 0.297 (-798850848)
alloca took 0.062 (-799315632)
much better
Alright, now I can increase my test sizes
 
5:18 PM
swapped out new and delete for HeapAlloc and HeapFree
now 0.027 nofunc, 0.249 allocator, 0.044 alloca
 
I cranked `count` up to `100000000`.
nofunc took 2.218 (1937456563)
allocator took 27.061 (1887499110)
alloca took 5.235 (1837541657)
@DeadMG better but not significantly so
 
so now we're at about 5x slower than _alloca
 
I'm still wondering why Ideone threw a bad_alloc
 
probably doesn't have much memory available to it
alright
now compiling as 64bit
nofunc 0.024, allocator 0.186, alloca 0.024
 
Does anyone know of a way to write a function template that has an overload or something that will be called when the function template is used with any class that's a base class of a certain class
 
5:21 PM
@DeadMG I'm allocating less than 4k. I'll try lowering that.
 
IMO you need to go above RAND_MAX
 
@SethCarnegie use an overload?
 
I re-wrote and am testing part of this, how is it that you are taking rand()+1 and allocating that?
 
@MooingDuck yeah, how
if I make the overload use a Base&, then the child classes use the general template, not the specialised one that takes a Base&
 
@SethCarnegie or use SFINAE
 
5:22 PM
@MooingDuck I tried but I'm not good with it
 
user784668
@MooingDuck It runs on a platform where RAND_MAX is 2^31.
 
@SethCarnegie me neither
 
time to pull in a memory arena allocator
 
@Fanael oh hey, I removed the code that keeps it less than 4k. Oops
@DeadMG that'd be good
 
user784668
@MooingDuck And I wondered why it's so slow on my system.
 
5:23 PM
@DeadMG how is it you're using rand()+1 for a size? that can get to be pretty big...
 
user784668
nofunc took 0.01 (1310579395)
allocator took 9.8 (1309986438)
alloca took 0.01 (1309393481)
 
@stdOrgnlDave RAND_MAX on MSVC is only 0x7FFF
@Fanael That's a debug allocator, no doubt.
 
user784668
@DeadMG That's the effect of many big new and delete.
 
This is what I tried
struct A { };

struct B : public A { };

struct C { };

template<typename T>
void f(const T& a, bool b = true) {
    cout << "not special" << endl;
}

template<typename T>
void f(const A& t, bool b = is_base_of<A, T>::value) {
    cout << "special" << endl;
}
but they all call "not special"
 
user784668
@DeadMG RAND_MAX is 2^31-1 here.
 
5:26 PM
amazin that your alloca didn't stack overflow then
 
I'm allocating an array in order to take out overhead of rand() (yeah, stupid, who cares) and getting kernel breaks on delete[]
 
user784668
@DeadMG I didn't setrlimit.
 
user784668
Now with modulus:
 
user784668
nofunc took 0.12 (-1464148726)
allocator took 0.7 (6149130)
alloca took 0.11 (6149130)
 
@Fanael I don't even know what tat function is.
 
user784668
5:28 PM
@DeadMG Some POSIX shit to set resource limits, including stack size: pubs.opengroup.org/onlinepubs/007904975/functions/…
 
well that was fun
I forgot to free the memory arena on occasion and the program consumed practically all my memory
Windows did a fantastically poor job of not completely dying at the hands of the process
 
user784668
I just imagined that on my system.
 
user784668
Oh hai, swap! *hangs*
 
user784668
^ that's more or less what happens when Linux is pressured into swapping a lot.
 
hotlist 538
this is madnezz
 
5:33 PM
Hi guys quick question - should I include the source files to my classes in my include/ directory with my definitions?
 
@DeadMG I made sure to turn exceptions off among a few other things ideone.com/Iuf9H
 
@user908041 I don't understand your question. Headers should have declarations and be in the include directory. Source files should be in a different directory and contain definitions. (With lots of exceptions)
 
Hotness at 556... damn...
 
@DeadMG: I did the pools wrong I guess: ideone.com/081CM
 
@MooingDuck First thing I see wrong with the benchmark.
It's susceptible to lazy page allocation.
 
5:39 PM
@MooingDuck Yes, you definitely did.
 
The OS doesn't actually give you pages until you finally access them.
So I'd suggest you use calloc() instead.
 
@Mysticial There's a write in there, that MSVC didn't optimize out (AFAICT)
 
@MooingDuck You're only writing to one location. Not the entire block.
At least write to every 4k.
 
@Mysticial I'm (intending to) allocating less than 4k
 
user784668
@Mysticial It's never more than 4k. Unless he screwed up that again.
 
5:40 PM
oh, ok.
I saw this:
#ifdef _DEBUG
        int count=100000;
#else
        int count=10000000;
#endif
and it looked like more than 4k.
 
@Mysticial number of loops/tests
 
@MooingDuck Yeah, I realized that about 20 seconds later. :)
 
Hmm, I find myself avoiding eating now that I have a retainer-thing. It's just too much effort taking it out, eating, cleaning everything, then putting it back in. It's my new weight loss program!
 
user784668
What? test.cpp:5:37: fatal error: boost/pool/pool_alloc.hpp: No such file or directory
 
user784668
I thought I have boost installed.
 
5:43 PM
it is taking msvc about 30 seconds to do what GCC was doing in .16
 
@stdOrgnlDave you probably made a mistake
 
Otherwise, I don't see much else wrong. Though a more realistic benchmark would still be to write to and read from all the allocated memory once.
 
OK
Dead's Custom Memory Arena
0.04 sec
compared to alloca's 0.023 sec
so less than 2x
 
@SethCarnegie you can't specialize on the value of a Boolean parameter. The bool isn't helping you at all there.
 
user784668
Just admit it, alloca sucks.
 
5:45 PM
@DeadMG that's very close. For very very special specific conditions I would still use alloca.
 
@MooingDuck I haven't even optimized the memory arena implementation.
for example, the arena automatically tracks destructors, whereas alloca does not
 
@DeadMG it tracks destructors? Interesting
 
@DeadMG I made sure to turn off all exceptions that make sense to including the new bad alloc extension, also to add MSVC support. ideone.com/Bd0nf
 
@stdOrgnlDave what bad_alloc extension?
 
@DeadMG exception, sorry. hey, you never free() from alloca!
 
5:48 PM
@stdOrgnlDave alloca has no free, you just exit the scope
 
of course there is no free() for alloca,
 
@stdOrgnlDave you should increase count, make the test take as much time (less than 5 seconds) as possible.
 
of course
the way I've used the arena is actually somewhat similar to garbage collection
 
@DeadMG cool
 
and equally
I didn't implement a few obvious optimizations when emptying the arena
which could provide interesting speedups inthis case
 
5:51 PM
@stdOrgnlDave if you run from inside MSVC, it uses the debug heap, which is loads slower (even in release mode). Build in MSVC, but then run it from the command line. Waaay faster.
 
@MooingDuck is there any reason for such a behaviour?
 
@DeadMG Memory arena as a memory pool of some sort (big buffer :)), if you don't mind my askin' ?
 
@bamboon because when VS launches a process it makes it use the debug heap, so it can find/catch errors for you. (I assume)
 
@MooingDuck yeah, but why does it do that if I say release mode + do not debug
 
@DeadMG is all memory getting reclaimed during the test?
@bamboon I dunno.
 
5:54 PM
@MooingDuck I'm pretty sure it is.
 
@MooingDuck I'm new to C++ and I'm just a little confused on how to arrange my source directory. As I take it at the moment, I should have my definitions in include/ e.g include/triangle.h, but should I have the source for the class in include/triangle.cpp or for instance src/triangle.cpp?
 
@DeadMG So long as you aren't cheating :P
 
Sorry for being a bit vague :>
 
@Mysticial 642 ^^
 
huh
 
5:56 PM
@bamboon Yeah this is crazy. Does anyone remember how high the auditor question got? That was well before I joined SO/SE.
 
strange problem
 
include / headers *.h | *.hpp files are the files you want to share usually containing prototypes, those are in "include"
 
Anyways, off to lunch...
 
apparently, 1 + rand() gives 21,000
even though RAND_MAX is only 0x7FFF
 
Xeo
Holy crap @ the latency question by @Konrad oO
 
5:57 PM
source files (implementation files) like *.c | *.cpp contain definitions and are in "source"
 
oh, wait, 0x7FFF is probably a lot more than 4k
who said that you were only ever allocating 4k?
 
user784668
@DeadMG 0x7FFF is 32k-1
 
user784668
@DeadMG He fixed it, the code now says 1+rand()%4000.
 
@DeadMG revised code, ideone.com/nsxtx (how the hell do you link in here). removed any exception throwing, added malloc, made sure cout was flushed
 
lol
now I've added the %4000, all three functions execute in 0.003
 
5:59 PM
ScarletAmara - but my question is regarding the body/definition of the class and its members. As far as I'm aware that should be separate to the declaration in the .h.
 
@DeadMG yeah, sorry about that. The first version I'd rearranged some stuff and accidentally dropped the modulus.
The intent was to only deal with one page of memory.
@user908041 .cpp files all go in the src directory. Usually include is also in src, but not always.
 
@user908041 Prototypes are in .h and definitions in .c, i think i did make that clear :)
 
user784668
@ScarletAmaranth .c?!?
 
Ah ok thanks for clearing that up @MooingDuck :) and @ScarletAmaranth, thanks but that doesn't help much with the directories :p
 
@user908041 the class definition goes in a header (in include), but the definitions of the member functions go in source files (in src)
 
6:01 PM
anyway It's cleared up now, I'm good to go :p
 
@Fanael Meh, CBA typing the whole thing twice :)
 
thanks a bunch @MooingDuck
 
facepalm
 
@user908041 I'm glad you got it. It's very simple: .h in include, and .cpp in src.
 
omg, every day at least 2 ppl come in and ask that question
 
6:02 PM
yes @MooingDuck, I just wanted someone to clear that up before I started throwing everything in include/ and got myself in a bit of a mess
 
I mean, the only real advantage of C over C++ is that it's faster to type the extension of C files.
 
huh
 
hmm, I wonder if I hit "build all" instead of "build project"
 
the %4000 has really cut down the time of nofunc and alloca, for some reason..
 
@MooingDuck It will explode! :)
 
6:03 PM
@ScarletAmaranth <vector>?
 
@MooingDuck Wut ?
 
@DeadMG it cut the time of nofunc? That's wierd
@ScarletAmaranth C++ has fewer characters than C does.
 
What is this memory arena you kids are talking about :) ?
@MooingDuck But cpp / hpp are longer than c / h :)
 
@MooingDuck Yeah. For some strange reason, both nofunc and alloca take virtually no time at all to execute.
 
@ScarletAmaranth standard includes don't need that, and C and H (capital) were used for C++ for a long time.
@DeadMG alloca makes sense (kinda), but nofunc doesn't. :/
 
6:05 PM
and now for some reason, the memory arena takes 20 seconds to run instead of the previous
 
I'm googling this memory arena yet I'm finding weird stuff :(
 
ah, I think I must have lowered the maximum memory a little too far
oh well
yay
nofunc, 0.021, allocator 0.026, alloca 0.026
 
Cool. John Carmack is on SO
 
SU also.
 
And yes I believe that it's John Carmack himself. He has ~200 rep and a great answer badge.
 
6:10 PM
so in summary
my memory arena > you
 
Type mismatch.
 
roflol
 
It seems like @DeadMG thinks he's pwning the world again.
 
I took out deallocators and the paging got so bad I had to hard reset
windows fail
 
@stdOrgnlDave Happened to me too.
 
6:11 PM
@DeadMG very impressive
 
@rubenvb he's also a "superuser" whatever that is
 
@ScarletAmaranth A memory arena is a very small high speed allocator. (ish)
 
@DeadMG how'd you get them to get so low? looks like the limit isn't allocation now, need more iterations
 
@MooingDuck Thank you fine sir.
 
omg, superusers.stackexchange.com seriously?
 
6:12 PM
@stdOrgnlDave no, he prolly subscribed first to superuser first.
 
@ScarletAmaranth they're usually tuned specifically to your code, so they can be tricky to use sometimes.
 
@stdOrgnlDave you're new here, aren't you?
 
@rubenvb define "new." if by new you mean 723 rep, on multiple stack exchange sites, etc. then yes, I'm new here.
 
@stdOrgnlDave Memory arena allocators re-use their internal memory. I only call new once in the whole shebang.
 
@stdOrgnlDave new = allocation + construction
 
6:14 PM
@stdOrgnlDave yet you're surprised by superuser.com?
 
If i have an std::vector<UserType> in which I'm trying to find UserType.primitiveType, and i want to be checking UserType.primitiveType of each element and not the UserType itself, how would i go about making this dream come true :) ?
 
@stdOrgnlDave You want to see?
 
superuser.stackexchange.com doesn't exist
 
@ScarletAmaranth That's your third facepalm, of the day, and you personally account for 69% of all facepalms debited to Loungs<C++> in a whole week (9 out of 13)
 
@DeadMG same results with a placement new?
@DeadMG I think you need more iterations if they are all taking the same time (including the empty call)
 
6:15 PM
@sehe That makes me the ultimate face-palmer.
 
@sehe His forehead must be red by now :)
 
I'm already up to 1m
 
@ScarletAmaranth No, that's Freddy Mercury
 
oh, no, wait, I lied
 
@sehe True dat, i even did one freddy mercury facepalm here, a few days ago.
 
6:16 PM
they don't all take the same time
 
@ScarletAmaranth again, I don't understand what you're asking us.
 
the allocator runs faster than the empty function
/whistle
 
@ScarletAmaranth See, I didn't even count that :)
 
@DeadMG good optimizer?
 
probably just sub-level CPU effects
 
6:17 PM
@DeadMG probably. I've seen it happen before :(
 
I went up to 10m and the allocator is still faster than alloca, but now they're both a little slower than the empty
 
@DeadMG start doubting your oscilloscope.
 
@DeadMG quantum gravity getting you. I'm certain of it.
 
@MooingDuck I have std::find(std::begin(myVectorOfUserType) ... looking for myType.primitieType), how im i gonna convince it to be looking at each element's .primitiveType ? :) I mean i could working around that but that's not all that elegant :)
 
@DeadMG reallly? I personally feel it must be karma: the world is treating you nicely because you treat it so nicely
 
6:18 PM
@ScarletAmaranth you (probably) can't use find for that
 
@sehe I almost choked on my food.
@MooingDuck Thanks.
 
@sehe lols
 
@ScarletAmaranth As they say in Holland, that would be swatting two flies in one stroke :)
 
@ScarletAmaranth just write a function with a for loop. It's 3 lines of code
 
here
 
6:19 PM
@sehe Two birds with a single stone ;)
 
@ScarletAmaranth thx
 
@Xeo It’s been quite a ride :)
 
ideone won't accept it- probably doesn't have unique_ptr or someshit like that
but compiles clean in MSVC
 
@ScarletAmaranth You mean something along the lines of std::find_if(items.begin(), items.end(), boost::bind(&UserType::primitiveType) == myPrimitiveType);? (Btw, I don't think std::bind works here.)
 
6:19 PM
@MooingDuck ya, was just wonderin' whether there's no a legendary std::epicStuff usage for this :)
 
@ScarletAmaranth you can use std::find_if
 
@StackedCrooked Huuuh, that would be interesting, gonna take a look, thanks.
 
@DeadMG You forgot -std=c++0x: ideone.com/avahI, yet GCC 4.5 is not new enough
 
Yeah ill take a look at that.
 
@StackedCrooked just use a lambda?
 
6:20 PM
@MooingDuck Yeah, forgot about that.
 
I don't understand why it's making a fuss: ideone.com/XioxZ
 
@StackedCrooked I'd give an example, but I keep forgetting the lambda syntax
 
Yeah i actually am using lambda to return mytype.primitive type but i can't make it search trough the primitive types in array.
But find_if could work i guess ?
 
How do I set a limit to sprintf such that I don't get a buffer overflow? I want to do sprintf(str, "%i", some_num) multiple times, which might overflow.
 
@TonyTheLion you realize that foo<MyIterator>::value_type is MyIterator?
 
6:21 PM
@TonyTheLion Because value_type names a type? And you tried to assign it to a value?
ok
 
@KonradRudolph Google's top ranked result for 'pixel transatlantic' or 'monitor transatlantic ping' is already that SU post.
 
if you force inlining of alloca you overload the stack. I wonder if that's something to worry about when using alloca anyway
 
not quite as good as the results offered by MSVC10 on my machine, but still extremely good
 
@ScarletAmaranth yeah, find_if(begin, end, [](value_type) {return valuetype.primitivetype == myprimitivetype;});
(or something)
 
std::find_if(items.begin(), items.end(), [=](const Item & item) { return item.primitiveType() == myPrimitiveType});
 
6:22 PM
@DeadMG You can get GCC for Windows you know ;-)
 
Need to capture.
 
@MooingDuck And it will be comparing the value to find with the MyType.primitive ?
 
So you could test with a real benchmark
 
@DeadMG I'm happy with that
 
6:23 PM
@rubenvb I don't really see how running the code with MSVC10 is any different to running it with GCC :P
 
@stdOrgnlDave we never alloca more than 4k, we're fine
 
except that ideone probably doesn't pass decent optimization flags to GCC or something like that
 
@DeadMG It could surprise you. In both directions.
And you have no idea what system the code is run on.
 
@RMartinhoFernandes ohai
 
@ScarletAmaranth it will find the first element in items who's primitivetype member is equal to myprimitivetype
 
6:24 PM
@MooingDuck not if you force inlining
 
the minutae of the timings are irrelevant
what's important is that on both ideone and here, the heap allocation and free is perfectly competitive with alloca
 
@MooingDuck Interesting, how is it told that I'm looking for the primitiveType in the vector it's iterating trough ? (I do understand why the "value to look for" is a primitive type.)
 
@stdOrgnlDave it uses noinline and function pointers. Even then, I think it should do the de/reallocations anyway
@ScarletAmaranth the lambda
 
thus justifying my position that there is no need to introduce VLAs
 
@MooingDuck The lambda is not specifying stuff only for the third argument, that is, what to find ?
 
6:25 PM
@ScarletAmaranth are you looking at this code?
 
if you need high-speed low-size memory allocation then arenas serve that purpose just fine
 
@ScarletAmaranth it tells it what to find and how to find it
 
@MooingDuck but if you're running around alloca()'ing, generally speaking. that function can optionally be inlined, screwing you
 
@DeadMG I cede
 
6:26 PM
CMake 2.8.7 was a bug-ridden piece of crap.
 
Oki doki, thanks a lot, i was being a derp.
 
CMake 2.8.8 is a better so-far-unknown-bug-ridden piece of crap that works.
 
@stdOrgnlDave Optimizations that cause the compiler or program to change in functionality (crash/fail) are disallowed.
 
@MooingDuck so that means a compiler sees alloca and never inlines that function?
 
@stdOrgnlDave That's one reason I specifically made it un-inlinable.
@stdOrgnlDave I see your point, I'm not sure why I'm debating with you. sorry :/
 
6:30 PM
@MooingDuck np. I'm sure that they do check for that though.
one thing interesting here, I think VS10 uses 32-bit clib. malloc is about a second slower than new when using 64-bit target, but the same when using 32-bit target
that is disappointing :-(
 
hmm, apperently a 10 second sleep is not enough time for me to attach visual studio to a process.
 
@MooingDuck @StackedCrooked Thanks :-)
 
I come back from lunch and we're still talking about heap vs. stack allocation?
 
@Mysticial not really
 
@Mysticial got something better to talk about?
 
6:42 PM
@stdOrgnlDave let's talk about... um... uh... good point. :)
 
Does Stack Exchange still send out DMCA takedown notices?
 
@KonradRudolph Did someone just plagiarize that latency Q/A?
 
@KonradRudolph The CC lic requires attribution, and if you dont attribute, i expect do
 
@Mysticial yes
 
@KonradRudolph Put it on meta.
 
It says "Super User"
 
@KonradRudolph He attributes and links back. That's not breaking the terms.
 
and it links
 
oh, I didn’t see that
everything’s fine then
 
But I can see how you missed it though.
 
6:46 PM
hmpf
and why does Twitter not notify me of messages that contain my handle anymore?
I accidentally found lots of “RT” style retweets of my tweet via tweetmeme …
I thought Twitter notified me of those …
 
@bamboon Hey, you asked me to ping you when I got to chapter five of the Concurrency in Action book. This is that ping.
 
@RMartinhoFernandes Pong.
 

« first day (563 days earlier)      last day (4384 days later) »