
Hi Phillip, On 10/1/2017 1:40 PM, Philippe Marschall wrote:
Hi
Let me start by mentioning that I don't believe any of these issues are Seaside specific. IMO these issues apply to any web framework using GLORP and even any web framework using an ORM in general. So it could be beneficial to investigate how other Smalltalk web frameworks (AIDA, ApeX, Iliad, ...) or even other languages solve this issue (JSF, Spring Web MVC, JPA/Hibernate).
What is most concerning to me is how every object ever loaded with GLOP is tracked in the cache of the GLOP session. IMO this is wrong as most objects are read-only and never edited. These objects should not be tracked. This leads to a lot of unnecessary memory overhead. Only the objects that are actually edited should be tracked. I think of it this way, when a table or list of objects is rendered none the displayed objects should be tracked. Only when an edit link or button is clicked and an edit form is rendered then the edited object needs to be tracked and optimistically locked. If we track every object ever loaded then this simply leads to unbound memory usage. If caching has to happen for correctness then the cache should be flushed at the end of a request. As an object-relational mapping framework, Glorp has no way to know which retrieved objects are going to be modified. If you don't cache objects on retrieval, you have to go back to the database again to see what's changed before doing an update. Also, if the application has a simple UI with lots of objects which are not modified, but are used continually, it may make sense to keep them around. In any case, retrieving objects that are read-only in one session and potentially editable objects in another session and then flushing caches at appropriate times might be appropriate.
Digging a bit into the GLROP documentation I don't think a unit of work should be active during the render phase. As far as I understand this should prevent any of the loaded objects from being tracked by being added to the cache. Only when an object is being edited should it be registered manually for tracking by the GLOP session. However during the callback phase a unit of work should be active. This should be done automatically by a Seaside-GLORP extension. On a successful or cancelled edit the edited object should be removed from the cache again and the callback should be invalidated (ideally a one time callback is used).
It would be good to hear from somebody with GLROP experience whether what I just wrote made any sense at all or is utter nonsense. Philippe, I think your "it should be this way" could be right for some applications, but wrong for others. A solution for an application that serves one request at a time per image with multiple images running in parallel might do things the way you suggest. Another application might want to cache objects in the image for use by multiple simultaneous requests. If you register retrieved objects only when the edit button is clicked, you need an extra round trip to the database. It might depend on whether your limited resource is the database server, application server memory, application server cpu or something else.
Cincom uses Glorp to read and write source code definitions in StORE. When reading, Store database objects are retrieved and then converted to active Smalltalk code. When writing a package or bundle, the Store database objects have to be synched to the database before writing a new version so that unchanged definitions are not written as duplicates in the database. This is, in essence, what you're suggesting. It's necessary because the objects in the image live long beyond the duration of a database connection, but it has a cost. Hope you find this helpful...
I would also be open to attending some sort of meetup in northern Switzerland/southern Germany to discuss this in person.
Cheers Philippe
On Thu, Sep 28, 2017 at 8:56 AM, jtuchel@objektfabrik.de <jtuchel@objektfabrik.de> wrote:
Hi there,
since nobody at ESUG seemed to be interested in a Glorp/Seaside BOF as I suggested, I try something new now ;-)
Glorp is a great tool for OR mapping and works very well. There is good introductory material, even if it is hard to find. But when it comes to real world use, there are many questions to be answered like
how to handle transactions, mementos, units of work and that stuff, especially in a multi-user environment like a Seaside based web app how to map more complicated things, like polymorphic joins, embedded objects etc. what if an image slows down gradually when a user has been working for hours, almsot coming to a standstill. How to find out if Glorp or your use of it is the problem? What can you do then? Is my use of transactions correct or will I face problems
None of these are easy questions and maybe there are many possible answers to them, But finding them on your own can be hard and take a lot of time. It can even be a risk to your business.
There is the Glorp group, but it's not actually in heavy use and sometimes it is hard to write down a problem in a few lines. Explaining the whole thing sometimes would make for loooong messages that probably nobody ever reads, esp. if the poster's english isn't brilliant.
So what I'm looking for is ways to find and meet people who also use Glorp (or any other ORM in Smalltalk) and would be interested in discussing stuff and maybe answer questions. Something like a Glorp users group.
The best thing to exchange ideas is probably to meet face to face and carry your laptop with you. So if anybody in Southern Germany, Eastern France, Northern Switzerland would be interested in such a meeting, please let me know and I am more than interested in setting something up.
The second best is probably some sort of online conference call. Maybe even on a regular basis.
Please let me know if you'd be interested.
Joachim
-- ----------------------------------------------------------------------- Objektfabrik Joachim Tuchel mailto:jtuchel@objektfabrik.de Fliederweg 1 http://www.objektfabrik.de D-71640 Ludwigsburg http://joachimtuchel.wordpress.com Telefon: +49 7141 56 10 86 0 Fax: +49 7141 56 10 86 1
_______________________________________________ seaside mailing list seaside@lists.squeakfoundation.org http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________ Esug-list mailing list Esug-list@lists.esug.org http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org