Potential optimisation for LicenseCompareHelper.matchingStandardLicenseIdsWithinText()
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 28/100
- Issue 类型
- 重构
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- java
- 领域
- performance
调研方向
从 src/main/java/org/spdx/utility/compare/LicenseCompareHelper.java 开始,重点查看 matchingStandardLicenseIdsWithinText() 及其相关方法。首先检查匹配结果是否暴露原始文本的索引,以及如何处理 GPL-2.0-only 和 GPL-2.0-or-later 这类相互重叠的模板。完成的标准是:定义匹配顺序和文本移除策略,在保留所需结果及索引行为的同时,证明性能有所提升。
由索引模型根据 Issue 内容生成。
描述
It occurred to me that there may be a potentially substantial performance optimisation possible within the org.spdx.utility.compare.LicenseCompareHelper.matchingStandardLicenseIdsWithinText() family of methods, beyond the existing "quick check regex" optimisation.
Specifically, the idea is that when a match is found for a given license within an input text, the subset of text that matched is removed from the input text before further matching is performed. This not only speeds up subsequent matching (by reducing the size of the input), it also allows for early termination once the input is exhausted (i.e. below the size of the smallest possible match).
This enhancement could (should?) also order matching by approximate license popularity (i.e. the most popular licenses are checked first), since that would tend to result in early termination being reached more frequently in real world use. The OSI publishes such a list, albeit only for OSI-approved licenses - I'm fairly certain I've seen other sources of license popularity that would be more than enough for this purpose (after all it doesn't have to be precise - even using an approximate popularity order would be a lot better than random, or alphabetical, matching processing).
One possible complication is when two templates match the same text - for example the GPL-2.0-only and GPL-2.0-or-later templates tend to match the same thing. If this optimisation were implemented as I'm envisaging, whichever license template is used first would be the only one to show up in the result. Though if that behaviour is undesirable there may be workarounds - the library might maintain a list of "overlapping" templates, and ensure that when one of them matches a given text, the other overlapping templates are always checked too, prior to the matched text being removed from the input.
Another possible complication is if LicenseCompareHelper provides indexes into the original input text where a match was found (I don't recall if it does this or not; if it does I'm not currently using that capability). If so, there will be some extra bookkeeping needed to make sure that those indexes remain correct, given that each subsequent match attempt might only be looking at a fragmented subset of the original input.
- 主要语言
- Java
- 星标
- 71
- 派生
- 44
- 平均合并
- 16 小时 17 分钟
- 30 天内合并 PR
- 9
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
spdx/Spdx-Java-Library 的其他 Issue
-
question
难度 5/5 一周以上 新手友好度 30/100
spdx/Spdx-Java-Library#449 ·
-
question
难度 5/5 一周以上 新手友好度 30/100
spdx/Spdx-Java-Library#398 ·
-
wontfix
难度 3/5 1-2 天 新手友好度 45/100
spdx/Spdx-Java-Library#393 · 2 条评论 · 1 个 reaction ·
-
matching
难度 5/5 一周以上 新手友好度 35/100
spdx/Spdx-Java-Library#392 · 4 条评论 ·
-
enhancement
难度 5/5 一周以上 新手友好度 30/100
spdx/Spdx-Java-Library#390 · 11 条评论 · 1 个 reaction ·
查看 spdx/Spdx-Java-Library 的全部 Issue
相似的 Issue
-
enhancement
难度 1/5 1 小时以内 新手友好度 88/100
helidon-io/helidon#12721 ·
维护者通常 1 天内回复
-
status: team-only type: dependency-upgrade
难度 2/5 1-3 小时 新手友好度 64/100
spring-projects/spring-boot#51966 ·
维护者通常 1 天内回复
-
Missing repro Platform: Android
难度 2/5 1-3 小时 新手友好度 78/100
software-mansion/react-native-reanimated#10816 · 2 条评论 ·
维护者通常 1 天内回复
-
area/docs backport/26.6 backport/26.8 kind/bug status/triage
难度 1/5 1 小时以内 新手友好度 75/100
维护者通常 1 天内回复
-
[destination-snowflake] Custom domains rejected unlike source connections可能已有人在做 @kuza55 今天认领。 未关闭autoteam community connectors/destination/snowflake team/use
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复