You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This came out of the team discussion. We should introduce a per-query-per-node memory limit configurable in run in MBs. If the query goes over the limit, it should be interrupted with an error.
@pixelspark -- cool idea. I think we already have a time limit, but it's hardcoded. It should be relatively easy to expose it. ("I think" is a key phrase here :))
I think this is a good idea, but I think we should think carefully about the implementation or else it will end up being unmaintainable. This proposal would require making each datum_t be "owned" by a specific query. This is a big change; I suspect it's bigger than the configured_limits_t changes. We have to deal with all the same awkward cases, plus some new ones. For example, when we deserialize a datum through a mailbox_t, we want to apply the cost of that datum to the per-query memory limit for the query that initiated the request. It has the potential to get complicated quickly.
Here are some thoughts:
We should look at how other projects have implemented memory limits, and see if there are good ideas that we can copy.
We should consider making the memory limit system generic instead of tying it to the concept of a ReQL queries. For example, we arguably want per-backfill memory limits. The other advantage of making the memory limit system generic is that we might want to thread it through weird places (such as mailboxes), and threading a ReQL-specific memory limit system through mailboxes is way uglier than threading a generic memory limit system through mailboxes.
We should see if we can get away with implementing a datum_t size limit first. I'm pretty sure we'll want a per-query memory limit eventually, but implementing a datum_t size limit might buy us some time before it becomes critical, and we can use that time to do a better job.
I also have some vague ideas for how a per-query memory limit system could work. I suggest that we create a base class for objects subject to the memory limit; this way, we can apply the memory limit gradually to one data type at a time in a controlled fashion. Subclasses of this base class would be constructed with a "memory account" object that they would use for allocations, and they would remember this object. We would overload "placement operator new" to use the special allocator. It would be possible to transfer ownership of a memory-managed object between two different accounts, or to construct it with no owner. (For example, mailboxes might construct objects received over with no owner, but then the query would take ownership once it received the object.) We would also provide a std allocator implementation that allocates from a memory account.
Obviously this deserves a lot more thought than this brief paragraph, but these are just some ideas to get the juices flowing. Also, we shouldn't forget to check how other projects do it and see if there are existing best practices.
I would be OK with just having a per-{object/array} cumulative size limit and doing a generic memory-limiting system later. I think it depends on how hard it would be to limit memory on a per-query basis.
(To be clear, when I say "cumulative size limit" I mean "An array of ten objects each with 5 fields counts as 50.")
Activity
coffeemug commentedon Aug 28, 2013
This is somewhat related to #971.
pixelspark commentedon Aug 28, 2013
A time limit would also be nice (see #1344)
coffeemug commentedon Aug 28, 2013
@pixelspark -- cool idea. I think we already have a time limit, but it's hardcoded. It should be relatively easy to expose it. ("I think" is a key phrase here :))
timmaxw commentedon Aug 13, 2014
Copying @mlucy's comment:
timmaxw commentedon Aug 13, 2014
I think this is a good idea, but I think we should think carefully about the implementation or else it will end up being unmaintainable. This proposal would require making each
datum_tbe "owned" by a specific query. This is a big change; I suspect it's bigger than theconfigured_limits_tchanges. We have to deal with all the same awkward cases, plus some new ones. For example, when we deserialize a datum through amailbox_t, we want to apply the cost of that datum to the per-query memory limit for the query that initiated the request. It has the potential to get complicated quickly.Here are some thoughts:
datum_tsize limit first. I'm pretty sure we'll want a per-query memory limit eventually, but implementing adatum_tsize limit might buy us some time before it becomes critical, and we can use that time to do a better job.I also have some vague ideas for how a per-query memory limit system could work. I suggest that we create a base class for objects subject to the memory limit; this way, we can apply the memory limit gradually to one data type at a time in a controlled fashion. Subclasses of this base class would be constructed with a "memory account" object that they would use for allocations, and they would remember this object. We would overload "placement
operator new" to use the special allocator. It would be possible to transfer ownership of a memory-managed object between two different accounts, or to construct it with no owner. (For example, mailboxes might construct objects received over with no owner, but then the query would take ownership once it received the object.) We would also provide astdallocator implementation that allocates from a memory account.Obviously this deserves a lot more thought than this brief paragraph, but these are just some ideas to get the juices flowing. Also, we shouldn't forget to check how other projects do it and see if there are existing best practices.
mlucy commentedon Aug 13, 2014
I would be OK with just having a per-{object/array} cumulative size limit and doing a generic memory-limiting system later. I think it depends on how hard it would be to limit memory on a per-query basis.
(To be clear, when I say "cumulative size limit" I mean "An array of ten objects each with 5 fields counts as 50.")
@gchpaco -- any opinion?
28 remaining items