theseion / Fuel

Fuel, the Smalltalk object serializer
https://theseion.github.io/Fuel
MIT License
27 stars 13 forks source link

Introduce configurable limit to number of objects serialized #203

Closed GoogleCodeExporter closed 2 years ago

GoogleCodeExporter commented 9 years ago
I serialize stacks in our production images. Sometimes these stacks become very 
big (just had one with 16MB). Since cutting off the stack isn't necessarily a 
solution (the first few contexts can reference the entire graph) I thought that 
we could maybe introduce a configurable limit for the number of objects that 
are to be serialized.

Something like this:

analyzer := FLAnalyzer newDefault
    objectLimit: 50000;
    yourself.
FLSerializer newDefault
    analyzer: analyzer;
    ...

When the serialization reaches the limit it will discard the stack of untraced 
objects and replace invalid references with nil.

Thoughts?

Original issue reported on code.google.com by maxle...@gmail.com on 31 May 2013 at 8:50

GoogleCodeExporter commented 9 years ago
Hi Max. I think this limit really make sense and several times I found myself 
wanting the same. but I don't understand what you mean with "When the 
serialization reaches the limit it will discard the stack of untraced objects 
and replace invalid references with nil."  Could you explain a bit more?  
Because it looks complicated for normal graphs. Remember this will be for any 
type of graph, not necessary context stacks.

Wouldn't make sense to throw an error if we reach the limit? 

Original comment by marianopeck on 31 May 2013 at 11:55

GoogleCodeExporter commented 9 years ago
I guess it depends on the use case. In my case I want to have a serialized 
version of the stack and I don't want any exception to be thrown. What I'm 
asking is "serialize as much as you can but not more than x objects, then 
terminate".
If I understand you correctly, you're case would be along the lines "serialize 
the graph only if it does not contain more than x objects. If you reach the 
limit, notify me by throwing an exception".

So maybe we need two things here:
1. a mechanism to limit the number of objects serialized
2. a mechanism to tell fuel how to behave when that limit is reached

How about this:

    FLAnalyzer newDefault
        objectLimit: 50000;
        dontFailOnLimit;
        yourself.

Default would be to signal an exception when the limit is reached.

Original comment by maxle...@gmail.com on 31 May 2013 at 4:19

theseion commented 8 years ago

I have an idea of how to do this but it requires changes to various parts of the code. I have a simple prototype which still fails for more complex cases.

Theory: think of the graph as a network of nodes that are grouped around the root node in concentric circles. Every circle represents a one step increase of distance to the root node. To constrain the number of objects in the graph sensibly, simply prune nodes with distance > x. This even works for context chains.

tinchodias commented 8 years ago

Do the changes to various parts of the code of your working prototype also increase complexity to understand the code, or are they just spread changes? If it's more close to the first option, then you can just commit it, IMO.

theseion commented 8 years ago

Yes, I believe they do. I'm not happy with the code. First I want to have a prototype that works across all cases, then I can try to make it pretty.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will remain open but will probably not come into focus. If you still think this should receive some attention, leave a comment. Thank you for your contributions.

theseion commented 2 years ago

@theseion In 4.0.0 (finally ;))