@@ -62,7 +62,43 @@ abstract class ForkJoinParallelCpgPass[T <: AnyRef](cpg: Cpg, @nowarn outName: S
62
62
// Override this to disable parallelism of passes. Useful for debugging.
63
63
def isParallel : Boolean = true
64
64
65
- override def createAndApply (): Unit = createApplySerializeAndStore(null )
65
+ override def createAndApply (): Unit = {
66
+ baseLogger.info(s " Start of pass: $name" )
67
+ val nanosStart = System .nanoTime()
68
+ var nParts = 0
69
+ var nanosBuilt = - 1L
70
+ var nDiff = - 1
71
+ var nDiffT = - 1
72
+ try {
73
+ val diffGraph = Cpg .newDiffGraphBuilder
74
+ nParts = runWithBuilder(diffGraph)
75
+ nanosBuilt = System .nanoTime()
76
+ nDiff = diffGraph.size
77
+
78
+ // TODO how about `nDiffT` which seems to count the number of modifications..
79
+ // nDiffT = overflowdb.BatchedUpdate
80
+ // .applyDiff(cpg.graph, diffGraph, null)
81
+ // .transitiveModifications()
82
+
83
+ flatgraph.DiffGraphApplier .applyDiff(cpg.graph, diffGraph)
84
+ } catch {
85
+ case exc : Exception =>
86
+ baseLogger.error(s " Pass ${name} failed " , exc)
87
+ throw exc
88
+ } finally {
89
+ try {
90
+ finish()
91
+ } finally {
92
+ // the nested finally is somewhat ugly -- but we promised to clean up with finish(), we want to include finish()
93
+ // in the reported timings, and we must have our final log message if finish() throws
94
+ val nanosStop = System .nanoTime()
95
+ val fracRun = if (nanosBuilt == - 1 ) 0.0 else (nanosStop - nanosBuilt) * 100.0 / (nanosStop - nanosStart + 1 )
96
+ baseLogger.info(
97
+ f " Pass $name completed in ${(nanosStop - nanosStart) * 1e-6 }%.0f ms ( ${fracRun}%.0f%% on mutations). ${nDiff}%d + ${nDiffT - nDiff}%d changes committed from ${nParts}%d parts. "
98
+ )
99
+ }
100
+ }
101
+ }
66
102
67
103
override def runWithBuilder (externalBuilder : DiffGraphBuilder ): Int = {
68
104
try {
@@ -105,45 +141,9 @@ abstract class ForkJoinParallelCpgPass[T <: AnyRef](cpg: Cpg, @nowarn outName: S
105
141
}
106
142
}
107
143
144
+ @ deprecated(" Please use createAndApply" )
108
145
override def createApplySerializeAndStore (serializedCpg : SerializedCpg , prefix : String = " " ): Unit = {
109
- baseLogger.info(s " Start of pass: $name" )
110
- val nanosStart = System .nanoTime()
111
- var nParts = 0
112
- var nanosBuilt = - 1L
113
- var nDiff = - 1
114
- var nDiffT = - 1
115
- try {
116
- val diffGraph = Cpg .newDiffGraphBuilder
117
- nParts = runWithBuilder(diffGraph)
118
- nanosBuilt = System .nanoTime()
119
- nDiff = diffGraph.size
120
-
121
- // TODO how about `nDiffT` which seems to count the number of modifications..
122
- // nDiffT = overflowdb.BatchedUpdate
123
- // .applyDiff(cpg.graph, diffGraph, null)
124
- // .transitiveModifications()
125
-
126
- flatgraph.DiffGraphApplier .applyDiff(cpg.graph, diffGraph)
127
- } catch {
128
- case exc : Exception =>
129
- baseLogger.error(s " Pass ${name} failed " , exc)
130
- throw exc
131
- } finally {
132
- try {
133
- finish()
134
- } finally {
135
- // the nested finally is somewhat ugly -- but we promised to clean up with finish(), we want to include finish()
136
- // in the reported timings, and we must have our final log message if finish() throws
137
- val nanosStop = System .nanoTime()
138
- val fracRun = if (nanosBuilt == - 1 ) 0.0 else (nanosStop - nanosBuilt) * 100.0 / (nanosStop - nanosStart + 1 )
139
- val serializationString = if (serializedCpg != null && ! serializedCpg.isEmpty) {
140
- " Diff serialized and stored."
141
- } else " "
142
- baseLogger.info(
143
- f " Pass $name completed in ${(nanosStop - nanosStart) * 1e-6 }%.0f ms ( ${fracRun}%.0f%% on mutations). ${nDiff}%d + ${nDiffT - nDiff}%d changes committed from ${nParts}%d parts. ${serializationString}%s "
144
- )
145
- }
146
- }
146
+ createAndApply()
147
147
}
148
148
149
149
}
@@ -154,6 +154,7 @@ trait CpgPassBase {
154
154
155
155
def createAndApply (): Unit
156
156
157
+ @ deprecated(" Please use createAndApply" )
157
158
def createApplySerializeAndStore (serializedCpg : SerializedCpg , prefix : String = " " ): Unit
158
159
159
160
/** Name of the pass. By default it is inferred from the name of the class, override if needed.
@@ -196,11 +197,8 @@ trait CpgPassBase {
196
197
prefix + " _" + outputName + " _" + index
197
198
}
198
199
199
- protected def store (overlay : GeneratedMessageV3 , name : String , serializedCpg : SerializedCpg ): Unit = {
200
- if (overlay.getSerializedSize > 0 ) {
201
- serializedCpg.addOverlay(overlay, name)
202
- }
203
- }
200
+ @ deprecated
201
+ protected def store (overlay : GeneratedMessageV3 , name : String , serializedCpg : SerializedCpg ): Unit = {}
204
202
205
203
protected def withStartEndTimesLogged [A ](fun : => A ): A = {
206
204
baseLogger.info(s " Running pass: $name" )
0 commit comments