Hello!

>> can to do to work around this exception is modifying Wt's source to
>> remove it.
>
> When removing the warning, you do not see any adverse effects?

I did not see adverse effects (such as memory problems). But I used
this patched version not for long time: I moved back to Wt 3.2.1
because of other bugs.

>> I think, Wt::Dbo should behave as memory manager: longly unused
>> objects go to swap (i.e. to database, ptr.flush() && ptr.purge()).
>> Because of lazy loading, this can be done. In this case circular
>> dependency would not be a problem. Could you implement it, please?
>
> The main problem is that we currently depend on reference counting.
> What you are really suggesting is that we also do a 'mark' and 'sweep'
> garbage collection. I've never considered this before, but indeed, it
> might make sense since Wt::Dbo indeed has a centralized knowledge on
> all objects, and it has everything in place to implement the
> traversal. In that case we can simply break the cycle as the
> corrective action, which should normally lead to a normal (but
> post-poned) action.
>
> I'm not sure how this will work in practice (how to configure this
> 'mark&sweep'), but I suspect that in reality most sessions will only
> have a very low number of objects that are being kept around during
> user think-time and thus there is indeed opportunity to do this every
> so many requests.

My proposal was not garbage collection. I proposed to unload longly
unused objects.

As I understand, mark&sweep garbage collection would require freeze
whole Session, traverse all objects from "roots" (dbo pointers, which
are not members of dbo objects), mark them and then unload those of
them which were not marked during traversing. In this case pointer
must know if it is a field of class (as collection does). This can be
implemented in persist() method. But in case pointer knows if it is a
member of class, this information can be used in reference-count
approach as well (consider all pointers, which are dbo object fields,
to be "weak"). If all pointers between dbo objects were considered
weak, then no circular depencies of objects would occur. But that's
not what I proposed.


I asked in my original message if dbo can unload object with non-null
reference-count. In case of mark&sweep scheme it would be converted
into "if dbo can unload non-marked object".

The following proposal is actual only if the answer is "yes, dbo can
unload objects, referenced by dbo pointers".

(Here is something similar to how some operating systems decide which
pages should go to swap.) This algorithm does not require neither
reference-count nor traversing. Dbo can maintain (intrusive) linked
list of objects and remove most old ones. Each access to object moves
this object to beginning of linked list (making it the youngest).
There can be also max number of objects loaded to memory (which can be
Session parameter). When it is exceeded, the most old object (end of
linked list) is unloaded. Timestamp can also be stored in each object.
Then we can unload objects starting from oldest, if they are not used
for long time. For example, if user goes away, leaving Wt page opened,
all objects associated with his session will be unloaded through
several minutes.

Example 1:
 * dbo A, with weak pointer to dbo B
 * dbo B, with pointer to dbo A
 * Widget, with pointer to dbo A

Each action in Widget needs A and B. If B were unloaded after each
action (in reference-counted system, because pointer from A to B is
weak), then database version would be reloaded each time. In system I
proposed B would live in memory, if is used frequently.

Example 2:
 * Widget -> dbo A -> dbo B -> dbo C -> dbo D -> dbo E ->...
 * All pointers are not weak.
Widget exists all time session exists, but it is rarely used. In
reference-counted system all the objects are loaded despite they are
not needed.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
witty-interest mailing list
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to