« first day (3758 days earlier)      last day (1182 days later) » 

12:45 AM
On an unrelated note, is there some kind of allocator that provides buckets of sizes for types know at compile time?
something like:
struct buckets
{
std::vector<polymorphic_type1>;
std::vector<polymorphic_type2>;
}
 
1:05 AM
Boost PolyCollection again. Perhaps with Object Pools
Also, don't sit there and lazily declare someone else's unchosen trouble aletory [sic] issues or "modicum of heat". The use of hyperbolic language betrays you know full well you are misrepresenting both.
The fact that it annoys you that somebody else's choices make you face a moral dilemma is your problem.
 
I think weakness annoys me, but also celebrating that weakness.
 
@Mikhail sure. Because patents are completely meaningless
@Mikhail Nobody celebrates the weakness. It's you doing that framing
Commemorating the person doesn't equal celebrating the weakness. Like it isn't bad to remember your grandparents, even though they did, after all, die like any other sucker.
 
I worked ~4 years in academic publishing, and maybe 10 in academia. AMA
 
 
2 hours later…
3:18 AM
So backing my shared pointers of known types with boost::polycollection looks like a functional strategy but I suspect I can do better. Basically my allactor doesn't actually need to know the type of object its going to allocate. So I should be able to have a pool (but really an std::vector) for each of the 10 or so unique object sizes.
I guess I could kinda generate the 10 or so discrete bucket (std::vectors) form where to draw and deposit unique memory locations using an std::map at runtime.
So, with poly collection :

shared_ptr->poly_collection_idx->poly_collection_internal_idx->actual_object
vs
shared_ptr->bucket_idx->actual_object
but instead of having std::unordered_map<memory_size,bucket> I'm wondering if I can do some Kompile Time(tm) magic to generate them from a bunch of sizeof() statements.
might be some egregious use of frozen?
Then I still have map semantics, but at compile time...
 
 
3 hours later…
6:08 AM
Anyone here knows much about Arduino sketch?
I thought loop() inside Arduino program would loop forever? Why is it exited whenever I simulate an input?
 
 
2 hours later…
8:09 AM
yeah loop is called forever. If it stops then you're hanging somewhere. The arduino IDE just includes it's own main/__init that will just call the setup()/init() functions
 
 
3 hours later…
11:25 AM
@PeterT Is there a way to find out where it exits the loop?
 
what do you mean by "exit the loop"? Every function call you make could just wait on something, what makes you think that you "exited the loop"?
if you really want to you can also just search for the main file it uses github.com/arduino/ArduinoCore-megaavr/blob/master/cores/…
and change that one in your local arduino install
 
11:40 AM
@PeterT I have a print statement in setup(), it has been called when I simulate a serial input. Depends on the input, the Arduino then does something.
 
so you're saying that you rebooted it from within loop and you landed back in setup()?
 
Could be so, that print statement is only in the setup.
 
I'm not sure I understand. Anyway, you could print something at the start and end of every loop-run and see if you are actually exiting the calls loop() or you're "escaping" it somewhere in-between
 
Yeah, primitive technology, printing statement everywhere.
 
nwp
9 messages moved from C++ Questions and Answers
 
 
6 hours later…
5:46 PM
 
 
3 hours later…
8:26 PM
21
A: Custom (pool) allocator with boost shared_ptr

utnapistimHere's the code to do what you want (probably won't compile as I don't have boost on hand and I'm writing it from memory): class YourClass; // your data type, defined somewhere else boost::object_pool<YourClass> allocator; void destroy(YourClass* pointer) { allocator.destroy(pointer); } b...

^ So I looked this implementation and it seems to use use 25% more memory than using a pool (just calling std::shared_ptr). Kinda weird
The precise difference obviously depends on the object being allocated (in my case 48 bytes), but why does the boost::object_pool seem to use more memory?
 
 
1 hour later…
9:33 PM
So, what I was hoping for some way to combine a bunch of small fixed size memory pools, so that I could "dynamic" like growth behavior but at substantially reduced overhead. For example, if I wanted to allocate 100 byte objects, I could draw from a fixed pool of 100 x 20 , where 20 is some number of objects.
When that pool would get exceeded it would append a new pool.
I thought there boost or somebody else had a version of this?
 
 
1 hour later…
10:59 PM
@sehe Do you happen to know the internals of boost object pools? From what I understand its stored as [chunk1,chunk2,chunk3][chunk4,chunk5,chunk6],[chunk7] where the blocks are delimited by []. And only the blocks have the system malloc overhead? So in my case I want to allocate a bunch of ~48 bytes structs. So if I set the next_size parameter to 100*48 bytes, the next allocation will use the system allocator to grab room for 100 48 byte chunks?
Then the next 100 calls to the object pool will avoid hitting the system allocator?
So in that case the per malloc system overhead should be limited to 1 malloc information block per 100 objects?
 
11:21 PM
@Mikhail That's my basic understanding as well. I admit I hardly played with these because I don't really have a need. I usually work from higher level primitives (like flat_sets on top of a small_vector)
 
Except that when I look at total memory used its much worse than everything else
Basically I need to pool a bunch of linked list nodes. Fuck I've been bashing my head against this all day, probably just need to roll my own allocator.
So, for a 48 byte object, the overhead is like 100 bytes if you follow this dude's solution: stackoverflow.com/a/2911438/314290, compared to not using a pool, for example where its something like 26 bytes.
 
@Mikhail Wait. Why is shared_ptr involved? Looks like that should at the very least use allocate_shared.
For pooling linked list nodes, I would make a linked list with boost::intrusive on a vector (or possibly deque) of nodes.
 
11:46 PM
using allocate_shared doesn't change the important point, that each node element in addition to its sizeof() get reference count (small) and a malloc size block (bigger).
I was actually was dealing with graph nodes rather than linked list nodes
But I have rather unfortunate requirements, specifically, I absolutely must use std::shared_ptr to hold my nodes to funnel them over to python.
So now I'm working on my half baked implementation of what I think boost::object_pool is actually supposed to do :-)
:-(
Fuck, I should have done a PhD in CS rather than hustling biomedical optics
 

« first day (3758 days earlier)      last day (1182 days later) »