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

cleanup: remove asynchronous experiments #1613

Merged
merged 5 commits into from
Jun 5, 2024
Merged

cleanup: remove asynchronous experiments #1613

merged 5 commits into from
Jun 5, 2024

Conversation

bassosimone
Copy link
Contributor

@bassosimone bassosimone commented Jun 5, 2024

We originally developed asynchronous experiments as a mean to support websteps, a nettest that returned more than one measurement per invocation of its Measure method.

Since then, we removed websteps. Therefore, this code is currently technically unused. Additionally, this code further complicates implementing richer input, because it is another way of performing measurements.

As such, in the interest of switfly moving forward with richer input and of simplifying the engine, we are now removing this unused functionality from the tree.

While there, better the documentation of OnProgress and undeprecate functions to open/close reports since it's clear that, for now, using a submitter in cmd/ooniprobe is a bit of a stretch given our current goals. So, it feels best to avoid deprecating until we have nice plan for replacement.

To have more confidence that the job we did is ~correct, we use the following table to cross compare the operations that we previously performed for running sync experiments (i.e., all experiments) in an async way to the code we're using after this diff to run experiments. (Note that the diff itself is such that you can easily see the deleted and the added code inside of the experiment.go file.) In both cases, we're looking at the operations performed starting from MeasureWithContext.

Operation Before After
MaybeLookupLocationContext yes yes
use e.session.byteCounter yes yes
use e.byteCounter yes yes
newMeasurement yes yes
save start time yes yes
initialize experiment args yes yes
call measurer.Run yes yes
save end time yes yes
compute measurement runtime yes yes
scrub measurement yes yes
return measurement yes yes

Part of ooni/probe#2607

Depends on #1612

This diff refactors *engine.experiment to make the report field
goroutine safe. It also moves at the bottom of experiment.go code
that was intermixed with *engine.experiment methods.

Part of ooni/probe#2607
@bassosimone bassosimone marked this pull request as draft June 5, 2024 15:17
@bassosimone bassosimone force-pushed the issue/2607b branch 2 times, most recently from 528e8c0 to 348c391 Compare June 5, 2024 15:25
We originally developed asynchronous experiments as a mean to
support websteps, a nettest that returned more than one measurement
per invocation of its Measure method.

Since then, we removed websteps. Therefore, this code is currently
technically unused. Additionally, this code further complicates
implementing richer input, because it is another way of performing
measurements.

As such, in the interest of switfly moving forward with richer
input _and_ of simplifying the engine, we are now removing this
unused functionality from the tree.

Part of ooni/probe#2607
@bassosimone bassosimone marked this pull request as ready for review June 5, 2024 15:47
Conflicts:
	internal/engine/experiment.go
Copy link
Contributor

@DecFox DecFox left a comment

Choose a reason for hiding this comment

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

LGTM!

@bassosimone
Copy link
Contributor Author

The coverage error is like:

--- FAIL: TestDoUploadWithCancelledContext (0.00s)
    ndt7_test.go:73: not the error we expected dns_server_misbehaving
FAIL
coverage: 62.2% of statements
FAIL	github.com/ooni/probe-cli/v3/internal/experiment/ndt7	0.092s

It seems very unrelated so I think it's okay for us to merge.

// TODO(bassosimone,DecFox): historically we did this only for measuring
// and not for opening a report, which probably is not correct. Because the
// function call is idempotent, call it also when opening a report?
if err := e.session.MaybeLookupLocationContext(ctx); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I was wondering if MaybeLookupLocationWithContext would be more descriptive?

Re. moment to call it, a subtle concern here might be the low likelihood that there's a network change between measurement and submission.

Thinking mostly in asynchronous submission, I think it'd be healthy to a) call it when submitting; b) raise an error (or warning) if submitting a msmt for a different (CC,ASN) that the report we've opened. I can work on that as part of my future deliverables, that include deferred submission (which is an special case).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ainghazal wrote:

I was wondering if MaybeLookupLocationWithContext would be more descriptive?

Yeah, so, first of all we can gain some more characters by removing WithContext, which is an artifact from when we also had a version of the call without a context. How would you suggest to change the name?

Re. moment to call it, a subtle concern here might be the low likelihood that there's a network change between measurement and submission.

Thinking mostly in asynchronous submission, I think it'd be healthy to a) call it when submitting; b) raise an error (or warning) if submitting a msmt for a different (CC,ASN) that the report we've opened. I can work on that as part of my future deliverables, that include deferred submission (which is an special case).

As far as I know, when we're resubmitting we're using a probeservices.Submitter: https://github.com/ooni/probe-cli/blob/master/internal/probeservices/collector.go#L185. The code should open reports only based on the data stored inside the measurement, so it should support the use case of measuring, say, w/o VPN, and then submitting with VPN. It would be great to have another pair of eyes looking at the code as well as having some manual testing to ensure whether this is still true. It might also be good to have a test guaranteeing that this is the case.

Copy link
Contributor

@ainghazal ainghazal Jun 5, 2024

Choose a reason for hiding this comment

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

How would you suggest to change the name?

if so, perhaps just MaybeLookupLocation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure!

@bassosimone bassosimone merged commit 885ce85 into master Jun 5, 2024
19 checks passed
@bassosimone bassosimone deleted the issue/2607b branch June 5, 2024 17:34
@bassosimone bassosimone added the 2024-06-richer-input Tracking 2024-06 richer input work label Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2024-06-richer-input Tracking 2024-06 richer input work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants