Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of LookupImpl.LookupAnalysis via pre-built index #1279

Closed

Conversation

Friendseeker
Copy link
Member

@Friendseeker Friendseeker commented Nov 5, 2023

LookupImpl.LookupAnalysis takes O(classpath length) to run. In project with long classpath, LookupImpl.LookupAnalysis is noticeable in profiling. (According to #593)

This PR introduces a binaryClassNameToAnalysis lookup table to reduce lookup time complexity.

For memory consumption of binaryClassNameToAnalysis, assuming there are 10000 binary class names in the worst case, each with 50 characters (100 bytes), the total key size is 10000 * 100 bytes = 1 MB, which is small.

Closes #593.

@eed3si9n
Copy link
Member

eed3si9n commented Nov 6, 2023

Overall LGTM, but if would be cool if we could include either a benchmark or some sample project that demonstrates the improvement.

@Friendseeker
Copy link
Member Author

Here's the two recent CI benchmark results with & without the optimization:

https://github.com/sbt/zinc/actions/runs/6773539163/job/18408627550 and https://github.com/sbt/zinc/actions/runs/6764410486/job/18382666918

Here's some excerpts:

Without optimization:

[info] Result "xsbt.HotScalacBenchmark.action":
[info]   N = 5
[info]   mean =  23098.871 ±(99.9%) 497.066 ms/op
[info]   Histogram, ms/op:
[info]     [22900.000, 22925.000) = 1 
[info]     [22925.000, 22950.000) = 0 
[info]     [22950.000, 22975.000) = 0 
[info]     [22975.000, 23000.000) = 0 
[info]     [23000.000, 23025.000) = 0 
[info]     [23025.000, 23050.000) = 0 
[info]     [23050.000, 23075.000) = 1 
[info]     [23075.000, 23100.000) = 1 
[info]     [23100.000, 23125.000) = 0 
[info]     [23125.000, 23150.000) = 0 
[info]     [23150.000, 23175.000) = 0 
[info]     [23175.000, 23200.000) = 1 
[info]     [23200.000, 23225.000) = 0 
[info]     [23225.000, 23250.000) = 0 
[info]     [23250.000, 23275.000) = 1 
[info]   Percentiles, ms/op:
[info]       p(0.0000) =  22917.677 ms/op
[info]      p(50.0000) =  23085.449 ms/op
[info]      p(90.0000) =  23253.221 ms/op
[info]      p(95.0000) =  23253.221 ms/op
[info]      p(99.0000) =  23253.221 ms/op
[info]      p(99.9000) =  23253.221 ms/op
[info]      p(99.9900) =  23253.221 ms/op
[info]      p(99.9990) =  23253.221 ms/op
[info]      p(99.9999) =  23253.221 ms/op
[info]     p(100.0000) =  23253.221 ms/op
[info] Secondary result "xsbt.HotScalacBenchmark.action:gc.alloc.rate":
[info]   130.140 ±(99.9%) 3.472 MB/sec [Average]
[info]   (min, avg, max) = (129.191, 130.140, 131.328), stdev = 0.902
[info]   CI (99.9%): [126.668, 133.613] (assumes normal distribution)
[info] Secondary result "xsbt.HotScalacBenchmark.action:gc.alloc.rate.norm":
[info]   3156755382.400 ±(99.9%) 9353105.171 B/op [Average]
[info]   (min, avg, max) = (3154084416.000, 3156755382.400, 3160329016.000), stdev = 2428971.711
[info]   CI (99.9%): [3147402277.229, 3166108487.571] (assumes normal distribution)
[info] Secondary result "xsbt.HotScalacBenchmark.action:gc.count":
[info]   90.000 ±(99.9%) 0.001 counts [Sum]
[info]   (min, avg, max) = (17.000, 18.000, 22.000), stdev = 2.236
[info]   CI (99.9%): [90.000, 90.000] (assumes normal distribution)
[info] Secondary result "xsbt.HotScalacBenchmark.action:gc.time":
[info]   7154.000 ±(99.9%) 0.001 ms [Sum]
[info]   (min, avg, max) = (1346.000, 1430.800, 1511.000), stdev = 64.325
[info]   CI (99.9%): [7154.000, 7154.000] (assumes normal distribution)

With optimization:

[info] Result "xsbt.HotScalacBenchmark.action":
[info]   N = 5
[info]   mean =  18656.264 ±(99.9%) 612.879 ms/op
[info]   Histogram, ms/op:
[info]     [18500.000, 18550.000) = 1 
[info]     [18550.000, 18600.000) = 1 
[info]     [18600.000, 18650.000) = 1 
[info]     [18650.000, 18700.000) = 1 
[info]     [18700.000, 18750.000) = 0 
[info]     [18750.000, 18800.000) = 0 
[info]     [18800.000, 18850.000) = 0 
[info]     [18850.000, 18900.000) = 0 
[info]     [18900.000, 18950.000) = 1 
[info]   Percentiles, ms/op:
[info]       p(0.0000) =  18522.046 ms/op
[info]      p(50.0000) =  18622.710 ms/op
[info]      p(90.0000) =  18924.700 ms/op
[info]      p(95.0000) =  18924.700 ms/op
[info]      p(99.0000) =  18924.700 ms/op
[info]      p(99.9000) =  18924.700 ms/op
[info]      p(99.9900) =  18924.700 ms/op
[info]      p(99.9990) =  18924.700 ms/op
[info]      p(99.9999) =  18924.700 ms/op
[info]     p(100.0000) =  18924.700 ms/op
[info] Secondary result "xsbt.HotScalacBenchmark.action:gc.alloc.rate":
[info]   160.312 ±(99.9%) 5.542 MB/sec [Average]
[info]   (min, avg, max) = (158.092, 160.312, 161.700), stdev = 1.439
[info]   CI (99.9%): [154.770, 165.854] (assumes normal distribution)
[info] Secondary result "xsbt.HotScalacBenchmark.action:gc.alloc.rate.norm":
[info]   3142377318.400 ±(99.9%) 4212317.767 B/op [Average]
[info]   (min, avg, max) = (3140712616.000, 3142377318.400, 3143361136.000), stdev = 1093925.547
[info]   CI (99.9%): [3138165000.633, 3146589636.167] (assumes normal distribution)
[info] Secondary result "xsbt.HotScalacBenchmark.action:gc.count":
[info]   104.000 ±(99.9%) 0.001 counts [Sum]
[info]   (min, avg, max) = (20.000, 20.800, 22.000), stdev = 1.095
[info]   CI (99.9%): [104.000, 104.000] (assumes normal distribution)
[info] Secondary result "xsbt.HotScalacBenchmark.action:gc.time":
[info]   6546.000 ±(99.9%) 0.001 ms [Sum]
[info]   (min, avg, max) = (1258.000, 1309.200, 1333.000), stdev = 31.815
[info]   CI (99.9%): [6546.000, 6546.000] (assumes normal distribution)

So the numbers do seem to be smaller. However I don't know if the CI uses the same machine each time. If CI benchmark results is not truth-worthy enough, I can do testing locally on my laptop.

@Friendseeker
Copy link
Member Author

Friendseeker commented Nov 6, 2023

I had checked CI results for xsbt.HotScalacBenchmark.action across different recent PRs

1270: 23870.623 ±      897.960   ms/op

1272: 15522.280 ±      290.355   ms/op

1274: 22776.748 ±      824.291   ms/op

1274: 20984.942 ±     1091.008   ms/op

So... Cross comparison between different CI runs is meaningless. I shall run benchmarks locally instead to gather data.

@Friendseeker
Copy link
Member Author

Friendseeker commented Nov 7, 2023

Here's the benchmark result:

With the optimization:


[info] HotScalacBenchmark.action                         /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample   10        6817.422 ±      112.969   ms/op
[info] HotScalacBenchmark.action:gc.alloc.rate           /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample    5         440.283 ±       22.578  MB/sec
[info] HotScalacBenchmark.action:gc.alloc.rate.norm      /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample    5  3173548741.600 ± 12227671.111    B/op
[info] HotScalacBenchmark.action:gc.count                /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample    5         214.000                 counts
[info] HotScalacBenchmark.action:gc.time                 /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample    5        3105.000                     ms
[info] HotScalacBenchmark.action:p0.00                   /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample             6744.441                  ms/op
[info] HotScalacBenchmark.action:p0.50                   /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample             6794.772                  ms/op
[info] HotScalacBenchmark.action:p0.90                   /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample             6944.929                  ms/op
[info] HotScalacBenchmark.action:p0.95                   /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample             6945.767                  ms/op
[info] HotScalacBenchmark.action:p0.99                   /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample             6945.767                  ms/op
[info] HotScalacBenchmark.action:p0.999                  /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample             6945.767                  ms/op
[info] HotScalacBenchmark.action:p0.9999                 /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample             6945.767                  ms/op
[info] HotScalacBenchmark.action:p1.00                   /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample             6945.767                  ms/op
[info] HotShapelessBenchmark.action                      /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample   18        3321.423 ±       27.155   ms/op
[info] HotShapelessBenchmark.action:gc.alloc.rate        /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample    5         463.219 ±       20.049  MB/sec
[info] HotShapelessBenchmark.action:gc.alloc.rate.norm   /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample    5  1622412368.400 ±  5928171.244    B/op
[info] HotShapelessBenchmark.action:gc.count             /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample    5         213.000                 counts
[info] HotShapelessBenchmark.action:gc.time              /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample    5        3202.000                     ms
[info] HotShapelessBenchmark.action:p0.00                /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample             3271.557                  ms/op
[info] HotShapelessBenchmark.action:p0.50                /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample             3317.694                  ms/op
[info] HotShapelessBenchmark.action:p0.90                /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample             3364.671                  ms/op
[info] HotShapelessBenchmark.action:p0.95                /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample             3372.220                  ms/op
[info] HotShapelessBenchmark.action:p0.99                /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample             3372.220                  ms/op
[info] HotShapelessBenchmark.action:p0.999               /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample             3372.220                  ms/op
[info] HotShapelessBenchmark.action:p0.9999              /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample             3372.220                  ms/op
[info] HotShapelessBenchmark.action:p1.00                /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true  sample             3372.220                  ms/op
[info] ColdScalacBenchmark.action                        /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true      ss    5       22372.120 ±      649.988   ms/op
[info] ColdScalacBenchmark.action:gc.alloc.rate          /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true      ss    5         150.684 ±        3.944  MB/sec
[info] ColdScalacBenchmark.action:gc.alloc.rate.norm     /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true      ss    5  3625515476.800 ± 16153258.595    B/op
[info] ColdScalacBenchmark.action:gc.count               /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true      ss    5         296.000                 counts
[info] ColdScalacBenchmark.action:gc.time                /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true      ss    5        2373.000                     ms
[info] ColdShapelessBenchmark.action                     /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true      ss    5       16251.642 ±      673.525   ms/op
[info] ColdShapelessBenchmark.action:gc.alloc.rate       /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true      ss    5         114.146 ±        4.107  MB/sec
[info] ColdShapelessBenchmark.action:gc.alloc.rate.norm  /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true      ss    5  2003152908.800 ± 13875755.814    B/op
[info] ColdShapelessBenchmark.action:gc.count            /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true      ss    5         190.000                 counts
[info] ColdShapelessBenchmark.action:gc.time             /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_3a4aced9           true      ss    5        1626.000                     ms
[success] Total time: 586 s (09:46), completed Nov 6, 2023, 10:31:46 p.m.

Without optimization:


[info] HotScalacBenchmark.action                         /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample   10        6767.929 ±       69.926   ms/op
[info] HotScalacBenchmark.action:gc.alloc.rate           /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample    5         442.517 ±       16.960  MB/sec
[info] HotScalacBenchmark.action:gc.alloc.rate.norm      /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample    5  3158922152.800 ±  7168994.553    B/op
[info] HotScalacBenchmark.action:gc.count                /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample    5         208.000                 counts
[info] HotScalacBenchmark.action:gc.time                 /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample    5        2993.000                     ms
[info] HotScalacBenchmark.action:p0.00                   /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample             6710.886                  ms/op
[info] HotScalacBenchmark.action:p0.50                   /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample             6773.801                  ms/op
[info] HotScalacBenchmark.action:p0.90                   /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample             6835.038                  ms/op
[info] HotScalacBenchmark.action:p0.95                   /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample             6836.716                  ms/op
[info] HotScalacBenchmark.action:p0.99                   /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample             6836.716                  ms/op
[info] HotScalacBenchmark.action:p0.999                  /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample             6836.716                  ms/op
[info] HotScalacBenchmark.action:p0.9999                 /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample             6836.716                  ms/op
[info] HotScalacBenchmark.action:p1.00                   /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample             6836.716                  ms/op
[info] HotShapelessBenchmark.action                      /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample   18        3321.889 ±       52.968   ms/op
[info] HotShapelessBenchmark.action:gc.alloc.rate        /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample    5         460.968 ±       26.362  MB/sec
[info] HotShapelessBenchmark.action:gc.alloc.rate.norm   /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample    5  1616603032.400 ±  4094565.358    B/op
[info] HotShapelessBenchmark.action:gc.count             /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample    5         208.000                 counts
[info] HotShapelessBenchmark.action:gc.time              /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample    5        3362.000                     ms
[info] HotShapelessBenchmark.action:p0.00                /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample             3250.586                  ms/op
[info] HotShapelessBenchmark.action:p0.50                /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample             3309.306                  ms/op
[info] HotShapelessBenchmark.action:p0.90                /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample             3428.005                  ms/op
[info] HotShapelessBenchmark.action:p0.95                /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample             3439.329                  ms/op
[info] HotShapelessBenchmark.action:p0.99                /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample             3439.329                  ms/op
[info] HotShapelessBenchmark.action:p0.999               /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample             3439.329                  ms/op
[info] HotShapelessBenchmark.action:p0.9999              /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample             3439.329                  ms/op
[info] HotShapelessBenchmark.action:p1.00                /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true  sample             3439.329                  ms/op
[info] ColdScalacBenchmark.action                        /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true      ss    5       22429.638 ±      687.585   ms/op
[info] ColdScalacBenchmark.action:gc.alloc.rate          /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true      ss    5         150.384 ±        3.941  MB/sec
[info] ColdScalacBenchmark.action:gc.alloc.rate.norm     /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true      ss    5  3627138744.000 ± 31303175.452    B/op
[info] ColdScalacBenchmark.action:gc.count               /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true      ss    5         282.000                 counts
[info] ColdScalacBenchmark.action:gc.time                /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true      ss    5        2336.000                     ms
[info] ColdShapelessBenchmark.action                     /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true      ss    5       16221.570 ±      512.319   ms/op
[info] ColdShapelessBenchmark.action:gc.alloc.rate       /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true      ss    5         114.326 ±        1.850  MB/sec
[info] ColdShapelessBenchmark.action:gc.alloc.rate.norm  /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true      ss    5  2001709224.000 ± 16016911.514    B/op
[info] ColdShapelessBenchmark.action:gc.count            /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true      ss    5         194.000                 counts
[info] ColdShapelessBenchmark.action:gc.time             /var/folders/fm/f93y40ld5ql0h43m_7p6kkqh0000gn/T/sbt_89158142           true      ss    5        1616.000                     ms
[success] Total time: 585 s (09:45), completed Nov 6, 2023, 10:44:17 p.m.

The changes are within the error margin, so it seems this was a case of premature optimization. I suggest we discard this change to avoid unnecessary complexity in the codebase.

@eed3si9n
Copy link
Member

eed3si9n commented Nov 7, 2023

It's possible that the change still works but it requires significantly larger classpath than what you tested.

@Friendseeker
Copy link
Member Author

Friendseeker commented Nov 7, 2023

It's possible that the change still works but it requires significantly larger classpath than what you tested.

You are right, it is too early to say that the optimization is pre-mature (albeit I should have done more due diligence before opening the PR).

I just posted a comment under #593 requesting for extra detail. Hopefully we can get & replicate the exact setup retronym used when they raised the issue. Once there's evidence suggesting the optimization is worthwhile, we can revisit the PR.

@Friendseeker
Copy link
Member Author

Friendseeker commented Oct 10, 2024

Need to revisit this PR.

When I did this PR, I noticed no improvement as this PR did not actually address the real hotspot.

lazy val analyses: Vector[Analysis] = {
classpath flatMap { entry =>
compileConfiguration.perClasspathEntryLookup.analysis(entry).toOption.map {
case a: Analysis => a
}
}
}

I didn't really understand #593 (comment) back then but now it makes a lot more sense. If build tool pass in a naive implementation of perClasspathEntryLookup this can easily be performance bottleneck as deserialization of large analysis can take >100ms.

Need to look at which perClasspathEntryLookup are build tools using. If some of them use a naive one, then we need this optimization at Zinc side to wrap their perClasspathEntryLookup with something like CachedPerClasspathEntryLookup


Update: All of sbt, bloop, mill use a map based implementation for perClasspathEntryLookup, so perClasspathEntryLookup.analysis takes O(1) time. Although when classPath is long, even O(1) time adds up. Furthermore it is a vector instead of a set.

I wonder if we can add a allAnalysis method to perClasspathEntryLookup. At least for Bloop and Mill they are just building the underlying map from list of upstream analysis, which is exactly the desired analyses. The properly way to address the problem is to keep the construction of analyses fast and keep the size of analyses small.

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.

LookupImpl.lookupAnalysis is O(N) wrt classpath length
2 participants