Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Optimizing build performance - observing redundant calls to isAffected and validation
Optimizing build performance - observing redundant calls to isAffected and validation [message #1758543] Wed, 29 March 2017 20:42 Go to next message
Larry LeBron is currently offline Larry LeBronFriend
Messages: 124
Registered: October 2015
Senior Member
I have an xtext dsl project with 255 dsl files, and I am observing some very long builds.

I have added logging to trace what's going on.

When making a single change (adding a comment) to a single line in one resource, I am experiencing a long build after saving (at least 10 seconds).

During a build like this, I see the the build cycle (including the inferrer and validator) being called more than 20 times. Sometimes as high as 50 or so.

I've done a bit more digging, including inserting traces into XTextBuilder, IXtextBuilderParticipant and IResourceDescription.Manager.isAffected().

For example, on one save I saw 10 calls to XTextBuilder.doBuild(). I then tried it again and saw 18 additional calls.

For all of these, I see the same exact deltas in IXtextBuilderParticipant.doBuild(), corresponding to the one resource file that was altered:

[DefaultResourceDescriptionDelta for platform:/resource/playablEngine/src/ai/playabl/abl/test/TestEntity.abl old :true,new :true]


I guess my main question is - is there any way to optimize this? Why is build and validation being called so many times for this file after a single save?

Some additional info on the deltas being passed to isAffected() is below. Let me know if any additional analysis would be helpful to shed light on this.

Thanks for any advice.



As an example, here is the first set of deltas it's querying about. It includes 3 deltas:
[UnconfirmedStructuralChangesDelta for java:/Objects/assertions._assertionSetter old :true,new :true, 
ChangedResourceDescriptionDelta for java:/Objects/testExpressions._bindTestWMEHierarchical old :true,new :false, 
ChangedResourceDescriptionDelta for java:/Objects/rules._testTestExpression old :true,new :false]


I see this set passed to isAffected 1,529 times during the build. The validator runs between those two rounds of isAffected calling.

Therefore, each round of calls to isAffected is actually comprised of 764 calls, which corresponds to one call to isAffected per project resource per member of the delta set.

Later in the build logging, 1,020 calls for another delta (exactly 4 times through the project resource set)
[ChangedResourceDescriptionDelta for java:/Objects/rules._testTestExpression old :true,new :false, 
ChangedResourceDescriptionDelta for java:/Objects/testExpressions._bindTestWMEHierarchical old :true,new :false, 
UnconfirmedStructuralChangesDelta for java:/Objects/assertions._assertionSetter old :true,new :true]


Looking at this set, it looks like the same as the earlier one I quoted, in a different order.

A later set includes these, and isAffected is called for it 510 times (2 times through the resource set)
[ChangedResourceDescriptionDelta for java:/Objects/testExpressions._bindTestWMEHierarchical old :true,new :false, 
ChangedResourceDescriptionDelta for java:/Objects/rules._testTestExpression old :true,new :false, 
UnconfirmedStructuralChangesDelta for java:/Objects/assertions._assertionSetter old :true,new :true]


This set is again made of the same 3 deltas in a different order.



[Updated on: Fri, 31 March 2017 19:13]

Report message to a moderator

Re: Optimizing build performance - observing redundant calls to isAffected and validation [message #1758551 is a reply to message #1758543] Thu, 30 March 2017 06:05 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I have raised / commented on a couple of Bugzillas concerned with poor build performance,. But there was never a convincing repro. I mitigated my problems by moving all the build-time dependencies out of the application plugins. However I still see some build thrashes.

Your example may be big enough to make the problem obvious. Unless someone highlights an obvious bug in your implementation, can you package your example as a bug report?

Regards

Ed Willink
Re: Optimizing build performance - observing redundant calls to isAffected and validation [message #1758553 is a reply to message #1758551] Thu, 30 March 2017 06:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
There are additional bugs on how Java changes are handled. I don't know if this affects you

https://github.com/eclipse/xtext-eclipse/issues/70
And there might be a situation where the build runs in possible pseudo infinite loops
(Build is restarted. ClusteringBuilderState.doBuild called multiple times)

It would be nice to have a complete reproducible example
(Dsl +example model, you can anonymize both to a hello world example is possible).

And yes it is intended that is affected is called foreach resource
Since if you change a file you want to know if there are dependent files
That might need a rebuild

I don't know why this is affected is slow in your case since it is a metadata operation only.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Optimizing build performance - observing redundant calls to isAffected and validation [message #1758554 is a reply to message #1758553] Thu, 30 March 2017 06:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
here is the build about the pseudo infinite loop (build restarts itself due cancelation by refresh external resource - i dont know if you have switched on this feature in your ws) in https://bugs.eclipse.org/bugs/show_bug.cgi?id=486083

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Optimizing build performance - observing redundant calls to isAffected and validation [message #1758558 is a reply to message #1758554] Thu, 30 March 2017 07:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
best place would be to file a ticket at github.com/eclipse/xtext-eclipse (if you have a reproducible example)

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Optimizing build performance - observing redundant calls to isAffected and validation [message #1758706 is a reply to message #1758558] Fri, 31 March 2017 19:07 Go to previous messageGo to next message
Larry LeBron is currently offline Larry LeBronFriend
Messages: 124
Registered: October 2015
Senior Member
I've done some additional analysis.

Really, the title of this should be "Optimizing build performance - preventing redundant builds".

I first discovered this issue by watching the logging in calls to isAffected() and my validator, but the real issue is that, for my DSL, a single save is calling the builder a number of times.

I have a custom version of
XtextBuilder.doBuild(ToBeBuilt toBeBuilt, IProgressMonitor monitor, BuildType type)
which I'm using to analyze this.

After a save in which I've made changes to multiple language blocks in only a single resource file, the first call to this method receives a toBeBuilt with that single resource in toBeBuilt.toBeUpdated.

After that build completes, I get a seemingly random number of additional calls to XtextBuilder.doBuild(). In each of these calls, toBeUpdated is empty (no entries in toBeUpdated like the first time). However, following the call to the superclass, XtextBuilder's queuedBuildData member DOES have entries in its deltas. This is why the build proceeds. These deltas remain the same to ever subsequent call to doBuild, which basically feels like its churning.

I don't know why its called repeatedly. I'm going to try implementing a workaround where I prevent these seemingly redundant builds from getting passed to XtextBuilder, though that may obviously break things.

I am unfortunately unable to share this project as it's proprietary codebase, but I will try to replicate with a Hello World language at some point in the future.

If anyone has an idea of why this might be happening, please let me know. In the meantime, I'll try the workaround where I prevent these extra builds and see what happens. It occurs to me that these builds may be necessary to build the Java classes being generated by my Xtext DSL. I'm unclear on whether all code generation plus Java building is supposed to occur in a single call to XtextBuilder.doBuild().
Re: Optimizing build performance - observing redundant calls to isAffected and validation [message #1758708 is a reply to message #1758706] Fri, 31 March 2017 19:16 Go to previous messageGo to next message
Larry LeBron is currently offline Larry LeBronFriend
Messages: 124
Registered: October 2015
Senior Member
Also, Christian, to respond to your earlier notes.

I do have "refresh using native hooks or polling" deactivated. In the past, this did cause infinite build loops for me.

Also, sorry for any confusion. The issue isn't that performance of isAffected(0 is slow. I was just surprised to see thousands of calls to it for a single save. The real issue seems to be the numerous repeated calls to doBuild().
Re: Optimizing build performance - observing redundant calls to isAffected and validation [message #1758709 is a reply to message #1758708] Fri, 31 March 2017 19:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
would be interesting why queued build data does not get emptied and which entries it has. thus it would be really interesting to understand what happens.

at least 2 calls are expected if you use xbase (which i assume)
but the second one should no have any effect cause nothing to be built


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 31 March 2017 19:36]

Report message to a moderator

Re: Optimizing build performance - observing redundant calls to isAffected and validation [message #1758710 is a reply to message #1758709] Fri, 31 March 2017 20:07 Go to previous messageGo to next message
Larry LeBron is currently offline Larry LeBronFriend
Messages: 124
Registered: October 2015
Senior Member
Quote:
would be interesting why queued build data does not get emptied and which entries it has. thus it would be really interesting to understand what happens.


I agree. queuedBuildData is populated with this list of deltas and then the list doesn't change over the series of redundant builds.

Here's an example list of queuedBuildData deltas from one save. These all correspond to Java classes which are constructed from the language blocks I altered before the save.

[ChangedResourceDescriptionDelta for java:/Objects/assertions._testHierarchicalCreateTestWME old :true,new :false, 
ChangedResourceDescriptionDelta for java:/Objects/rules._testAssertionHierarchical old :true,new :false, 
ChangedResourceDescriptionDelta for java:/Objects/rules._testTestExpression old :true,new :false, 
ChangedResourceDescriptionDelta for java:/Objects/testExpressions._bindTestWMEHierarchical old :true,new :false, 
UnconfirmedStructuralChangesDelta for java:/Objects/assertions._testCreateTestWME old :true,new :true, 
UnconfirmedStructuralChangesDelta for java:/Objects/behaviors._testClauseBlocksWithRuleMemories_2282634343 old :true,new :true, 
UnconfirmedStructuralChangesDelta for java:/Objects/rules._testHierarchicalClauseBlocksWithMemoryArguments old :true,new :true, 
UnconfirmedStructuralChangesDelta for java:/Objects/rules._testHierarchicalClauseBlocksWithMemoryArguments old :true,new :true, 
UnconfirmedStructuralChangesDelta for java:/Objects/testExpressions._testFindRuleMemWME old :true,new :true, 
UnconfirmedStructuralChangesDelta for java:/Objects/testExpressions._testHierarchicalFindFlaggedTestWME old :true,new :true]




Quote:
at least 2 calls are expected if you use xbase (which i assume)
but the second one should no have any effect cause nothing to be built


Great to know, thanks. Yes, I'm using xbase. For my workaround, I may just set a flag after the "real" build completes, ignoring any subsequent builds. I'll let you know what happens.
Re: Optimizing build performance - observing redundant calls to isAffected and validation [message #1758711 is a reply to message #1758710] Fri, 31 March 2017 20:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Yes but there changes should no lead to another bunch of changes etc.
Is it possible you generation is flaky unstable etc

(What you trying to reproduce this e.g. With the domain model example)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Optimizing build performance - observing redundant calls to isAffected and validation [message #1758713 is a reply to message #1758711] Fri, 31 March 2017 21:08 Go to previous messageGo to next message
Larry LeBron is currently offline Larry LeBronFriend
Messages: 124
Registered: October 2015
Senior Member
Yes, when trying to reproduce, I'll use the domainModel example.

I'm not exactly sure what could be flaky about my generation, but I wouldn't rule it out Smile
Re: Optimizing build performance - observing redundant calls to isAffected and validation [message #1758864 is a reply to message #1758713] Mon, 03 April 2017 22:12 Go to previous messageGo to next message
Larry LeBron is currently offline Larry LeBronFriend
Messages: 124
Registered: October 2015
Senior Member
Ok, I have attempted and failed to replicate this with the DomainModel example. I've only made a minor alteration to the DomainModel example to try
to trigger this so it's possible that I just need to add something else to the example to make this behavior occur.

More likely is that something is wrong with my DSL implementation which is causing the behavior.

A little more insight from my new hours of tracing/debugging. Any additional help is much appreciated!



At the end of the first doBuild(), during the call to Workspace.checkpoint(), I see various java deltas get queued (via the broadcastChanges() pipeline).

I see this behavior in DomainModel as well, after certain changes.

Then, during the second build, these deltas get cleared during the call to QueuedBuildData.getAndRemovePendingDeltas().

In DomainModel, this ends the process, as no further deltas are created during Workspace.checkpoint().

In my language, for some reason, the same deltas get created AGAIN during Workspace.checkpoint().

I don't know why.

Any advice is certainly appreciated. I don't see any difference in the generated Java files from build to build.
Re: Optimizing build performance - observing redundant calls to isAffected and validation [message #1758873 is a reply to message #1758864] Tue, 04 April 2017 03:12 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
I fear my knowledge is too few to give you any pointers .
Can you give any hints what you have customized in your DSLs?
Which xtext version do you use.
Can you digg into the changes that are reported, what is the actual change the have?
Do I see it correct that you generate code to the Java default package? Maybe there is a problem with that so what about changing that?
What about removing stuff from generator / inferrer step by step to nail it down


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:IJvmModelAssociations across models
Next Topic:JvmType content proposal
Goto Forum:
  


Current Time: Thu Apr 25 00:46:26 GMT 2024

Powered by FUDForum. Page generated in 0.05315 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top