Skip to content

[build-script-impl] Optimize setting -> variable name lookups. #2847

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

Conversation

ddunbar
Copy link
Contributor

@ddunbar ddunbar commented Jun 2, 2016

What's in this pull request?

This optimizes build-script-impl's setting processing code (which was adding about 1s to each invocation, on my machine). See commit for details.

Related to SR-237.


Before merging this pull request to apple/swift repository:

  • Test pull request on Swift continuous integration.

Triggering Swift CI

The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:

Smoke Testing

Platform Comment
All supported platforms @swift-ci Please smoke test
All supported platforms @swift-ci Please smoke test and merge
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
All supported platforms @swift-ci Please test and merge
OS X platform @swift-ci Please test OS X platform
OS X platform @swift-ci Please benchmark
Linux platform @swift-ci Please test Linux platform

Lint Testing

Language Comment
Python @swift-ci Please Python lint

Note: Only members of the Apple organization can trigger swift-ci.

  • The current behavior of mapping via tr was very slow when called over and
    over for each option. This matters for SR-237 where I would like
    build-script to take over the top-level build process control loop, which
    involves executing build-script-impl multiple times.
  • This patch optimizes the lookup in two ways:
    1. It does the setting to variable conversion in a single pass, for all
      options at once.
    2. It builds a cache of the setting to variable name conversion (as an
      exploded associate array), and uses that when doing variable assignment.
  • This patch speeds up build-script-impl --dry-run by 2x on one test case.

 - The current behavior of mapping via `tr` was very slow when called over and
   over for each option. This matters for SR-237 where I would like
   `build-script` to take over the top-level build process control loop, which
   involves executing `build-script-impl` multiple times.

 - This patch optimizes the lookup in two ways:

   1. It does the setting to variable conversion in a single pass, for all
      options at once.

   2. It builds a cache of the setting to variable name conversion (as an
      exploded associate array), and uses that when doing variable assignment.

 - This patch speeds up `build-script-impl --dry-run` by 2x on one test case.
@ddunbar
Copy link
Contributor Author

ddunbar commented Jun 2, 2016

/cc @gribozavr

@swift-ci please smoke test

@gribozavr
Copy link
Contributor

LGTM!

@gribozavr gribozavr merged commit e7429b9 into swiftlang:master Jun 3, 2016
@ddunbar ddunbar deleted the build-script-impl-optimize-setting-to-variable-lookups branch June 6, 2016 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants