There are 2 updates.
 
 
XWiki Platform / cid:jira-generated-image-avatar-775c5077-7cf5-4742-b0fa-3e190e547d72 XWIKI-16977 Open

The class migrator is way too slow

 
View issue   ยท   Add comment
 

2 updates

 
cid:jira-generated-image-avatar-4759a350-c7b2-4ddb-b494-9696b0030ccf Changes by Manuel Leduc on 10/Oct/24 11:16
 
Description: When modifying a xclass field the class migrator wake up to do necessary modification to corresponding xobjects. Problem is that the current implementation can takes hours when there is a lot of xobject of that xclass and blocks the class save in the meantime.

The object update is very important so we can't just remove it but there is probably ways to work on optimizing it.


h2. Reproduction steps

# create a class (e.g., {{MyClass.WebHome}})
# create a lot of page each containing an object from the new class
# edit the class and add a new field
# wait

h2. expected

# the change is performed "quickly"

h2. Actual

# adding the new field takes 27 seconds

h2. Notes

This is worsened by the fact that changes on the XObject are performed as soon as the field is added.

Snippet to create the classes
{code:groovy}
{{groovy}}

for(index in 1..3000){
key = "Test"+index
udoc = xwiki.getDocument("Space."+key)
uobj = udoc.getObject("MyClass.WebHome", true)
uobj.set("field1", key) ## assuming MyClass.WebHome has a "field1" field
print("* Created *" + udoc.key + "*\n")
udoc.save()
}
{{/groovy}}
{code}

You can find attached the result of a profiling after adding a new field to MyClass.WebHome
Attachment: jar_2024_10_10_111110.jfr