AntonTerekhov / OrientDB-PHP

Binary protocol for OrientDB for PHP applications (Beta)
http://code.google.com/p/orient/wiki/NetworkBinaryProtocol
BSD 3-Clause "New" or "Revised" License
108 stars 23 forks source link

Memory consumption in OrientDBRecordDecoder #25

Closed fsicre closed 11 years ago

fsicre commented 11 years ago

OrientDB allows very big documents (2GB).

Having them twice in memory may cause major problems

Do you think that, once parsed, $this->content could be empty-ed in order to reduce memory consumption ?

AntonTerekhov commented 11 years ago

Well, this is least I'd to worry about.

It's clear, that any document big enough to consume all available memory will raise two problems before crash: slow reading from net and slow parsing.

On the other hand, if $this->content isn't emptied, we can introduce flag and do not encode, if data hans't changed.

fsicre commented 11 years ago

I do agree with you on the first part of your comment.

I'm not sure to understand the second part.

For now what I have understood is that

When you say "we can introduce flag and do not encode", are you optimizing a futur update of the record without any prior changes of its data, and in this case, sending back the ->content without encode ?

$record->data->addresses[0]->city = "New city name"; But how can we know at $record level that le city name has changed ?

Kind of Composite pattern ?

$record->data->addresses got to be a special Array with tainting capabilities $record->data->addresses[0] got to be a special Object with tainting capabilities

and on sending to server $record got to ask its "childs" if they are tainted ?

AntonTerekhov commented 11 years ago

Yes, something like that. May be Observer.

Not sure if this kind of optimization would be processor-friendly, or even case "we're downloaded record, it got zero changes and we occasionally put it back unmodified" is occurs frequently enough.

fsicre commented 11 years ago

Ok I see, thanks or your explainations.