« first day (1283 days earlier)      last day (1576 days later) » 

9:35 AM
can I pass a bitfield as a template parameter?
 
nwp
9:49 AM
Kinda sorta not really. Bitfields are not objects, you can't do much with them. But you can pass the value using the underlying type.
 
 
5 hours later…
2:22 PM
I don't understand this answer.
200
A: Why is the use of alloca() not considered good practice?

Igor ZevakaOne of the most memorable bugs I had was to do with an inline function that used alloca. It manifested itself as a stack overflow (because it allocates on the stack) at random points of the program's execution. In the header file: void DoSomething() { wchar_t* pStr = alloca(100); //.........

What would be different if the compiler doesn't inline doSomthing() ?
 
nwp
Then the memory would be released at the end of doSomething so it doesn't eat stack.
And I agree with the comment and consider this a compiler bug.
 
Ah!!! I see
 
usually it wouldn't matter if it's inlined, but alloca treats the stack-pointer popping as if it was the destructor
in that implementation apparently
 
nwp
There is nothing wrong with inlining the function, the compiler just has to still run the "destructors" just like for any other function.
 
well it's kind of understandable how this happened though, because C doesn't have desctructors, so the compiler added it to the "stack cleanup"-part
 
2:32 PM
OK thanks
By running getrlimit(RLIMIT_STACK, &rm); getrlimit(RLIMIT_DATA, &rm2), I found that it only gives 8388608 bytes (8MB) stack size by default, while 2^64 - 1 bytes for heap + bss + initalized data segment
No wonder stackoverflow is more likely to be a problem
 
nwp
I think that's Linux default for the main thread. I think Windows uses 1MB by default. Or did at some point.
Inb4 "There is no such thing as a main thread!!!11"
 
yeah, pretty sure windows/Visual Studio default is still 1MB.
 
 
2 hours later…
user6461957
4:17 PM
Is my conclusion valid?: considering `std::map` is implemented via a red-black tree and each node of the very
same tree points to 4 different non-consecutive memory locations (left, right, parent, data/key-value pair), then
the number of cache hits reduces considerably.
 
reduces considerably compared to what? While doing what?
 
user6461957
Implementing the associative container via regular hashing/open addressing with a dynamic array?
 
yeah for most operations I would consider a red-black tree map to have more cache misses than a hash-map
std::unordered_map is a hash map. Not a particularly good one, but a hash map nonetheless
 
user6461957
Do you know the rationale behind the implementation of associative containers via red-black trees?
 
Mostly historical as far as I know, like I said a hash-map type was added later
 
user7659542
4:30 PM
An api I am using forces me to return a void*. What if I don't have nothing to return?
 
@d03 also reduces the requirements on the key type to be just weakly ordered
 
user7659542
Returning nothing gives me a warning "control reaches end of non-void function"
 
user7659542
and I don't want that warning
 
user6461957
return NULL? or return nullptr?
 
return nullptr
@d03 while for a hash table you need to define a hashing function
 
user7659542
4:32 PM
thx!
 
user6461957
@PeterT True, so I can bypass the hashing function but with a cost (cache misses).
 
nwp
Why do you even care about cache misses? Are you so starved for performance that you need to benchmark and profile and torture the code to maximize performance?
 
user6461957
It's out of my curiosity.
 
if people don't care about performance why would they write C++
 
nwp
I have never cared for performance and still write C++. It's being able to express what I want fairly precisely that does it for me.
 
4:37 PM
for precision you chose a language with a lot of implicit behavior
 
nwp
How are those related?
I don't think I've used std::unordered_map for anything outside of simple test projects either.
 
user6461957
Implementing an adjacency list with std::map + std::vector vs std::unordered_map + std::vector is maybe also worth considering?
The latter is slightly better regarding cache friendliness as it tends to be more consecutive.
Though it would be probably better to not use an adjacency lists at all if performance is critical. Maybe a 1D array that represents a graph matrix?
 
user6461957
The 1D array being for example a std::vector.
 
nwp
If you want to go the hardcore performance route you really need to learn to do benchmarking and profiling correctly. You can't just choose the one that is most cache-friendly.
 
@d03 there's some pretty good hash-table implementations out there
 
user6461957
4:49 PM
@nwp Also, don't you think that considering performance is vital in other development areas such as embedded systems?
 
nwp
I partially do embedded systems development. It just doesn't matter. You buy an atmega or whatever and it's fine. Performance is rarely an issue and if it is you just use a bigger processor. Developing more efficient code is just not worth it.
There are some areas where performance matters. High frequency trading and some AAA games.
 
in other areas you still don't want to be a 10 minute wait to add 2 numbers
hyperbolically speaking
 
user6461957
@nwp Can we just assume that our processors get better and better? Didn't we reach the limit of clock speeds already?
 
nwp
Maybe it's just that using C++ and not being overly dumb and copying huge vectors everywhere is already good enough.
@d03 That was for embedded devices that run at 1MHz or something where you can indeed just throw performance (and battery power) at the problem. For desktop it's different, but I can hardly imagine an application that needs more performance. It feels like when things are laggy someone did some horrendously inefficient crap and it's not because the cache efficiency isn't perfect.
Then again I shouldn't be talking about performance since I basically have no experience in it besides that it never mattered in my area.
Which is desktop applications and embedded devices.
What actually matters is being able to develop complex applications without drowning in complexity and bugs. I'm ... working on becoming better at that.
 
 
3 hours later…
8:12 PM
Are bad_alloc exceptions reported in release mode?
 
if you allocate absolutely obscene amounts maybe, but on many OSs you can overcommit with allocs and then just get a segmentation fault when accessing the allocated pages for the first time
 
Hmm, thing is, I seem to have memory fragmentation issues, but only in debug mode... so I wonder if I have them in release too, but I don't get them reported..
 
memory fragmentation? how long is your program running for?
 
It does not start ;)
Well, it does, but not to a point I can use it.
(It's a 32 bit app)
We load a lot of images and upload them to the VRAM, but create 3d models with them.
 
oh,ok. With 32 bit that makes a lot more sense
 
8:26 PM
Yeah, at some point, I try to load a texture that takes 64 mb, and get a bad_alloc, although I use only ~1gb of memory.
(I know I should upgrade to 64 bits, for multiple reasons.)
 
I can imagine if you're uploading to the GPU then the driver would also take up a bunch of pages, so that might exacerbate your issue
You could use something like vmmap to see how your memory-space looks
 
A couple more models here and I get bad_alloc
 
well, might be time for some custom allocators then
 
8:41 PM
Yeah ;/
Either that or we go to 64bit.
 
or just go 64bit?
 
In both cases, we have risks :/
 
I mean if you need clean and non-overlapping address space 64bit slab allocators are hard to beat
 
you could also open a new process to load the models and try to use shared GPU contexts to load the models into :P
 
tbf fair it doesn't look like you've marked your process LARGE_ADDRESS_AWARE as is
so you only have 2GB of ram
even on a 64bit system
 
8:44 PM
Hmm, would that let me go to ~3gb?
 
3.2 or 3.5 or something like that
 
That's useful, I think. I'll try that tomorrow or Friday!
(That will not make my issue go away, it'll just allow me to tackle it later :P)
Thanks for the info!
in VMmap, I get some memory that is marked as "unusable", and is always attached to an "image"; can I assume that it is not usable because it is the "padding" for the slot reserved before?
Errr
 
9:02 PM
@Vaillancourt 4gb on x64 systems
and 3gb on x86-32
@Vaillancourt either that or the kernel is using it for something
 

« first day (1283 days earlier)      last day (1576 days later) »