To do a slope analysis on a site I project a grid of point on a Topography. For some reason this is much slower in Revit 2021 than it is in Revit 2020.
The reference intersector is created as follows:
ReferenceIntersector refIntersector = new ReferenceIntersector(topo.Id, FindReferenceTarget.Mesh, view);
Then I do a loop over all my points and use a System.Diagnostics.Stopwatch to measure the total time taken everytime I call the FindNearest function, to make sure I measure only the FindNearest call:
StartWatch();
ReferenceWithContext referenceWithContext = refIntersector.FindNearest(pt, rayDirection);
StopWatch();
Revit 21: Total Projection Time = 233s (number of projections: 6332)
Revit 20: Total Projection Time = 147s (number of projections: 6332)
This is almost two times slower !!
Is anybody experiencing this as well?
The topography is 2.1km x 1.3km long
Solved! Go to Solution.
To do a slope analysis on a site I project a grid of point on a Topography. For some reason this is much slower in Revit 2021 than it is in Revit 2020.
The reference intersector is created as follows:
ReferenceIntersector refIntersector = new ReferenceIntersector(topo.Id, FindReferenceTarget.Mesh, view);
Then I do a loop over all my points and use a System.Diagnostics.Stopwatch to measure the total time taken everytime I call the FindNearest function, to make sure I measure only the FindNearest call:
StartWatch();
ReferenceWithContext referenceWithContext = refIntersector.FindNearest(pt, rayDirection);
StopWatch();
Revit 21: Total Projection Time = 233s (number of projections: 6332)
Revit 20: Total Projection Time = 147s (number of projections: 6332)
This is almost two times slower !!
Is anybody experiencing this as well?
The topography is 2.1km x 1.3km long
Solved! Go to Solution.
Solved by jeremy_tammik. Go to Solution.
Solved by jeremy_tammik. Go to Solution.
Thank you for the interesting observation.
If you would like to share a minimal reproducible case, I will gladly pass it on the the development team for analysis:
https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b
Thank you for the interesting observation.
If you would like to share a minimal reproducible case, I will gladly pass it on the the development team for analysis:
https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b
Hi Jeremy,
Thanks for looking into this.
I can confirm that this is an issue as I can even reproduce it on the rac_advanced_sample_project.rvt
The minimal code below can be used to reproduce the issue.
Here is the difference on a large site that I have (2.1km x 1.3km):
Revit 2020: Projection Time == 69s (3000)
Revit 2021: Projection Time == 112s (3000)
and here is the difference on the rac_advanced_sample_project.rvt
Revit 2020: Projection Time == 17s (30000)
Revit 2021: Projection Time == 29s (30000)
To run the test, you just need to duplicate the 3D view, turn off the section Box and in VG remove everything but Topography (not sure it makes a difference, but I was doing it). Then select the Topography and run an external command that calls the function below:
(note: adjust the counter based on the size of the site as shown in the comments)
void PerformanceTest(UIDocument uiDoc, Document doc)
{
// Get the selected Topography
Selection userSel = uiDoc.Selection;
ICollection<ElementId> set = userSel.GetElementIds();
TopographySurface topo = null;
foreach (ElementId id in set)
{
Element element = doc.GetElement(id);
if (element is TopographySurface)
{
topo = (TopographySurface)element;
break;
}
}
if (topo == null)
{
return;
}
View activeView = doc.ActiveView;
if (!(activeView is View3D))
{
return;
}
View3D view = activeView as View3D;
// Get topo center
BoundingBoxXYZ bound = topo.get_BoundingBox(view);
XYZ rayBase = new XYZ((bound.Max.X + bound.Min.X) / 2, (bound.Max.Y + bound.Min.Y) / 2, bound.Min.Z - 10);
// Create the intersector
List<ElementId> meshId = new List<ElementId>();
meshId.Add(topo.Id);
ReferenceIntersector refIntersector = new ReferenceIntersector(topo.Id, FindReferenceTarget.Mesh, view);
Random rnd = new Random();
Stopwatch watch = new Stopwatch();
int i;
for (i = 0; i < 30000; i++) // on a large site use 3000, on a small site use 30000
{
// Create a random point around the topo center
XYZ pt = new XYZ(rayBase.X + rnd.Next(1, 100) - 50, rayBase.Y + rnd.Next(1, 100) - 50, rayBase.Z);
watch.Start();
ReferenceWithContext referenceWithContext = refIntersector.FindNearest(pt, XYZ.BasisZ);
watch.Stop();
if (referenceWithContext != null)
{
//
}
}
Debug.Print("Projection Time == " + Math.Round((double)watch.ElapsedMilliseconds / 1000).ToString() + $"s ({i})");
}
Hi Jeremy,
Thanks for looking into this.
I can confirm that this is an issue as I can even reproduce it on the rac_advanced_sample_project.rvt
The minimal code below can be used to reproduce the issue.
Here is the difference on a large site that I have (2.1km x 1.3km):
Revit 2020: Projection Time == 69s (3000)
Revit 2021: Projection Time == 112s (3000)
and here is the difference on the rac_advanced_sample_project.rvt
Revit 2020: Projection Time == 17s (30000)
Revit 2021: Projection Time == 29s (30000)
To run the test, you just need to duplicate the 3D view, turn off the section Box and in VG remove everything but Topography (not sure it makes a difference, but I was doing it). Then select the Topography and run an external command that calls the function below:
(note: adjust the counter based on the size of the site as shown in the comments)
void PerformanceTest(UIDocument uiDoc, Document doc)
{
// Get the selected Topography
Selection userSel = uiDoc.Selection;
ICollection<ElementId> set = userSel.GetElementIds();
TopographySurface topo = null;
foreach (ElementId id in set)
{
Element element = doc.GetElement(id);
if (element is TopographySurface)
{
topo = (TopographySurface)element;
break;
}
}
if (topo == null)
{
return;
}
View activeView = doc.ActiveView;
if (!(activeView is View3D))
{
return;
}
View3D view = activeView as View3D;
// Get topo center
BoundingBoxXYZ bound = topo.get_BoundingBox(view);
XYZ rayBase = new XYZ((bound.Max.X + bound.Min.X) / 2, (bound.Max.Y + bound.Min.Y) / 2, bound.Min.Z - 10);
// Create the intersector
List<ElementId> meshId = new List<ElementId>();
meshId.Add(topo.Id);
ReferenceIntersector refIntersector = new ReferenceIntersector(topo.Id, FindReferenceTarget.Mesh, view);
Random rnd = new Random();
Stopwatch watch = new Stopwatch();
int i;
for (i = 0; i < 30000; i++) // on a large site use 3000, on a small site use 30000
{
// Create a random point around the topo center
XYZ pt = new XYZ(rayBase.X + rnd.Next(1, 100) - 50, rayBase.Y + rnd.Next(1, 100) - 50, rayBase.Z);
watch.Start();
ReferenceWithContext referenceWithContext = refIntersector.FindNearest(pt, XYZ.BasisZ);
watch.Stop();
if (referenceWithContext != null)
{
//
}
}
Debug.Print("Projection Time == " + Math.Round((double)watch.ElapsedMilliseconds / 1000).ToString() + $"s ({i})");
}
I would also consider the influence of other add-ins i.e. is this an issue with the API method or something introduced in 2021 (in-built (1st party?) and 3rd party) that goes on in the background slowing down the pace.
Would suggest striping out other add-ins for comparison (from all the various locations of loading them) if not already done so.
I would also consider the influence of other add-ins i.e. is this an issue with the API method or something introduced in 2021 (in-built (1st party?) and 3rd party) that goes on in the background slowing down the pace.
Would suggest striping out other add-ins for comparison (from all the various locations of loading them) if not already done so.
@RPTHOMAS108 I have removed the other add-ins in the AppData folder (can't remove the add-ins in Program Data as I don't have admin rights).
I get the exact same time. Revit 21 is much slower. I have created an add-ins to create Solar Farms and it is a shame that I don't get the same performance in Revit 21.
Could someone at Autodesk @jeremy_tammik have alook into this? I have provided the code to reproduce the issue
@RPTHOMAS108 I have removed the other add-ins in the AppData folder (can't remove the add-ins in Program Data as I don't have admin rights).
I get the exact same time. Revit 21 is much slower. I have created an add-ins to create Solar Farms and it is a shame that I don't get the same performance in Revit 21.
Could someone at Autodesk @jeremy_tammik have alook into this? I have provided the code to reproduce the issue
I will gladly raise this issue with the development team. Can you please share the appropriately modified sample model here as well, so they do not have to duplicate those steps, and to make absolutely sure that we are talking about the same thing? Thank you!
I will gladly raise this issue with the development team. Can you please share the appropriately modified sample model here as well, so they do not have to duplicate those steps, and to make absolutely sure that we are talking about the same thing? Thank you!
Hi @jeremy_tammik ,
Please find the file attached. This is the sample file rac_advanced_sample_project.rvt that has been purged.
There is a 3D view called "Reference Intersector Test" that can be used to run the script provided. With this file and 30,000 iterations (in the FOR loop) I get:
17s in Revit 2020
27s in Revit 2021
Just in case someone asks why would I need 30,000 iterations:
Thanks!
Hi @jeremy_tammik ,
Please find the file attached. This is the sample file rac_advanced_sample_project.rvt that has been purged.
There is a 3D view called "Reference Intersector Test" that can be used to run the script provided. With this file and 30,000 iterations (in the FOR loop) I get:
17s in Revit 2020
27s in Revit 2021
Just in case someone asks why would I need 30,000 iterations:
Thanks!
Dear Mehdi,
Thank you for your reproducible case.
I logged the issue REVIT-174745 [ReferenceIntersector slowdown in Revit 2021] with our development team for this on your behalf as it requires further exploration and possibly a modification to our software. Please make a note of this number for future reference.
You are welcome to request an update on the status of this issue or to provide additional information on it at any time quoting this change request number.
This issue is important to me. What can I do to help?
This issue needs to be assessed by our engineering team and prioritised against all other outstanding change requests. Any information that you can provide to influence this assessment will help. Please provide the following where possible:
This information is extremely important. Our engineering team have limited resources, and so must focus their efforts on the highest impact items. We do understand that this will cause you delays and affect your development planning, and we appreciate your cooperation and patience.
Best regards,
Jeremy
Dear Mehdi,
Thank you for your reproducible case.
I logged the issue REVIT-174745 [ReferenceIntersector slowdown in Revit 2021] with our development team for this on your behalf as it requires further exploration and possibly a modification to our software. Please make a note of this number for future reference.
You are welcome to request an update on the status of this issue or to provide additional information on it at any time quoting this change request number.
This issue is important to me. What can I do to help?
This issue needs to be assessed by our engineering team and prioritised against all other outstanding change requests. Any information that you can provide to influence this assessment will help. Please provide the following where possible:
This information is extremely important. Our engineering team have limited resources, and so must focus their efforts on the highest impact items. We do understand that this will cause you delays and affect your development planning, and we appreciate your cooperation and patience.
Best regards,
Jeremy
Dear Mehdi,
Thank you for your patience with this. Just a small update to let you know that the development team analysed the issue REVIT-174745 [ReferenceIntersector slowdown in Revit 2021] and reproduced the slowdown you describe. No idea how long it will take to fix, though, and when such a fix might become publicly available...
Best regards,
Jeremy
Dear Mehdi,
Thank you for your patience with this. Just a small update to let you know that the development team analysed the issue REVIT-174745 [ReferenceIntersector slowdown in Revit 2021] and reproduced the slowdown you describe. No idea how long it will take to fix, though, and when such a fix might become publicly available...
Best regards,
Jeremy
Yup. They reproduced, analysed, performed some minor fixes, and determined that the issue requires further exploration and a possible code fix in a future version. For this, they raised a new ticket REVIT-175514 [ReferenceIntersector slowdown in Revit 2021]. Please make a note of this number for future reference as well.
Yup. They reproduced, analysed, performed some minor fixes, and determined that the issue requires further exploration and a possible code fix in a future version. For this, they raised a new ticket REVIT-175514 [ReferenceIntersector slowdown in Revit 2021]. Please make a note of this number for future reference as well.
Dear Mehdi,
Thank you again for your patience with this.
After an impressive amount of discussion, research, analysis, and two change requests, the development team resolved the issue. The summary is short and sweet:
It turned out that 'FORCEINLINE' does make a significant difference in the way the compiler treats even simple functions.
We restored this for XYZ and UV and the macro now runs at the same speed as before.
Unfortunately, you may have to wait for the next major release of Revit to actually experience the improvement
Best regards,
Jeremy
Dear Mehdi,
Thank you again for your patience with this.
After an impressive amount of discussion, research, analysis, and two change requests, the development team resolved the issue. The summary is short and sweet:
It turned out that 'FORCEINLINE' does make a significant difference in the way the compiler treats even simple functions.
We restored this for XYZ and UV and the macro now runs at the same speed as before.
Unfortunately, you may have to wait for the next major release of Revit to actually experience the improvement
Best regards,
Jeremy
Haha! Funny that it sparked a heated debate!
Thank you very much Jeremy for getting this sorted.
Will look forward to the next major release.
Kind Regards,
Mehdi
Haha! Funny that it sparked a heated debate!
Thank you very much Jeremy for getting this sorted.
Will look forward to the next major release.
Kind Regards,
Mehdi
Can't find what you're looking for? Ask the community or share your knowledge.