refactor: Improve Zone Initialization and Node Shards Assignment #154
+17
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi @jostanislas And JunoDb Team this PR
Refactor
EtcdReader.readNodesShardsMethod for More Efficient Zone Initialization and Node shards assignmentDescription:
Issue Overview:
In the
etcdpackage and fileetcdreader.go, thereadNodesShardsmethod is responsible for reading Nodes Shards assignment through the etcd reader. During this process, it callscluster.NewZoneFromConfigto initialize zones ifc.Zones[zoneid] == nil. However, there is an opportunity to improve efficiency and avoid redundancy in zone and its nodes initialization.cluster.NewZoneFromConfignot just initialize zone it also executezone.initShardsAsssignment(numZones, numShards)to populate node but inreadNodesShardswe override this logic of populating node though this statementc.Zones[zoneid].Nodes[nodeid].StringToNode(uint32(zoneid), uint32(nodeid), string(ev.Value), TagPrimSecondaryDelimiter, TagShardDelimiter)Proposed Solution:
To enhance code efficiency and eliminate redundancy, I propose refactoring the
readNodesShardsfunction. Specifically, I suggest replacing the usage ofcluster.NewZoneFromConfigwith the newNewZonefunction. This new function will initialize zones without populating theNodesfield, leaving that task to be performed later in the code when it is needed. By making this change, we can avoid overwriting node data during zone initialization and improve overall efficiency.Impact:
This change will optimize the
readNodesShardsfunction and reduce redundant population of theNodesfield during zone initialization. It is expected to have a positive impact on performance.Additional Context:
This change is suggested as part of ongoing efforts to optimize and improve the codebase of the Juno project. It aims to make zone initialization and Nodes Shards assignment more efficient while maintaining code correctness.
And it Fixes #153