BUG: CreateStringArrayAction allocates every string during preflight
メンテナーはふだん 6 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- cpp
- 領域
- backend, performance, testing
調査の方向性
Read src/simplnx/Filter/Actions/CreateStringArrayAction.cpp and compare its mode handling with CreateArrayAction and CreateNeighborListAction; the issue identifies the unconditional value allocation as the problem. Check whether preflight code reads strings from arrays created by this action, then use the proposed test/EmptyStringStoreTest.cpp case to verify a preflight placeholder and add an execute mode check for initialized values. Done when both modes behave as expected and the focused test passes.
索引モデルが issue の本文から書いたものです。
説明
Problem
CreateStringArrayAction ignores the action mode. In preflight it allocates one std::string for every tuple and creates a populated StringArray, instead of a placeholder store as CreateArrayAction and CreateNeighborListAction do. Preflight runs every time a parameter changes in the GUI, so a filter that creates a large string output allocates memory proportional to its tuple count on each preflight. An empty std::string takes about 24 bytes, so a 100 million tuple string array costs about 2.4 GB per preflight.
Expected: in IDataAction::Mode::Preflight the action creates the StringArray with an EmptyStringStore, which holds only the tuple shape. Actual: the array holds totalTuples real strings.
Seen on develop at 705a1b7f2. 22 filters use the action, for example Read CSV File, Read String Data Array, Concatenate Data Arrays and the EBSD readers.
Steps to Reproduce
- Configure simplnx with
SIMPLNX_BUILD_TESTS=ONat 705a1b7f2. - Add the test below to
test/EmptyStringStoreTest.cpp. - Build
simplnx_testand runctest --test-dir <build-dir> -R "CreateStringArrayAction" -j 1 --output-on-failure. - The test fails: the array created in preflight is not a placeholder.
Cause
CreateStringArrayAction::apply() receives mode but never reads it. It always builds the full value vector and a populated array (CreateStringArrayAction.cpp#L48-L51):
usize totalTuples = std::accumulate(m_Dims.cbegin(), m_Dims.cend(), static_cast<usize>(1), std::multiplies<>());
std::vector<std::string> values(totalTuples, m_InitializeValue);
StringArray* array = StringArray::CreateWithValues(dataStructure, name, m_Dims, values, dataObjectId);
The numeric path chooses a placeholder in preflight (ArrayCreationUtilities.hpp#L188), and pipeline preflight applies every action in that mode (PipelineFilter.cpp#L196).
Verification Unit Test
File: test/EmptyStringStoreTest.cpp. It also needs these includes:
#include "simplnx/DataStructure/DataStructure.hpp"
#include "simplnx/DataStructure/StringArray.hpp"
#include "simplnx/Filter/Actions/CreateStringArrayAction.hpp"
#include "simplnx/UnitTest/UnitTestCommon.hpp"
TEST_CASE("CreateStringArrayAction: preflight creates a placeholder store")
{
DataStructure dataStructure;
const DataPath arrayPath({"Strings"});
const CreateStringArrayAction action(ShapeType{1000}, arrayPath, "initial");
Result<> result = action.apply(dataStructure, IDataAction::Mode::Preflight);
SIMPLNX_RESULT_REQUIRE_VALID(result);
const auto* stringArray = dataStructure.getDataAs<StringArray>(arrayPath);
REQUIRE(stringArray != nullptr);
REQUIRE(stringArray->getNumberOfTuples() == 1000);
REQUIRE(stringArray->isPlaceholder());
}
Run only this test:
ctest --test-dir <build-dir> -R "CreateStringArrayAction" -j 1 --output-on-failure --timeout 1500 --no-tests=error
Failure seen on macOS arm64, Release build at 705a1b7f2:
test/EmptyStringStoreTest.cpp:78: FAILED:
REQUIRE( stringArray->isPlaceholder() )
with expansion:
false
test cases: 1 | 1 failed
assertions: 4 | 3 passed | 1 failed
Proposed Fix
In CreateStringArrayAction::apply(), branch on mode. For Mode::Preflight, create the array without values and give it an EmptyStringStore, as the metadata-only .dream3d import already does in Dream3dIO.cpp:
if(mode == Mode::Preflight)
{
StringArray* array = StringArray::CreateWithValues(dataStructure, name, m_Dims, {}, dataObjectId);
// ... same nullptr error handling as today
array->setStore(std::make_shared<EmptyStringStore>(m_Dims));
return {};
}
Keep the current code for Mode::Execute.
An EmptyStringStore throws on element access. Before the change, check that no preflightImpl() and no code that runs during pipeline preflight reads the values of a string array that an earlier filter created through this action, because those reads would start to throw. Add an execute-mode test that checks the array holds totalTuples copies of the initial value.
Notes
- Found while writing the simplnx style-guide rule "Preflight Does Not Allocate or Read Array Data" (PR #1889), which names this action as a current exception.
- Not verified: whether any filter reads string values during preflight today. The proposed-fix check above covers it.
- 主要言語
- C++
- スター
- 18
- フォーク
- 15
- 平均マージ
- 4日 23時間
- マージ済み PR(30日)
- 42
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
BlueQuartzSoftware/simplnx のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
BlueQuartzSoftware/simplnx#1987 ·
メンテナーはふだん 6 日以内に返信
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
BlueQuartzSoftware/simplnx#1980 ·
メンテナーはふだん 6 日以内に返信
-
Testing
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
BlueQuartzSoftware/simplnx#1979 ·
メンテナーはふだん 6 日以内に返信
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
BlueQuartzSoftware/simplnx#1978 ·
メンテナーはふだん 6 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
BlueQuartzSoftware/simplnx#1945 ·
メンテナーはふだん 6 日以内に返信
BlueQuartzSoftware/simplnx の issue をすべて見る
似ている issue
-
bug triage
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
26.04 bug dark-mode Easy Hack impress symptom: visual
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
CollaboraOnline/online#16421 · コメント 1 件 ·
-
area/cs bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
ydb-platform/ydb#59881 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
-
documentation enhancement lua server
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100