Skip to content

Commit 04fd9ae

Browse files
timarmstrongImpala Public Jenkins
authored andcommitted
IMPALA-9373: Trial run of include-what-you-use
Implemented recommendations from IWYU in a subset of files, mostly in util. Did a few cleanups related to systematic problems that I noticed as a result. I noticed that uid-util.h was pulling in boost UUID headers to a lot of compilation units, so refactored that a little bit, including pulling out the hash functions into unique-id-hash.h and moving some inline functions into client-request-state-map.cc. Systematically replaced the general boost mutex header with the internal pthread-based one. This is equivalent for us, since we assume that boost::mutex is implemented by pthread_mutex_t, e.g. for the implementation of ConditionVariable. Switch include guards to pragma once just as general cleanup. Prefix string with std:: consistently in headers so that they don't depend on "using" declarations pulled in from random headers. Look at includes of C++ stream headers, including iostream and stringstream, and replaced them with iosfwd or removed them if possible. Compile time: Measured a full ASAN build of the impalad binary on an 8 core machine with cccache enabled, but cleared. It used very slightly less CPU, probably because we are still pulling in most of the same system headers. Before: real 9m27.502s user 64m39.775s sys 2m49.002s After: real 9m26.561s user 64m28.948s sys 2m48.252s So for the moment, the only significant wins are on incremental builds, where touching header files should not require as many recompilations. Compile times should start to drop meaningfully once we thin out more unnecessary includes - currently it seems like most compile units end up with large chunks of boost/std code included via transitive header dependencies. Change-Id: I3450e0ffcb8b183e18ac59c8b33b9ecbd3f60e20 Reviewed-on: http://gerrit.cloudera.org:8080/15202 Reviewed-by: Joe McDonnell <joemcdonnell@cloudera.com> Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
1 parent f216e68 commit 04fd9ae

File tree

169 files changed

+697
-729
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+697
-729
lines changed

be/src/benchmarks/lock-benchmark.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
#include <stdlib.h>
1918
#include <stdio.h>
19+
#include <stdlib.h>
2020
#include <iostream>
21-
#include <vector>
2221
#include <sstream>
22+
#include <vector>
2323
#include <boost/thread.hpp>
24-
#include <boost/thread/mutex.hpp>
24+
#include <boost/thread/pthread/mutex.hpp>
2525
#include "util/benchmark.h"
2626
#include "util/cpu-info.h"
2727
#include "util/spinlock.h"

be/src/benchmarks/process-wide-locks-benchmark.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "util/stopwatch.h"
3939
#include "util/thread.h"
4040
#include "util/uid-util.h"
41+
#include "util/unique-id-hash.h"
4142

4243
#include "common/init.h"
4344
#include "common/names.h"

be/src/catalog/catalog-server.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
#ifndef IMPALA_CATALOG_CATALOG_SERVER_H
19-
#define IMPALA_CATALOG_CATALOG_SERVER_H
18+
#pragma once
2019

2120
#include <string>
2221
#include <vector>
2322
#include <boost/shared_ptr.hpp>
24-
#include <boost/thread/mutex.hpp>
23+
#include <boost/thread/pthread/mutex.hpp>
2524
#include <boost/unordered_set.hpp>
2625

2726
#include "gen-cpp/CatalogService.h"
@@ -236,5 +235,3 @@ class CatalogServer {
236235
};
237236

238237
}
239-
240-
#endif

be/src/codegen/llvm-codegen.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <unordered_set>
2424

2525
#include <boost/algorithm/string.hpp>
26-
#include <boost/thread/mutex.hpp>
26+
#include <boost/thread/pthread/mutex.hpp>
2727
#include <gutil/strings/substitute.h>
2828

2929
#include <llvm/ADT/Triple.h>

be/src/common/logging.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@
1717

1818
#include "common/logging.h"
1919

20-
#include <boost/thread/locks.hpp>
21-
#include <boost/thread/mutex.hpp>
22-
#include <boost/uuid/uuid.hpp>
23-
#include <boost/uuid/uuid_generators.hpp>
24-
#include <boost/uuid/uuid_io.hpp>
20+
#include <stdio.h>
2521
#include <cerrno>
2622
#include <ctime>
2723
#include <fstream>
28-
#include <gutil/strings/substitute.h>
2924
#include <iostream>
3025
#include <map>
3126
#include <sstream>
32-
#include <stdio.h>
27+
#include <boost/thread/locks.hpp>
28+
#include <boost/thread/pthread/mutex.hpp>
29+
#include <boost/uuid/uuid.hpp>
30+
#include <boost/uuid/uuid_generators.hpp>
31+
#include <boost/uuid/uuid_io.hpp>
32+
#include <gutil/strings/substitute.h>
3333

3434
#include "common/logging.h"
3535
#include "service/impala-server.h"

be/src/common/names.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ using boost::thread;
136136
using boost::thread_group;
137137
#endif
138138

139-
#ifdef BOOST_THREAD_MUTEX_HPP
139+
#ifdef BOOST_THREAD_PTHREAD_MUTEX_HPP
140140
using boost::mutex;
141141
using boost::timed_mutex;
142142
using boost::try_mutex;

be/src/common/object-pool.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
19-
#ifndef IMPALA_COMMON_OBJECT_POOL_H
20-
#define IMPALA_COMMON_OBJECT_POOL_H
18+
#pragma once
2119

2220
#include <vector>
2321
#include <boost/thread/locks.hpp>
24-
#include <boost/thread/mutex.hpp>
22+
#include <boost/thread/pthread/mutex.hpp>
2523

2624
#include "gutil/macros.h"
2725
#include "util/spinlock.h"
@@ -67,5 +65,3 @@ class ObjectPool {
6765
};
6866

6967
}
70-
71-
#endif

be/src/exec/blocking-plan-root-sink.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "util/pretty-printer.h"
2525

2626
#include <memory>
27-
#include <boost/thread/mutex.hpp>
27+
#include <boost/thread/pthread/mutex.hpp>
2828

2929
using namespace std;
3030
using boost::unique_lock;

be/src/exec/data-sink.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ class DataSink {
9898
/// If this is the sink at the root of a fragment, 'sink_id' must be a unique ID for
9999
/// the sink for use in runtime profiles and other purposes. Otherwise this is a join
100100
/// build sink owned by an ExecNode and 'sink_id' must be -1.
101-
DataSink(TDataSinkId sink_id, const DataSinkConfig& sink_config, const string& name,
102-
RuntimeState* state);
101+
DataSink(TDataSinkId sink_id, const DataSinkConfig& sink_config,
102+
const std::string& name, RuntimeState* state);
103103
virtual ~DataSink();
104104

105105
/// Setup. Call before Send(), Open(), or Close() during the prepare phase of the query
@@ -151,7 +151,7 @@ class DataSink {
151151
const RowDescriptor* row_desc_;
152152

153153
/// The name to be used in profiles etc. Passed by derived classes in the ctor.
154-
const string name_;
154+
const std::string name_;
155155

156156
/// The runtime profile for this DataSink. Initialized in ctor. Not owned.
157157
RuntimeProfile* profile_ = nullptr;

be/src/exec/exec-node.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#include "runtime/runtime-state.h"
6666
#include "util/debug-util.h"
6767
#include "util/runtime-profile-counters.h"
68+
#include "util/uid-util.h"
6869

6970
#include "common/names.h"
7071

0 commit comments

Comments
 (0)