Windows.h should be included less |
|||
Issue description
Windows.h is included from base\time\time.h, base\synchronization\lock_impl.h, and probably a few other commonly used header files. This means that we pay the cost of compiling Windows.h for many (most?) translation units in Chrome. This slows down builds and pollutes the global namespace with problematic macros.
Only a *tiny* portion of the types from Windows.h are needed so this overhead and pollution are giving very few benefits.
In time.h the definitions of LONGLONG, DWORD, and FILETIME are used. LONGLONG and DWORD are easily avoided. FILETIME is harder to avoid but is only used by two rarely used functions:
static Time FromFileTime(FILETIME ft);
FILETIME ToFileTime() const;
In lock_impl.h the definition of SRWLOCK and the prototype for ReleaseSRWLockExclusive are used and the dependency on Windows.h is easily avoided.
If there are places that must include Windows.h then the cost of Windows.h (but not the worst of the macro pollution) can be avoided with these defines:
#define WIN32_LEAN_AND_MEAN
#define VC_EXTRALEAN
It should be easy to analyze .ninja_deps to find the most important places where Windows.h is included and also use that to measure some of the removal benefits.
,
Dec 21 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/608f59c4bfc2d161fe74e30803642d97e5d4eed8 commit 608f59c4bfc2d161fe74e30803642d97e5d4eed8 Author: Bruce Dawson <brucedawson@chromium.org> Date: Thu Dec 21 20:14:48 2017 Avoid using PostMessage to avoid Windows SDK conflicts The Windows SDK insists on defining PostMessage to PostMessageW. Working with this requires a delicate and fragile dance that was recently broken on jumbo builds with some settings (prior to April 2017, crrev.com/c/472192, we avoided this issue by using the name postMessage). While the long-term fix is to reduce how frequently we include Windows.h the pragmatic short-term fix is to rename the virtual functions. Bug: 746953, 796644 Change-Id: I9c8a46d34fa19b35ca065cc27cae0b40b936510a Reviewed-on: https://chromium-review.googlesource.com/837655 Commit-Queue: Bruce Dawson <brucedawson@chromium.org> Reviewed-by: Jochen Eisinger <jochen@chromium.org> Reviewed-by: Marijn Kruisselbrink <mek@chromium.org> Cr-Commit-Position: refs/heads/master@{#525782} [modify] https://crrev.com/608f59c4bfc2d161fe74e30803642d97e5d4eed8/content/renderer/service_worker/web_service_worker_impl.cc [modify] https://crrev.com/608f59c4bfc2d161fe74e30803642d97e5d4eed8/content/renderer/service_worker/web_service_worker_impl.h [modify] https://crrev.com/608f59c4bfc2d161fe74e30803642d97e5d4eed8/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc [modify] https://crrev.com/608f59c4bfc2d161fe74e30803642d97e5d4eed8/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.h [modify] https://crrev.com/608f59c4bfc2d161fe74e30803642d97e5d4eed8/third_party/WebKit/Source/core/exported/WebPagePopupImpl.cpp [modify] https://crrev.com/608f59c4bfc2d161fe74e30803642d97e5d4eed8/third_party/WebKit/Source/core/exported/WebPagePopupImpl.h [modify] https://crrev.com/608f59c4bfc2d161fe74e30803642d97e5d4eed8/third_party/WebKit/Source/core/html/forms/InternalPopupMenu.cpp [modify] https://crrev.com/608f59c4bfc2d161fe74e30803642d97e5d4eed8/third_party/WebKit/Source/core/page/PagePopup.h [modify] https://crrev.com/608f59c4bfc2d161fe74e30803642d97e5d4eed8/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp [modify] https://crrev.com/608f59c4bfc2d161fe74e30803642d97e5d4eed8/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorker.h
,
Dec 21 2017
I hacked on this enough to confirm that it won't easily be solved. I still think it is solvable and worthwhile, but not today. Here is a partial list of popular header files that #include Windows.h:
diff --git a/base/atomicops_internals_x86_msvc.h b/base/atomicops_internals_x86_msvc.h
-#include <windows.h>
diff --git a/base/files/platform_file.h b/base/files/platform_file.h
-#include <windows.h>
diff --git a/base/memory/shared_memory_handle.h b/base/memory/shared_memory_handle.h
-#include <windows.h>
diff --git a/base/message_loop/message_pump_win.h b/base/message_loop/message_pump_win.h
-#include <windows.h>
diff --git a/base/process/process_handle.h b/base/process/process_handle.h
-#include <windows.h>
diff --git a/base/synchronization/condition_variable.h b/base/synchronization/condition_variable.h
-#include <windows.h>
diff --git a/base/threading/platform_thread.h b/base/threading/platform_thread.h
-#include <windows.h>
diff --git a/base/threading/thread_local_storage.h b/base/threading/thread_local_storage.h
-#include <windows.h>
diff --git a/base/time/time.h b/base/time/time.h
-#include <windows.h>
diff --git a/base/win/message_window.h b/base/win/message_window.h
-#include <windows.h>
diff --git a/base/win/scoped_handle.h b/base/win/scoped_handle.h
-#include <windows.h>
diff --git a/chrome/utility/image_writer/image_writer.h b/chrome/utility/image_writer/image_writer.h
-#include <windows.h>
diff --git a/content/browser/accessibility/browser_accessibility_state_impl_win.cc b/content/browser/accessibility/browser_accessibility_state_impl_win.cc
-#include <windows.h>
diff --git a/ipc/ipc_sync_message.h b/ipc/ipc_sync_message.h
-#include <windows.h>
These can all be avoided, by adding typedefs in most cases, more drastic measures in other cases. References to HWND in header files are particularly annoying, but in some cases #include <Windows.h> can be replaced by:
typedef void* HANDLE;
A partial fix tends to cause problems where names like PostMessage are defined when a call is made but not when a class is declared, leading to compile errors - it's like pulling on a sweater thread with no clear end.
Another result of investigating this is the non-trivial number of .cc files that need Windows.h but don't include it, or include it too late. For instance, this is not legal:
#include <psapi.h>
#include <tchar.h>
#include <windows.h>
You have to include windows.h first:
#include <windows.h>
#include <psapi.h>
#include <tchar.h>
A partial list of .cc files that need an include of Windows.h added or moved is here:
diff --git a/base/files/file_enumerator_win.cc b/base/files/file_enumerator_win.cc
+#include <Windows.h>
diff --git a/base/files/file_util_win.cc b/base/files/file_util_win.cc
+#include <windows.h>
diff --git a/base/process/launch_win.cc b/base/process/launch_win.cc
+#include <windows.h>
diff --git a/base/process/process_metrics.cc b/base/process/process_metrics.cc
+#include <Windows.h>
diff --git a/base/synchronization/condition_variable_win.cc b/base/synchronization/condition_variable_win.cc
+#include <Windows.h>
diff --git a/base/syslog_logging.cc b/base/syslog_logging.cc
+#include <Windows.h>
diff --git a/base/threading/thread_local_storage.cc b/base/threading/thread_local_storage.cc
+#include <Windows.h>
diff --git a/base/time/time_win.cc b/base/time/time_win.cc
+#include <Windows.h>
diff --git a/chrome/browser/diagnostics/diagnostics_writer.cc b/chrome/browser/diagnostics/diagnostics_writer.cc
+#include <Windows.h>
diff --git a/chrome/browser/task_manager/sampling/shared_sampler_win.cc b/chrome/browser/task_manager/sampling/shared_sampler_win.cc
+#include <Windows.h>
diff --git a/chrome/utility/importer/edge_importer_win.cc b/chrome/utility/importer/edge_importer_win.cc
+#include <Windows.h>
diff --git a/chrome/utility/importer/ie_importer_win.cc b/chrome/utility/importer/ie_importer_win.cc
+#include <Windows.h>
diff --git a/components/browser_watcher/system_session_analyzer_win.cc b/components/browser_watcher/system_session_analyzer_win.cc
+#include <Windows.h>
diff --git a/components/metrics/metrics_log.cc b/components/metrics/metrics_log.cc
+#include <Windows.h> // Must be included before current_module.h?
diff --git a/components/startup_metric_utils/browser/startup_metric_utils.cc b/components/startup_metric_utils/browser/startup_metric_utils.cc
+#include <Windows.h>
diff --git a/components/wifi/wifi_service_win.cc b/components/wifi/wifi_service_win.cc
+#include <Windows.h>
diff --git a/content/browser/accessibility/browser_accessibility_state_impl_win.cc b/content/browser/accessibility/browser_accessibility_state_impl_win.cc
+#include <windows.h>
diff --git a/device/usb/usb_device_handle_win.cc b/device/usb/usb_device_handle_win.cc
+#include <Windows.h>
diff --git a/gin/array_buffer.cc b/gin/array_buffer.cc
+#include <Windows.h>
diff --git a/media/midi/midi_manager_winrt.cc b/media/midi/midi_manager_winrt.cc
+#include <Windows.h>
diff --git a/net/proxy/dhcpcsvc_init_win.cc b/net/proxy/dhcpcsvc_init_win.cc
+#include <Windows.h>
diff --git a/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics_win.cc b/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics_win.cc
+#include <windows.h>
diff --git a/ui/gfx/animation/animation_win.cc b/ui/gfx/animation/animation_win.cc
+#include <Windows.h>
See also bug 796644
,
Dec 29 2017
Windows.h is included in a lot of header files because of Windows types that are needed. These header files then get indirectly included by most .cc files. This can be minimized by having a header file that forward declares enough types to handle 90% of the needs for Windows.h. However! There are at least twenty function names used within Chromium that are also defined as macros by Windows.h. This includes CopyFile, PostMessage, StartService, and many others. In order to ensure that calls to these functions match the declarations it is necessary to either *always* have these macros defined or *never* have these macros defined. The ideal solution would be to have these macros undefined everywhere. Doing this requires wrapping every include of windows.h so that we can #undef these macros. There are about 800 includes of windows.h in the chromium repo, and more in third_party. There are also indirect includes of windows.h from objbase.h, aclapi.h, accctrl.h, rpc.h, wrl/client.h, unknwn.h and others. rpc.h is particularly annoying because it is #included in files generated by midl. There is also the minor annoyance that the ATL header files expect PostMessage to be defined, so another wrapper is needed for including this file. Additionally, once the problematic macros are undefined it is necessary to explicitly call the 'W' versions of all of the functions. After experimenting with this direction it became apparent that it was impractical. The number of files that would need to be touched in the chromium repo was well into the thousands, changes would also be needed in many third_party repos, and many of these changes were tightly coupled. So, the new plan is to give up on avoiding macro pollution and focus on avoiding includes of windows.h by using base/win/windows_types.h as much as possible, especially in commonly used header files such as base/time/time.h. Changes needed to make this work include: 1) Create base/win/windows_types.h and have it #define the macros that we rely on 2) Use base/win/windows_types.h instead of windows.h in as many places as possible. 3) Fix the many .cc files that require windows.h but don't include it. This includes files that, for instance, include commdlg.h or psapi.h or others without first including windows.h (this doesn't actually compile and only worked because windows.h was so pervasive). Testing with empty source files versus those that just #include <windows.h> shows about a 600 ms penalty for each include of windows.h (when building with clang). My current fix avoids ~5,000 includes of windows.h so that could save ~3,000 CPU s. On a 4-core machine that could be 750 s, on a 24-core machine it could be 125 s. Testing on a 20-core machine showed an average build-time savings of 130 s across three pairs of non-jumbo builds of chrome, representing a 2.5-3.0% improvement. There are probably another 8,000 includes of windows.h that could be avoided (a non-jumbo build of Chrome still has ~10,000 includes of windows.h), so another 4-5% improvement seems possible. crrev.com/c/846422 is the work in progress CL, still being cleaned up, currently 64-bit only.
,
Dec 30 2017
The number of includes reported by ninja.exe -t deps varies dramatically depending on whether goma or not goma is used - about 3,700 more are reported when using goma. This is due to Webkit's precompiled headers. Windows.h is included from third_party\WebKit\Source\build\win\Precompile.h and on non-goma builds this counts as one included of Windows.h. On goma builds this precompiled header is disabled so the Windows.h include is charged for every .obj file. Also note that, for unexplored ninja reasons. when building with DEPOT_TOOLS_WIN_TOOLCHAIN=0 there are no dependencies on Windows.h reported, making investigations more difficult.
,
Dec 31 2017
,
Jan 4 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/bfdc3fdc473922b0b99a0a0af37e8f8f97340173 commit bfdc3fdc473922b0b99a0a0af37e8f8f97340173 Author: Bruce Dawson <brucedawson@chromium.org> Date: Thu Jan 04 01:05:08 2018 Reduce includes of windows.h Windows.h is included in a number of key header files which means that a majority of the translation units when building Chrome include Windows.h. This is slowing down builds. This change creates a new header - base/win/windows_types.h - which contains typedefs and defines of common Windows.h types - and uses this in place of windows.h in enough places to reduce the number of translation units that include windows.h in a build of the 'chrome' target (debug component non-jumbo) by 5219, from 19041 to 13822, giving measurable build-time speedups (~2.5-3.0%). Follow-up changes will apply the same techniques to more headers and drop the number much further. Perversely enough, this change also adds includes of windows.h in many places - places that always needed windows.h but were implicitly depending on it being included elsewhere. TBR=jochen@chromium.org,wfh@chromium.org,rockot@chromium.org,mef@chromium.org,raymes@chromium.org,joedow@chromium.org,rogerta@chromium.org,jsbell@chromium.org,dpranke@chromium.org,sky@chromium.org TBRing mechanical changes, reviewers: jochen@ : Please review changes to chrome/, components/, content/, third_party/WebKit/Source/platform wfh@ : Please review changes to courgette/, sandbox/win rockot@ : Please review changes to device/, ipc/, services/ mef@ : Please review changes to net/ raymes@ : Please review changes to ppapi/ joedow@ : Please review changes to remoting/ rogerta@ : Please review changes to rlz/ jsbell@: Please review changes to storage/ dpranke@ : Please review changes to tools/gn/ sky@ : Please review changes to ui/ Bug: 796644,798763 Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel Change-Id: I3958d0d7d813bed74d9b166e0358dbde5b5729af Reviewed-on: https://chromium-review.googlesource.com/846422 Commit-Queue: Bruce Dawson <brucedawson@chromium.org> Reviewed-by: Misha Efimov <mef@chromium.org> Reviewed-by: Scott Violet <sky@chromium.org> Reviewed-by: John Abd-El-Malek <jam@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Cr-Commit-Position: refs/heads/master@{#526881} [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/BUILD.gn [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/allocator/allocator_shim_override_ucrt_symbols_win.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/allocator/partition_allocator/address_space_randomization.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/atomicops_internals_x86_msvc.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/files/file_path_watcher_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/files/file_util.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/files/file_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/files/memory_mapped_file_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/files/platform_file.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/memory/discardable_shared_memory.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/memory/shared_memory_handle.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/memory/shared_memory_handle_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/metrics/persistent_memory_allocator.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/process/memory_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/process/process_handle.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/process/process_metrics.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/process/process_metrics_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/process/process_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/synchronization/condition_variable.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/synchronization/condition_variable_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/synchronization/lock_impl.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/synchronization/lock_impl_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/synchronization/waitable_event_watcher_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/syslog_logging.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/test/test_reg_util_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/threading/platform_thread.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/threading/platform_thread_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/threading/thread_local_storage.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/time/time.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/time/time_unittest.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/trace_event/process_memory_dump.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/trace_event/process_memory_dump_unittest.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/trace_event/trace_event_etw_export_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/win/current_module.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/win/object_watcher.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/win/object_watcher.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/win/registry.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/win/scoped_handle.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/win/scoped_handle.h [add] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/win/win_includes_unittest.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/win/win_util.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/win/win_util.h [add] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/win/windows_full.h [add] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/base/win/windows_types.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/chrome/browser/conflicts/module_event_sink_impl_win_unittest.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/chrome/browser/diagnostics/diagnostics_writer.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/chrome/browser/extensions/extension_creator_filter_unittest.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/chrome/browser/platform_util_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/chrome/browser/safe_browsing/incident_reporting/binary_integrity_analyzer_win_unittest.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/chrome/browser/task_manager/sampling/task_group.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/chrome/browser/themes/theme_properties.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/chrome/browser/ui/webui/print_preview/pdf_printer_handler_win_unittest.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/chrome/browser/win/enumerate_modules_model.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/chrome/common/conflicts/module_watcher_win_unittest.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/chrome/common/multi_process_lock_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/chrome/installer/util/lzma_file_allocator.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/chrome/installer/util/lzma_file_allocator_unittest.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/components/browser_watcher/exit_code_watcher_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/components/metrics/clean_exit_beacon.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/components/metrics/metrics_log.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/components/metrics/ui/screen_info_metrics_provider.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/components/search_engines/template_url_prepopulate_data.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/components/startup_metric_utils/browser/startup_metric_utils.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/components/storage_monitor/storage_monitor_win.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/components/storage_monitor/volume_mount_watcher_win.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/components/update_client/updater_state_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/components/wifi/wifi_service_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/content/browser/accessibility/browser_accessibility_state_impl_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/content/renderer/pepper/event_conversion.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/content/renderer/pepper/pepper_plugin_instance_impl.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/courgette/memory_allocator.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/device/serial/serial_device_enumerator_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/device/usb/usb_device_handle_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/device/usb/usb_device_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/ipc/ipc_platform_file.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/ipc/ipc_sync_message.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/mojo/common/logfont_win.typemap [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/net/base/platform_mime_util_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/net/disk_cache/blockfile/mapped_file_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/net/disk_cache/blockfile/rankings.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/net/proxy/dhcpcsvc_init_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/ppapi/thunk/resource_creation_api.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/remoting/host/curtain_mode_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/remoting/host/heartbeat_sender.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/remoting/host/pairing_registry_delegate_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/remoting/host/win/unprivileged_process_delegate.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/rlz/win/lib/registry_util.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/sandbox/win/src/crosscall_server.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics_unittest.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/storage/browser/database/vfs_backend.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/third_party/WebKit/Source/platform/scheduler/util/thread_cpu_throttler.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/tools/gn/filesystem_utils.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/ui/base/cursor/cursor_loader_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/ui/base/win/foreground_helper.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/ui/compositor/test/test_compositor_host_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/ui/events/devices/input_device_observer_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/ui/gfx/animation/animation_unittest.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/ui/gfx/animation/animation_win.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/ui/gfx/native_widget_types.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/ui/gfx/platform_font_win.h [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/ui/platform_window/win/win_window.cc [modify] https://crrev.com/bfdc3fdc473922b0b99a0a0af37e8f8f97340173/ui/platform_window/win/win_window.h
,
Jan 4 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/c44d6679dc6284f2ba98772befe35fa5a82d2dfd commit c44d6679dc6284f2ba98772befe35fa5a82d2dfd Author: Bruce Dawson <brucedawson@chromium.org> Date: Thu Jan 04 21:40:44 2018 Move #include to the correct section CR fixes after crrev.com/c/846422 Bug: 796644 Change-Id: I3395664131d44ecf2108582b28d1cac52ae26b91 Reviewed-on: https://chromium-review.googlesource.com/849708 Reviewed-by: Scott Violet <sky@chromium.org> Commit-Queue: Bruce Dawson <brucedawson@chromium.org> Cr-Commit-Position: refs/heads/master@{#527101} [modify] https://crrev.com/c44d6679dc6284f2ba98772befe35fa5a82d2dfd/ui/gfx/native_widget_types.h
,
Jan 20 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/aa08ad82cc3843f8522feb409442ccd53151889e commit aa08ad82cc3843f8522feb409442ccd53151889e Author: Bruce Dawson <brucedawson@chromium.org> Date: Sat Jan 20 00:31:05 2018 Avoid varying behavior of header files When build optimizations collide... In order to avoid the non-trivial cost of including windows.h almost everywhere the windows_types.h file was added. This includes enough defines and types that many header files that previously required windows.h can use it instead. However there are a couple of .cc files - win_util.cc and process_metrics_win.cc - that need to include windows.h before including their associated header files so that they will get the full declarations of internal types. This sort of include ordering guarantee is incompatible with jumbo files. This change solves the problem in a more stable way by adding separate header files which include windows.h and then unilaterally declare the necessary Windows-dependent structs. These headers are then used when needed to gain access to IoCounters and NONCLIENTMETRICS_XP. This change also removes a redundant include of windows.h. Bug: 796644 Change-Id: I81e3f8f21a7ba917e20f0a710285d7da64a95ae8 Reviewed-on: https://chromium-review.googlesource.com/872230 Commit-Queue: Scott Violet <sky@chromium.org> Reviewed-by: Scott Violet <sky@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Cr-Commit-Position: refs/heads/master@{#530690} [modify] https://crrev.com/aa08ad82cc3843f8522feb409442ccd53151889e/base/process/process_metrics.h [modify] https://crrev.com/aa08ad82cc3843f8522feb409442ccd53151889e/base/process/process_metrics_freebsd.cc [add] https://crrev.com/aa08ad82cc3843f8522feb409442ccd53151889e/base/process/process_metrics_iocounters.h [modify] https://crrev.com/aa08ad82cc3843f8522feb409442ccd53151889e/base/process/process_metrics_linux.cc [modify] https://crrev.com/aa08ad82cc3843f8522feb409442ccd53151889e/base/process/process_metrics_mac.cc [modify] https://crrev.com/aa08ad82cc3843f8522feb409442ccd53151889e/base/process/process_metrics_openbsd.cc [modify] https://crrev.com/aa08ad82cc3843f8522feb409442ccd53151889e/base/process/process_metrics_win.cc [add] https://crrev.com/aa08ad82cc3843f8522feb409442ccd53151889e/base/win/win_client_metrics.h [modify] https://crrev.com/aa08ad82cc3843f8522feb409442ccd53151889e/base/win/win_util.cc [modify] https://crrev.com/aa08ad82cc3843f8522feb409442ccd53151889e/base/win/win_util.h [modify] https://crrev.com/aa08ad82cc3843f8522feb409442ccd53151889e/base/win/win_util_unittest.cc [modify] https://crrev.com/aa08ad82cc3843f8522feb409442ccd53151889e/chrome/browser/safe_browsing/safe_browsing_database.cc [modify] https://crrev.com/aa08ad82cc3843f8522feb409442ccd53151889e/content/browser/renderer_host/render_view_host_impl.cc [modify] https://crrev.com/aa08ad82cc3843f8522feb409442ccd53151889e/ui/base/l10n/l10n_util_win_unittest.cc [modify] https://crrev.com/aa08ad82cc3843f8522feb409442ccd53151889e/ui/gfx/platform_font_win.cc [modify] https://crrev.com/aa08ad82cc3843f8522feb409442ccd53151889e/ui/views/controls/menu/menu_config_win.cc [modify] https://crrev.com/aa08ad82cc3843f8522feb409442ccd53151889e/ui/views/widget/native_widget_aura.cc
,
Jan 22 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/3a458c7abeaa3e9edd7c75d9e7d380e84fa58fc5 commit 3a458c7abeaa3e9edd7c75d9e7d380e84fa58fc5 Author: Tomasz Moniuszko <tmoniuszko@opera.com> Date: Mon Jan 22 09:32:50 2018 Add missing includes to hwnd_message_handler_delegate.h Bug: 796644 Change-Id: I9c0b2ecc77eb72e97dec373297d2b2031ad68c82 Reviewed-on: https://chromium-review.googlesource.com/873648 Reviewed-by: Bruce Dawson <brucedawson@chromium.org> Reviewed-by: Scott Violet <sky@chromium.org> Commit-Queue: Tomasz Moniuszko <tmoniuszko@opera.com> Cr-Commit-Position: refs/heads/master@{#530826} [modify] https://crrev.com/3a458c7abeaa3e9edd7c75d9e7d380e84fa58fc5/base/win/windows_types.h [modify] https://crrev.com/3a458c7abeaa3e9edd7c75d9e7d380e84fa58fc5/ui/views/win/hwnd_message_handler_delegate.h
,
Mar 8 2018
As of ac8c96e764782cb4df3089277719653bfdafa384 (March 8, 2018), after a clean debug component build of chrome with these settings: is_debug = true is_component_build = true enable_nacl = false target_cpu = "x86" I found that there are 14,410 includes of windows.h: > ninja.exe -C out\debug_component -t deps | find /i /c "/windows.h" 14410 A slightly lower number of 14361 was found when running the -t deps output through parse_deps.py - attached. This is with DEPOT_TOOLS_WIN_TOOLCHAIN=1 because when building with the system installed version of Visual Studio the /showIncludes option doesn't report Windows.h. This is an increase from the 13822 reported January 4th, probably just from normal code growth. The results are categorized according to what object files the windows.h includes contribute to. The biggest contributors are: obj/third_party/WebKit - 5533 obj/chrome - 2221 obj/content - 956 obj/v8/v8 - 510 and so on. With luck there will be a few key header files that will broadly improve things. We'll see.
,
Mar 9 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/87a00ce53e5370d2f1ce55c83aa12720a7f89c6c commit 87a00ce53e5370d2f1ce55c83aa12720a7f89c6c Author: Bruce Dawson <brucedawson@chromium.org> Date: Fri Mar 09 21:53:50 2018 Enforce no use of windows.h in atomicops.h atomicops.h was fixed in January to not depend on Windows.h anymore. Update the comment to reflect that, and enforce it in the unit test. Bug: 559247, 796644 Change-Id: I95762b818d135f6f400e1b9aa66567464aef8951 Reviewed-on: https://chromium-review.googlesource.com/956668 Reviewed-by: Daniel Cheng <dcheng@chromium.org> Commit-Queue: Bruce Dawson <brucedawson@chromium.org> Cr-Commit-Position: refs/heads/master@{#542240} [modify] https://crrev.com/87a00ce53e5370d2f1ce55c83aa12720a7f89c6c/base/atomicops.h [modify] https://crrev.com/87a00ce53e5370d2f1ce55c83aa12720a7f89c6c/base/win/win_includes_unittest.cc
,
May 8 2018
Tests in a goma overhead bug (see https://bugs.chromium.org/p/chromium/issues/detail?id=819319#c12) show that excessive includes of Windows.h slow down goma builds as well. Or, at least, increase the local CPU load required for preprocessing for goma. So, reducing usage of Windows.h is useful for all and should still provide measurable (although not enormous) improvements in build times.
,
May 17 2018
Could we add a presubmit check to prevent new includes of Windows.h? (suggest using windows_types.h instead)
,
Jun 28 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/3c41dd4c6f6ab218366dbe4557910245e3f31bda commit 3c41dd4c6f6ab218366dbe4557910245e3f31bda Author: Bruce Dawson <brucedawson@chromium.org> Date: Thu Jun 28 16:22:59 2018 Don't include Windows.h from range.h Including Windows.h causes namespace pollution and build-time costs due to the heavy use of macros and the large size of the headers. This removes a #include of Windows.h from range.h that is currently causing problems. Bug: 855717 , 796644 Change-Id: I26abd068ed1c4a5ca65092258dd45ccd076c2b20 Reviewed-on: https://chromium-review.googlesource.com/1117739 Commit-Queue: Nico Weber <thakis@chromium.org> Reviewed-by: Nico Weber <thakis@chromium.org> Reviewed-by: Robert Sesek <rsesek@chromium.org> Cr-Commit-Position: refs/heads/master@{#571155} [modify] https://crrev.com/3c41dd4c6f6ab218366dbe4557910245e3f31bda/ui/gfx/range/range.h [modify] https://crrev.com/3c41dd4c6f6ab218366dbe4557910245e3f31bda/ui/gfx/range/range_win.cc [modify] https://crrev.com/3c41dd4c6f6ab218366dbe4557910245e3f31bda/ui/gfx/range/range_win_unittest.cc |
|||
►
Sign in to add a comment |
|||
Comment 1 by brucedaw...@chromium.org
, Dec 20 2017