Skip to content

Generate, index and display Dart SDK API results in pub search. #1581

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 12 commits into from
Sep 11, 2018

Conversation

isoos
Copy link
Collaborator

@isoos isoos commented Sep 5, 2018

@isoos isoos requested a review from sortie September 5, 2018 09:12
@isoos
Copy link
Collaborator Author

isoos commented Sep 5, 2018

Staging is being updated with this new version, should be available in less then an hour.

@isoos isoos force-pushed the search_generate_sdk branch 4 times, most recently from d0f0e45 to 4cf9faf Compare September 7, 2018 17:39
Copy link

@sortie sortie left a comment

Choose a reason for hiding this comment

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

lgtm

registerPackageIndex(new SimplePackageIndex());
registerTaskSendPort(taskReceivePort.sendPort);

// don't block on SDK index updates, as it may take several minutes before
// the dartdoc service produces the required output.
_updateDartSdkIndex();
Copy link

Choose a reason for hiding this comment

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

I believe there is an optional hint about unawaited futures. This code also doesn't look like it creates a future. How about .then((_) {}) or something to show that we do wish to ignore this background future?

_logger.warning('Error loading Dart SDK index.', e, st);
}
if (i % 10 == 0) {
_logger.warning('Unable to load Dart SDK index. Cycle: $i');
Copy link

Choose a reason for hiding this comment

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

Maybe use the word 'Attempt' instead of 'Cycle'

@@ -43,6 +46,60 @@ class DartdocBackend {

DartdocBackend(this._db, this._storage);

/// Whether the storage bucket has a useable extracted data file.
Copy link

Choose a reason for hiding this comment

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

usable

try {
final info = await _storage.info(objectName);
return info != null;
} catch (_) {
Copy link

Choose a reason for hiding this comment

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

Can we catch a specific exception instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I recall two distinct kind of error there, but one of them may be related to the outage I have mentioned earlier.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The other is DetailedApiRequestError, and I'm not sure where it is coming from.

@@ -43,6 +46,60 @@ class DartdocBackend {

DartdocBackend(this._db, this._storage);

/// Whether the storage bucket has a useable extracted data file.
/// Only the existence of the file is checked.
// TODO: decide whether we should re-generate the file after a certain age
Copy link

Choose a reason for hiding this comment

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

Is it redone when we bump pana or the runtime versions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it is redone.

storage_path.dartSdkDartdocDataName(shared_versions.runtimeVersion);
try {
final contentBytes = await file.readAsBytes();
await _storage.writeBytes(objectName, _gzip.encode(contentBytes));
Copy link

Choose a reason for hiding this comment

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

Is there a stream way to write the bytes?

} catch (e, st) {
final message =
'Unable to read SDK pub dartdoc data file (attempt #${i + 1}): $objectName ';
_logger.info(message, e, st);
Copy link

Choose a reason for hiding this comment

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

Woah. This seems flaky. What's the problem here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IIRC it was about the time where we have experienced several timeouts and 500s from the dartdoc's storage bucket both in prod and in staging. We can be more optimistic now, shall I remove?

Copy link

Choose a reason for hiding this comment

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

If you think it's stable? If we try once here, and it fails, is it later retried at a higher level?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it is retried at a higher level, removing the redundancy.

'dart',
['bin/pub_dartdoc.dart']..addAll(args),
workingDirectory: _pkgPubDartdocDir,
timeout: _dartdocTimeout * 2,
Copy link

Choose a reason for hiding this comment

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

Why times 2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Generating docs for the SDK takes longer time, and this seemed to be a good number. I'll refactor it into a separate const.

final isOk = pr.exitCode == 0 && hasPubData;
if (!isOk) {
_logger.warning(
'Error while generating SDK docs.\n\n${pr.stdout}\n\n${pr.stderr}');
Copy link

Choose a reason for hiding this comment

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

Should this be an error? Can this be triggered by poor user code? In that case, can we recognize the difference between bad user input and an infrastructure problem?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is most likely an infrastructure problem, making it a hard error.


/// The ObjectName for the Dart SDK's extracted dartdoc content.
String dartSdkDartdocDataName(String runtimeVersion) {
return sdkObjectName('dart/pub-dartdoc-data/$runtimeVersion.json.gz');
Copy link

Choose a reason for hiding this comment

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

Does anything garbage collect these old files or do they accumulate indefinitely? Does this mean we have to update the runtime version whenever we update the Dart SDK? Should we decouple the Dart SDK used for the API results and the Dart SDK pub's website itself uses?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Does anything garbage collect these old files or do they accumulate indefinitely?

No GC yet, but there will be.

Does this mean we have to update the runtime version whenever we update the Dart SDK? Should we decouple the Dart SDK used for the API results and the Dart SDK pub's website itself uses?

We do need to update it right now, but we could decouple the runtime SDK version from it. I'll need to think about it if there is any additional risk with the current stack, and I'll file a separate PR.

@isoos isoos force-pushed the search_generate_sdk branch from 4cf9faf to 0ec82a7 Compare September 11, 2018 07:47
@isoos isoos merged commit e3acf11 into dart-lang:master Sep 11, 2018
@isoos isoos deleted the search_generate_sdk branch September 11, 2018 11:50
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.

None yet

3 participants