This post has NOT been accepted by the mailing list yet.
I'm using z3c.relationfield in my Grok site, and I had some specific operations run surprisingly slow.
After profiling, I found out that it was updateRelations from z3c.relationfield.event that was called unnecessary frequently.
After some further digging, I found the problem, and a possible solution:
The objects I'm using relationfields on are actually containers, containing (in some cases lots of) small objects.
updateRelations is called for each IObjectModifiedEvent on any object providing IHasOutgoingRelations. Adding an object to a container will raise a IContainerModifiedEvent, which is derived from IObjectModifiedEvent. So each time I add an object to a container that uses relationfields, updateRelations is called, which turns out to be quite an expensive operation.
However, adding/removing objects from a container will normally not (in my case at least) change the container's relations, so this is unneeded overhead. I tried by adding this at the start of updateRelations:
return # the object is a container, and an element has been added/removed
In my site everything seems to keep running OK (and signifficantly faster, too).