Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client, refactor: simplify nullary flag handling #9121

Closed

Conversation

laszlocsomor
Copy link
Contributor

@laszlocsomor laszlocsomor commented Aug 8, 2019

Nullary startup flags (e.g. --[no]master_bazelrc)
are registered with
StartupOptions::RegisterNullaryStartupOption.

Important change: --host_jvm_debug now supports
the negative flag (--nohost_jvm_debug).
I suspect the missing support was a bug resulting
from the code duplication this PR eliminates.

Until now, nullary flags also had their special
handling logic, even though the logic was always
the same.

Now, nullary flags are registered together with
their member variable's pointer, and there's only
one code path to handle all. Startup flags
forbidden in .bazelrc files are handled specially.

Until now, we searched the handler code linearly
via a long if-elseif-elseif-... chain, so parsing
N flags out of M possible flags performed O(N*M)
string comparisons.

Now, we look up the nullary flag names from a
std::unordered_map, which has O(1) lookup
complexity, reducing the total complexity to O(M).

Also a drive-by improvement in blaze.cc: use
std::unique_ptr instead of manual new/delete.

Change-Id: Ie3dcba4ae6afa959e84657b7ff9bb8f4c87777fd

Nullary startup flags (e.g. --[no]master_bazelrc)
are registered with
StartupOptions::RegisterNullaryStartupOption.

Until now, nullary flags also had their special
handling logic, even though the logic was always
the same.

Now, nullary flags are registered together with
their member variable's pointer, and there's only
one code path to handle all. Startup flags
forbidden in .bazelrc files are handled specially.

Until now, we searched the handler code linearly
via a long if-elseif-elseif-... chain, so parsing
N flags out of M possible flags performed O(N*M)
string comparisons.

Now, we look up the nullary flag value from a
std::unordered_map, so the code is faster which
has O(1) lookup complexity, reducing the total
complexity O(M).

Change-Id: Ie3dcba4ae6afa959e84657b7ff9bb8f4c87777fd
@laszlocsomor laszlocsomor changed the title Client, refactor: simplify nullary flag handling WIP: Client, refactor: simplify nullary flag handling Aug 8, 2019
Change-Id: I74feb2936bb495259a072f1212b240c2ee62b6e4
Change-Id: I794cdc553ea833620b174375fbfdaa7492113d13
@laszlocsomor laszlocsomor changed the title WIP: Client, refactor: simplify nullary flag handling Client, refactor: simplify nullary flag handling Aug 8, 2019
@laszlocsomor laszlocsomor marked this pull request as ready for review August 8, 2019 09:43
@bazel-io bazel-io closed this in 5697da9 Aug 23, 2019
@laszlocsomor laszlocsomor deleted the nullary-startup-flags branch August 23, 2019 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants