C++ Logo

sg14

Advanced search

Re: [SG14] sizeof_block_metadata function, colony/hive, advice wanted

From: Matt Bentley <mattreecebentley_at_[hidden]>
Date: Wed, 1 Dec 2021 22:03:03 +1300
I kinda thought about this a bit and realised the same data could be
estimated by the programmer by inserting a number of elements equivalent
to the (programmer-specified) minimum block capacity, then using
hive_instance.memory() - (sizeof(T) * hive_instance.capacity())

to get the metadata memory usage.
So, possibly not worth adding this function in, even as a convenience
function.


On 26/11/2021 7:54 am, Ben Saks via SG14 wrote:
> +1 to Ben Craig's request for a motivational example. A couple of other
> points to consider:
>
> * Could it be a static member function rather than a const member
> function? If I understand, this seems like it might be data that you'd
> want to use to create a container, rather than a question you'd want to
> ask of an existing container.
>
> * Either way, I imagine that it could and should be a constexpr function.
>
> Regards,
> Ben Saks
>
>
>
> Sent from my Galaxy
>
>
> -------- Original message --------
> From: Ben Craig via SG14 <sg14_at_[hidden]>
> Date: 11/25/21 11:46 AM (GMT-05:00)
> To: sg14_at_[hidden]
> Cc: Ben Craig <ben.craig_at_[hidden]>
> Subject: Re: [SG14] sizeof_block_metadata function, colony/hive, advice
> wanted
>
> If you can provide a short, motivational chunk of code that shows how it
> would be used, then that would make it a lot easier to answer the
> question about whether it's useful or not. I suspect the function may
> be providing something that is easy for the implementation to provide,
> but very hard for a user to use.
>
> I suspect that this is trying to help the user solve an optimization
> problem, where they are trying to minimize the amount of total memory
> used for a given range of element counts. If that's the case, then
> write a short code snippet that either solves, or hints at the solution
> to that problem.
>
> > -----Original Message-----
> > From: SG14 <sg14-bounces_at_[hidden]> On Behalf Of Matt Bentley via
> > SG14
> > Sent: Wednesday, November 24, 2021 7:35 PM
> > To: Low Latency:Game Dev/Financial/Trading/Simulation/Embedded Devices
> > <sg14_at_[hidden]>
> > Cc: Matt Bentley <mattreecebentley_at_[hidden]>
> > Subject: [EXTERNAL] [SG14] sizeof_block_metadata function, colony/hive,
> > advice wanted
> >
> > Hi all,
> > thinking about including a
> > size_type sizeof_block_metadata(const size_t block_size)
> >
> > function for colony/hive, as this would allow the user to ascertain the
> > amount of memory used by a memory block's metadata in colony (including
> > skipfield), given the number of elements stored in that memory block.
> > This is less important for colony which is a fixed implementation, more
> > important for std::hive which could potentially have many alternative
> > implementations and these might not be visible to the user in text form.
> >
> > The idea was that if someone knows how much memory is used by each
> > block outside of the actual memory used to store the elements, that might
> > aid in terms of knowing how much cache space is used by the metadata and
> > people might be able to make better decisions about the min/max
> capacities
> > of memory blocks (if they are specifying these manually) on that basis.
> >
> > The function would throw an exception if the block_size specified was
> > outside the minimum/maximum block capacity ranges.
> >
> > My main question to you is whether this function is worth including -
> as it
> > adds yet another function to the codebase.
> > Thanks,
> > M@
> >
> >
> > _______________________________________________
> > SG14 mailing list
> > SG14_at_[hidden]
> >
> https://urldefense.com/v3/__https://lists.isocpp.org/mailman/listinfo.cgi/sg
> > 14__;!!FbZ0ZwI3Qg!_EmqRo6oE_K3_0kspLt95nQkSwn6ReF6w24SgNk6c4-
> > tKwgxy1B_QABcfeZ_$
> _______________________________________________
> SG14 mailing list
> SG14_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/sg14
>
> _______________________________________________
> SG14 mailing list
> SG14_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/sg14
>

Received on 2021-12-03 00:27:18