Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Conversation

AbdelStark
Copy link
Contributor

PR description

  • compute estimated world state completion
  • display estimated world state completion in the logs
  • CompleteTaskStep now have access to a LongSupplier to retireve the number of pending requests
  • use a RunnableCounter to trigger displaying every 1000 requests completed
  • only show a new log when the estimation changes
  • added test to check the estimation computation

Fixed Issue(s)

- compute estimated world state completion
- display estimated world state completion in the logs
- `CompleteTaskStep` now have access to a `LongSupplier` to retireve the number of pending requests
- use a `RunnableCounter` to trigger displaying every 1000 requests completed
- only show a new log when the estimation changes
- added test to check the estimation computation
@AbdelStark AbdelStark added the enhancement New feature or request label Jul 4, 2019
@ajsutton
Copy link
Contributor

ajsutton commented Jul 4, 2019

I’d suggest reporting the raw downloaded vs pending nodes rather than calculating the percentage. Otherwise it will fairly quickly get to 99.9% or even 100% complete and stay there for a day or so. I lernt that the hard way - my first dashboard tried to report it as a percent. :)

@AbdelStark
Copy link
Contributor Author

I’d suggest reporting the raw downloaded vs pending nodes rather than calculating the percentage. Otherwise it will fairly quickly get to 99.9% or even 100% complete and stay there for a day or so. I lernt that the hard way - my first dashboard tried to report it as a percent. :)

Ok no problem

@AbdelStark AbdelStark requested a review from ajsutton July 4, 2019 09:31

public class CompleteTaskStep {
private static final Logger LOG = LogManager.getLogger();
private static final int DISPLAY_PROGRESS_STEP = 1000;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is logging too often. Needs to be at least 100,000 maybe even a million. We request up to 3,840 node at a time (10 concurrent requests for 384 nodes).

Copy link
Contributor

Choose a reason for hiding this comment

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

A million is too rare - I'd go for 100,000.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

final String newEstimatedWorldStateCompletion =
doubleFormatter.format(computeWorldStateSyncProgress());
if (!Objects.equals(newEstimatedWorldStateCompletion, lastEstimatedWorldStateCompletion)) {
LOG.info("Estimated World State completion: {}", newEstimatedWorldStateCompletion);
Copy link
Contributor

Choose a reason for hiding this comment

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

As mentioned the percent complete winds up being misleading. This should probably be something like:
Downloaded {} world state nodes. At least {} nodes remaining.. That conveniently avoids most of the complexity too. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suggest keeping the percent as an estimation at the end of the log because i think it was the initial request.

@@ -48,9 +49,14 @@ public void inc() {
public void inc(final long amount) {
stepCounter.addAndGet((int) amount);
backedCounter.inc(amount);
total++;
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't thread safe so total will wind up being the wrong value.

Actually stepCounter isn't thread safe either. It should be a final AtomicLong then this method becomes something like:

backedCounter.inc(amount);
if (stepCounter.addAndGet(amount) % step == 0) {
  task.run();
}

And then you can just get the total with stepCounter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it is true, this is what i did for the first implementation of this class. But during the review someone said that if we don't need the total then no need to use a modulo just store the incremental counter and reset to zero when hit the step. But now we need the total so i will implement this approach.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, it's not that we need the total - it's that it's not thread-safe to assign the new AtomicInteger (nor is it safe to downcast the long to an int when incrementing it). You could wind up with all kinds of weird exceptions coming out of it because the AtomicInteger could be exposed to other threads before its constructor has actually completed (compilers and CPUs are free to reorder instructions as there's no memory fences involved).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@AbdelStark AbdelStark requested a review from ajsutton July 5, 2019 08:27
@AbdelStark AbdelStark requested a review from RatanRSur July 5, 2019 16:18
@AbdelStark AbdelStark merged commit 4cc3926 into PegaSysEng:master Jul 5, 2019
@AbdelStark AbdelStark deleted the feature/pie-1712-display-world-state-sync-progress-logs branch July 8, 2019 07:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants