BUG: CreateStringArrayAction allocates every string during preflight
Los mantenedores suelen responder en 6 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 78/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- cpp
- Área
- backend, performance, testing
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C++
- Estrellas
- 18
- Forks
- 15
- Merge medio
- 4 d 23 h
- PR fusionados (30 d)
- 42
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de BlueQuartzSoftware/simplnx
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
BlueQuartzSoftware/simplnx#1987 ·
Los mantenedores suelen responder en 6 días
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
BlueQuartzSoftware/simplnx#1980 ·
Los mantenedores suelen responder en 6 días
-
Testing
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
BlueQuartzSoftware/simplnx#1979 ·
Los mantenedores suelen responder en 6 días
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
BlueQuartzSoftware/simplnx#1978 ·
Los mantenedores suelen responder en 6 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
BlueQuartzSoftware/simplnx#1945 ·
Los mantenedores suelen responder en 6 días
Todos los issues de BlueQuartzSoftware/simplnx
Issues similares
-
bug triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
26.04 bug dark-mode Easy Hack impress symptom: visual
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
CollaboraOnline/online#16421 · 1 comentario ·
-
area/cs bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
ydb-platform/ydb#59881 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
Los mantenedores suelen responder en 1 día
-
documentation enhancement lua server
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100