8000 Introduce ENFORCE_FAST to speed up tests in debug builds by jvilk-stripe · Pull Request #3341 · sorbet/sorbet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Introduce ENFORCE_FAST to speed up tests in debug builds #3341

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

Merged
merged 8 commits into from
Aug 4, 2020

Conversation

jvilk-stripe
Copy link
Collaborator

Introduce ENFORCE_FAST to speed up tests in debug builds.

ENFORCE_FAST is equal to ENFORCE, except it doesn't create timers.

Motivation

Timers were making debug test runs >50% slower locally. With these changes, test/testdata/lsp/definitions_and_usages takes less than half as much time as it used to (7s-8s to ~3.3s on my laptop).

  • 7.37s - 8.12s Before optimizations
  • 5.58s - 6.0s after SymbolRef::data/dataAllowingNone change
  • 5.3 - 5.6 after resolver::computeClassLinearization change
  • 4.0s - 4.4s after SymbolDataDebugCheck::check change
  • 4.0s after Symbol::mixins(), superClass()
  • 3.8s after Symbol::sanityCheck
  • 3.5s after GS::enterSymbol >2.7%
  • 3.4s after Symbol::arguments and a few others ~0.7%
  • ~3.25s after Name::sanityCheck / gs::sanityCheck

Timers still show up prominently in profiles, and I know there's probably another ~500ms of savings to trim, but this is good enough for now and will speed up my workflow.

Test plan

This change does not impact correctness.

@jvilk-stripe jvilk-stripe requested a review from jez August 4, 2020 00:45
@jvilk-stripe jvilk-stripe requested a review from a team as a code owner August 4, 2020 00:45
@jvilk-stripe
Copy link
Collaborator Author

I am open to renaming the new ENFORCE directive, too (ENFORCE_NO_TIMER?).

common/common.h Outdated
@@ -32,22 +32,32 @@ template <class E> using UnorderedSet = absl::flat_hash_set<E>;

#define _MAYBE_ADD_COMMA(...) , ##__VA_ARGS__

// A faster version of ENFORCE that does not emit a timer. Useful for checks that happen extremely frequently and
// are O(1). Please avoid using unless ENFORCE shows up in profiles.
#define ENFORCE_FAST(x, ...) \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We encourage people to prefer the fast thing many times in Sorbet (e.g., people cargo cult fast_sort).

I worry that people will think ENFORCE_FAST should be their default choice if they don't read the comment. What do you think about UNTIMED_ENFORCE or ENFORCE_WITHOUT_TIMER?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah just saw your comment (#3341 (comment)). That name works for me too!

Copy link
Collaborator
@jez jez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm on concept and implementation (thanks for implementing one in terms of the other). i have qualm about naming, because this shows up a lot, and in common files that people are like to read while being new to the team, so i'd like to make sure we choose a name that encourages people to still prefer ENFORCE

@jvilk-stripe jvilk-stripe merged commit 0c301f6 into master Aug 4, 2020
@jvilk-stripe jvilk-stripe deleted the jvilk/faster-enforce branch August 4, 2020 03:29
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
0