vanzin commented on a change in pull request #26416: [SPARK-29779][CORE] Compact old event log files and cleanup URL: https://github.com/apache/spark/pull/26416#discussion_r355803883
########## File path: core/src/main/scala/org/apache/spark/deploy/history/EventLogFilterRateCalculator.scala ########## @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.deploy.history + +import org.apache.hadoop.fs.{FileSystem, Path} + +import org.apache.spark.scheduler.SparkListenerEvent + +/** + * This class calculates the rate of events being accepted, via two phases reading: + * + * 1) Initialize available [[EventFilterBuilder]] instances, and replay the event log files with + * builders, so that these builders can gather the information to create [[EventFilter]] instances. + * 2) Initialize [[EventFilter]] instances from [[EventFilterBuilder]] instances, and replay the + * event log files with filters. Counts the number of events vs accepted events and calculate + * the rate. + */ +class EventLogFilterRateCalculator(fs: FileSystem) { + def calculate(eventLogPaths: Seq[Path]): Double = { + val builders = EventFilterBuilder.initializeBuilders(fs, eventLogPaths) Review comment: I was looking at how this class is used later; if I followed correctly, it's called every time there is a new log file, to see if the files can be compacted. Compaction, though, only happens when trying to rebuild the app's UI. I'm not sure I see the benefit of that. For starters, this method is as expensive as compacting the files, since you're replaying all the log files twice too. Then, you're gating compaction on whether someone wants to look an an app's UI. So if nobody ever does, then no compaction ever happens. It would be good to attempt something smarter here; maybe the listeners can get some idea of how much data would be filtered out in the first scan, so that if you don't detect a lot of stuff you avoid the second scan altogether; and if you do the second scan, might as well just write the compacted data, without waiting for a trigger later. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
