标签云

微信群

扫码加入我们

WeChat QR Code


Do you know ahead of time the lifetime of the object, or if it will transfer threads?

2018年09月27日34分08秒

Unfortunately no. This is defined by application logic.

2018年09月27日34分08秒

If ctor and dtor do not allocate or free memory, then they should be fast, and thus there should be no reason to avoid them. Also, the issue with having one freelist per-type is that you must use atomic ops to manipulate it, and it will encourage false sharing.

2018年09月27日34分08秒

Not sure that this is the best answer. IMHO the one about tcmalloc was better. Cannot vote though

2018年09月26日34分08秒

Issues with this are that you will see a lot of contention for the stack lock. Also, false sharing will exist, as allocations from separate threads will adjacent. In addition, if 3000 temporaries are allocated, and then 1 permanent object is allocated, the 3000 temporaries will not be reclaimbed.

2018年09月27日34分08秒

I don't get last part about note reclaiming temporary object. Can you be more specific?

2018年09月27日34分08秒

I misread the code and misunderstood the answer; the 'no reclaim temporary' part was entirely wrong. :-) However, the above could be improved to use a linked list, thus removing the lock. (Instead use atomic list ops.)

2018年09月26日34分08秒

Thank you.It was interesting reading. However our guys told me that it has heavy locks contention in compare to umem on Solaris.

2018年09月27日34分08秒

The concept is slightly different. An object could travel through threads handling it. And when its life time will has came to the end it could be in any other thread than the mother-thread. Of course after-life management details are hidden..

2018年09月26日34分08秒