We know that2.02-04 Text Stringsare bad for Anaplan models and that text functions and formulas using text are the slowest (slow in comparison to similarly-sized numeric formulas). One of the biggest contributing factors to the poor performance of text is the impact on the memory used by Anaplan.

下图显示了Anaplan单元类型的比较,以突出文本的性能和记忆使用。
按细胞类型进行性能成本按细胞类型进行性能成本Memory Use by Cell TypeMemory Use by Cell Type

本文将查看将文本连接在一起的内存和创建的内存 - 文本串联。
If we look at a simple text concatenation that joins the codes from three lists to create a unique ID, here's the formula:

CODE(ITEM(Product)) & "_" & CODE(ITEM(SKU)) & "_" & CODE(ITEM(Location))

此行项目的“适用”是“产品,SKU,位置”;列表分别具有以下尺寸100、2000、10个项目。这为我们提供了2,000,000个细胞的细胞计数。

This means we are doing four text additions 2 million times, and consequently, Anaplan is creating and throwing away millions of temporary strings in memory as it processes the formula.

让我们详细了解这个过程。在下面的示例中,我们将使用1个字节代表文本中的1个字符。这是一个基本的简化,实际的内存使用将更高。

公式将首先检索产品代码”123" and append an underscore to this text to create the first part of this string. The formula then retrieves the SKU code and appends that to the new part, creating another piece of text in memory. The first two bits of text we had in memory, "123" and "_", will be discarded and the memory will be cleared. We now have a new bit of text in memory "123_4567" and the previous parts can be discarded, 8 bytes in this case. This continues as the string is built up, new parts are created in memory and added to the previous parts to grow the string, the previous parts are then discarded and the memory cleared.

串联

正是创建和丢弃文本部分的过程会影响内存并使该公式慢慢。我们在最终文本的构建中使用并清除大量内存,这是一个昂贵的计算能力(相对于数字计算)的昂贵过程。

When there is a lot of this memory allocation happening at a fast rate, the processes of clearing up memory for the next calculations can cause delays, and in some circumstances "out of memory" errors. The process of memory clearing is known as "garbage collection", it will stop Anaplan and delay calculations while it is happening.

The charts below show memory use as concatenation increases, for all the chartsX轴是串联的数量“&”,1至90。

测试模型的大小为704MB,随着单元格中文本的长度的增加,它保持恒定,或者随着额外的串联或公式设置为空白而增加;这是Anaplan估计的尺寸基于细胞类型为该模型计算的。

Memory Used by TextMemory Used by Text

The graph above shows the actual memory used by the text line item; at 70 concatenations the memory from text has surpassed the predicted model memory size of 704Mb, from this point on the model will be using more memory than expected. As the concatenation increases the memory needed increases as the length of the text created grows, the length of each part of the text will also contribute to memory use; this example used numbers that varied from 1 to 4 digits, so quite short compared to the most text found in models.

As discussed above, the memory discarded in building the strings will also increase and to a much greater amount, the formula will create and discard a lot more memory than the final result.

Model Open TimeModel Open Time

随着串联的增加,性能将降低;内存分配和字符串操作的增加将导致更长的计算时间。我们可以在模型开放持续时间的上图中看到这一点,其中所有订单项均已完全计算。模型的开放持续时间比记忆增长更高,这表明我们的串联的影响正在增加,并且垃圾收集的延迟在更高的串联量增长了更长的时间。

Similar effects are seen as cell count grows or text length increases, the larger the amounts of memory used and discarded the longer they take.

This performance hit would also apply to any calculations affecting this line item in the model. If a user added a new SKU to the list then the code would need to recalculate the whole code overall 2 million cells.

Average Length of TextAverage Length of Text

The final chart just ties into the first in showing the linear growth of the text as concatenation increases. This is the average length of text across all cells (2 million in this test).

Avoiding Memory Problems With Concatenation

This is covered by Planual rule2.02-05创建最小层次结构的“连接”
Using our example formula above this would mean doing the following:

Formula Applies To 细胞计数
文本1=代码(item(product))&“ _” 产品 100
text2= "_" & CODE(ITEM(Location)) Location 10
text3= CODE(ITEM(SKU)) & Text2 SKU, Location 20,000
UniqueCode= Text1 & Text3 产品,SKU,位置 2,,,,000,000

This shows how we can do just one concatenation at the full cell count; the bulk of the work is done at the lowest cell counts possible to minimize the performance and memory impact we discussed above. The extra text created is an impact on the model size but is a good trade-off for the increased performance and reduced memory use. This also has the benefit of separating the individual calculations, meaning that if we use the previous example of someone adding an SKU then Text1 and Text2 would not need to be recalculated, reducing the number of calculations needed to achieve the same result; this is Planual rule2.02-18分手公式

Let's look at some calculation timings for this formula optimization:

The original formula doing four concatenations took1,,,,089ms to calculate, and the model open took 0.19s. The model open for the optimized model was 0.07s. The model open time is reduced by 63%—the calculation cost is reduced by 68%.
这是优化计算的分解:

UniqueCode 349.0ms
text3 3.542ms
文本1 0.108ms
text2 0.060ms

如果项目的顺序为product_location_sku,则您将以这种方式添加两个下划线:

"_" & CODE(ITEM(Location)) & "_"

这将是我们以最低的单元格计数进行最大串联的方式。

另外,请注意,代码(item(item(item))公式应在系统模块中并引用,您甚至可以创建一个单元订单项来引用“ _”。

在可能的情况下,需要将文本保持在最低限度,并且订单项还应将串联保持在最低限度。我建议,如果您有五个以上的串联,请考虑为什么需要此文本,并且可以通过替代建模来实现。When using text for "error" messages, try to use booleans as well as list members for the error text for example.

希望这会增加一些细节和知识,了解为什么创建了规则以及考虑模型可伸缩性时的重要性。不幸的是,我们的模型使用的内存是我们需要考虑的某些方法,即Anaplan使用的当前技术,内存使用是所有软件必须考虑的事情。遵循有关使用文本并最小化文本连接的计划规则,将有很长的路要走,可以帮助实现这一目标。

The content in this article has not been evaluated for all Anaplan implementations and may not be recommended for your specific situation.
Please consult your internal administrators prior to applying any of the ideas or steps in this article.
Comments

很酷的文章!
Many clients / novice model builders are sure that Anaplan works quickly and online anyway. Therefore, they are not very fond of following such recommendations. But charts and studies on the opening times of the model are a very strong argument.

Thank You, Mark!

对我来说,当将两个或三个代码粘在一起时,要记住这一点。值得庆幸的是,它不需要经常。

这些图表确实显示了如果您做“错误”的事情,可能会发生混乱!

你们都是对的,Anaplan非常强大,我们继续改善平台,在建模方面,它非常宽容和灵活。我想帮助的是,当您突破界限时,模型缩放到大尺寸时;这是我们真正的最佳实践和建议真正出现的地方。所有系统都有限制,并且类似的计划和信息有助于我们将这些限制更远,从而使模型更加自由!

这真太了不起了@MarkWarren! Love the detailed breakdown that shows visually the impact text strings can have.

@MarkWarren使用子公司视图的绝佳例外之一。感谢马克的这项出色的分析。

我还想提高一点manipu文本lation using functions like LEFT, MID etc. These also behave in a similar way to that described above in that they have a large impact on memory, creating and throwing away a lot of memory as they calculate, which leads to poor performance and can lead to memory problems at large scale.

谢谢@MarkWarren,,,,

I'll forward this article to all my "poor string performance deniers":slightly_smiling_face:

Thanks Mark, Very insightful article!

我们知道文本不是很好(在任何地方,不仅是Anaplan),但由于各自的原因,我们仍然需要拥有这样的东西。我们经常在现有模型中找到的一件事,对于设计最佳解决方案来说都是一件好事。

Version history
Last update:
‎04-21-202112:51 PM
Updated by:
About the Author
标签(2)