Skip to content

[test/Shell] Add stepper test for Benchmark_Onone #2059

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 4 commits into from
Oct 29, 2020

Conversation

vedantk
Copy link

@vedantk vedantk commented Oct 28, 2020

This PR wires up the stepper testing script to run alongside normal test/Shell testing.

This isn't the only (or necessarily the best) way to do stepper testing in CI. For example, we could modify some CI jobs to check out and run the stepper script.

Some advantages of doing stepper testing within test/Shell:

  • We don't need to invent a way to launch the just-built lldb driver (i.e. we can abandon https://reviews.llvm.org/D90276).
  • Existing CI jobs can gain additional test coverage (requires omitting --skip-build-benchmarks and adding a special cmake option though)
  • Test results show up in Jenkins, just like we're used to.
  • You (lldb devs) can easily run the test via llvm-lit.

@vedantk
Copy link
Author

vedantk commented Oct 28, 2020

@swift-ci test

###############################################################################

# Only visit unoptimized frames.
kOnlyUnoptimized = True

Choose a reason for hiding this comment

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

just curious: why do these names start with k?

Choose a reason for hiding this comment

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

If these are meant to be constants they should be all uppercase (https://www.python.org/dev/peps/pep-0008/#constants)

Copy link
Author

Choose a reason for hiding this comment

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

Will fix. @adrian-prantl heh, we have some history here: https://reviews.llvm.org/D80684#inline-741730

@@ -0,0 +1,214 @@
from __future__ import print_function

Choose a reason for hiding this comment

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

why is this in Inputs? Should it be in helper/?

Copy link
Author

Choose a reason for hiding this comment

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

Fixed.

Copy link

@adrian-prantl adrian-prantl left a comment

Choose a reason for hiding this comment

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

Great to see this moving forward!

@vedantk
Copy link
Author

vedantk commented Oct 28, 2020

@swift-ci test

SKIP_N_FRAMES_BETWEEN_INSPECTIONS
opts = os.getenv('STEPPER_OPTIONS', '').split(';')
for o in opts:
m = re.match('(\w+)=([^;]+)', o)

Choose a reason for hiding this comment

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

([^;]+) seems like it could be (.+) since the split above will ensure there are no ; characters. This could even be split('=').

thread.StepOutOfFrame(frame)
new_frame = thread.GetSelectedFrame()
new_name = new_frame.GetFunctionName()
print(':: Transitioned from {0} -> {1}.'.format(old_name, new_name))

Choose a reason for hiding this comment

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

the format numbers could be left out, ex {} -> {}

get_statics, get_in_scope_only)
for var in variables:
name = var.GetName()
if not var.GetLocation():

Choose a reason for hiding this comment

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

maybe a comment on why a variable is skipped when it has no location?

Copy link
Author

Choose a reason for hiding this comment

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

will add a comment


def doquit(dbg):
"Quit the stepper script interpreter."
os._exit(0)

Choose a reason for hiding this comment

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

If there's a reason to not call os.exit(), maybe a comment why?

Copy link
Author

Choose a reason for hiding this comment

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

No reason, just exit(0) works fine. Will fix.

else:
option, val = m.groups()
print('Setting', option, '=', val)
globals()[option] = eval(val)

Choose a reason for hiding this comment

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

Probably safer to use ast.literal_eval() over eval().

Copy link
Author

Choose a reason for hiding this comment

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

TIL! Agreed, but in this case imo it's not worth making the code more defensive, since eval-abuse is unlikely to get through code review.

process = target.GetProcess()
visited_pc_counts = defaultdict(int)
while True:
gen += 1

Choose a reason for hiding this comment

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

would it be useful to also track how many times do_inspection ends up being true, and including that count along with the generation count?

Copy link
Author

Choose a reason for hiding this comment

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

Yep, we want to configure tests to minimize the difference between #inspections and #generations, otherwise we're just wasting cycles without gaining test coverage.

@vedantk
Copy link
Author

vedantk commented Oct 28, 2020

@swift-ci test


# Skip optimized frames if asked to do so.
if do_inspection and ONLY_VISIT_UNOPTIMIZED and \
str(frame).endswith(' [opt]'):

Choose a reason for hiding this comment

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

TIL SBFrame has IsArtificial and IsInlined but not IsOptimized. Should we add this?

Copy link
Author

Choose a reason for hiding this comment

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

Probably, yeah. I'll put a patch together.

Copy link
Author

Choose a reason for hiding this comment

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

Ah, maybe SBFunction::GetIsOptimized is sufficient? I can see the logic behind that. Whether or not a function is inlined or tail-called depends on the frame. But if a function is optimized, that's true independent of which frame you pick.

@vedantk vedantk merged commit 6c734a4 into swiftlang:swift/main Oct 29, 2020
@vedantk vedantk deleted the stepper branch October 29, 2020 02:00
@vedantk vedantk restored the stepper branch October 29, 2020 02:01
@vedantk vedantk deleted the stepper branch October 29, 2020 02:05
vedantk added a commit to vedantk/swift that referenced this pull request Oct 30, 2020
Add a new "buildbot_incremental,lldb_asan_ubsan" preset.

This differs from the existing preset used to do sanitized lldb testing
on ci.swift.org, "buildbot_incremental_asan_ubsan,tools=RDA,stdlib=RDA",
in the following ways:

- It builds the swift benchmarks, with an unoptimized benchmark driver.
  This is to enable stepper testing on CI. For more context, see:
  swiftlang/llvm-project#2059.

- It does not build a sanitized clang or swift. This can save a large
  amount of time, and make reports from oss-lldb-asan bots more useful.

This is still WIP pending more testing.

Note:

A dry run for the existing buildbot_incremental_asan_ubsan preset does
not apply '--skip-build-benchmarks':

```
./swift/utils/build-script -n --preset "buildbot_incremental_asan_ubsan,tools=RDA,stdlib=RDA"
```

So I'm not yet sure where that comes from. Perhaps the oss-lldb-asan-osx
bot is using a different preset?

rdar://69589638
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.

4 participants