RFC: [x2cpg] Added ForkJoinParallelCpgPassWithAccumulator#5877
RFC: [x2cpg] Added ForkJoinParallelCpgPassWithAccumulator#5877max-leuthaeuser wants to merge 1 commit intomasterfrom
Conversation
This allows to get rid of Global typesSeen contention. I adapted jssrc2cpg to demo this. @bbrehm This also revealed a double call of finish() both in ForkJoinParallelCpgPass.createAndApply() and ForkJoinParallelCpgPass.runWithBuilder()
|
Waiting for ShiftLeftSecurity/codepropertygraph#1841, then I can remove the "finish() only once" hack here. |
ml86
left a comment
There was a problem hiding this comment.
Use of a thread local variable seems sub-optimal. Why not have runOnPart return a type X and accumulate this along side the diff graph in the stream.collect consumer function?
|
Because runOnPart runs on a single part of work (i.e., in our case a single, parsed file). |
|
It seems to depend on the accumulator use case. If one would end up writing lots of duplicate data in the accumulator like for our seen types than I would also expect the thread local implementation to be better. |
|
Waiting for ShiftLeftSecurity/codepropertygraph#1844 to adapt this PR here. |
|
I think the appropriate way would be for CpgPasses to be able to bring their own subclass of DiffGraphBuilder. That can then carry the hashset along. This is exacly what the stream collector interface is made for, so we should use that. |
|
But that would be per part again right? Anyway, feel free to open a PR in codepropertygraph. I guess the pass API will change too. |
|
Will do a new PR for jssrc2pg using ForkJoinParallelCpgPassWithAccumulator from ShiftLeftSecurity/codepropertygraph#1847 once that release is available. |
This allows to get rid of Global typesSeen contention. I adapted jssrc2cpg to demo this.
If thats something we want, this can go into https://github.com/ShiftLeftSecurity/codepropertygraph/blob/master/codepropertygraph/src/main/scala/io/shiftleft/passes/CpgPass.scala
@bbrehm This also revealed a double call of finish() both in ForkJoinParallelCpgPass.createAndApply() and ForkJoinParallelCpgPass.runWithBuilder()