Skip to content

perf(welcome): index connection tree to rebuild groups in linear time#1743

Open
desperadoxhy wants to merge 1 commit into
TableProApp:mainfrom
desperadoxhy:perf/welcome-tree-index
Open

perf(welcome): index connection tree to rebuild groups in linear time#1743
desperadoxhy wants to merge 1 commit into
TableProApp:mainfrom
desperadoxhy:perf/welcome-tree-index

Conversation

@desperadoxhy

Copy link
Copy Markdown
Contributor

问题

WelcomeViewModel.rebuildTree 对每个 group 单独算 connectionCount / depthOf / maxDescendantDepth(各自递归全扫),buildGroupTree 每层 filter 全表,O(G²+C·G),被 18 处连接操作触发。连接/分组多时每次操作卡。

方案

新增 buildGroupTreeIndexed + computeGroupTreeIndices:一次遍历建索引,BFS 算 depth,自底向上聚合 subtree count + maxDepth,降到 O(G+C)。入口重建索引(非增量,无一致性风险)。原 buildGroupTree / connectionCount / depthOf / maxDescendantDepth 公共 API 不变。treeItems 输出结构不变。

验证

  • BUILD SUCCEEDED
  • 随机属性测试:32 个随机拓扑(1-12 group、1-15 连接,含嵌套/孤儿/dangling 引用)断言新算法与原算法在树结构、depth、maxDepth、count 四项完全等价
  • 过程中发现并修复 maxDescendantDepth 漏 1+ 的 bug(属性测试捕获)
  • WelcomeViewModelTests 原测试无回归

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Before we can merge this PR, you need to sign our Contributor License Agreement.

To sign, please comment below with:

I have read the CLA Document and I hereby sign the CLA.


I have read the CLA Document and I hereby sign the CLA.


xuhengyu seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@desperadoxhy

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant