Skip to content

Commit

Permalink
Merge pull request #486 from kitsudaiki/fix/fix-cluster-resize
Browse files Browse the repository at this point in the history
fix: fix cluster-resize
  • Loading branch information
kitsudaiki authored Oct 24, 2024
2 parents 4539446 + 89621b8 commit f2d4d68
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
- fixed memory violations found by the new added ASan-memory-check
- some cases of invalid http-requests had returned an 200 reponse with empty body, which was fixed
- changed token-key in helm-chart from configmap to secret
- fixed memory-corruption in cluster-resize, because a pointer was used after free

### Removed

Expand Down
15 changes: 10 additions & 5 deletions src/hanami/src/core/processing/cluster_resize.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ resizeBlocks(Hexagon* targetHexagon)
* @return true, if successful, else false
*/
inline bool
createNewSection(Cluster& cluster, Connection* sourceConnection)
splitSection(Cluster& cluster, Connection* sourceConnection)
{
// get origin object
SourceLocation sourceLoc = getSourceNeuron(sourceConnection->origin, &cluster.hexagons[0]);
Expand All @@ -133,9 +133,6 @@ createNewSection(Cluster& cluster, Connection* sourceConnection)
ItemBuffer<SynapseBlock>* synapseBlockBuffer = &targetHexagon->attachedHost->synapseBlocks;

// get target-connection
if (targetHexagon->header.numberOfFreeSections < NUMBER_OF_SYNAPSESECTION / 2) {
resizeBlocks(targetHexagon);
}
Connection* targetConnection = searchTargetInHexagon(targetHexagon, *synapseBlockBuffer);
if (targetConnection == nullptr) {
Hanami::ErrorContainer error;
Expand Down Expand Up @@ -201,6 +198,7 @@ createNewSection(Cluster& cluster,
}
targetHexagon->header.numberOfFreeSections--;
targetHexagon->wasResized = true;
cluster.metrics.numberOfSections++;

// initialize new connection
targetConnection->origin.blockId = blockId;
Expand Down Expand Up @@ -248,10 +246,17 @@ updateCluster(Cluster& cluster, Hexagon* hexagon)

if (connection->splitValue > 0.0f) {
found = true;
createNewSection(cluster, connection);
splitSection(cluster, connection);
}
connection->splitValue = 0.0f;
}

// resize if necessary
// IMPORTANT: this must be done at the end, because the resize change the target of the
// pointer
if (hexagon->header.numberOfFreeSections < NUMBER_OF_SYNAPSESECTION / 2) {
resizeBlocks(hexagon);
}
}
return found;
}
Expand Down
2 changes: 2 additions & 0 deletions testing/python_sdk_api/sdk_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ def test_workflow():
length=50)

print("\n")
result = cluster.get_cluster(token, address, cluster_uuid, False)
print(json.dumps(json.loads(result), indent=4))
result = task.delete_task(token, address, task_uuid, cluster_uuid, False)

# save and reload checkpoint
Expand Down

0 comments on commit f2d4d68

Please sign in to comment.