Skip to content

Conversation

@shrinidhijoshi
Copy link
Collaborator

@shrinidhijoshi shrinidhijoshi commented Nov 20, 2025

Presto on Spark (and Presto Java) are missing the logging of Task createTime and endTime RuntimeMetric. The Presto Native Task execution logs these.

These metrics are used internally at Meta to show stage level start and end time visualizations.

This PR adds them so that we can leverage this internal tooling for Presto-on-Spark Java queries. Specially useful when comparing performance/runtime of java v/s native presto-on-spark queries

For reference, internally at Meta, adding these metrics enables this visualization
Screenshot 2025-11-20 at 1 22 51 PM

== NO RELEASE NOTE ==

@shrinidhijoshi shrinidhijoshi requested a review from a team as a code owner November 20, 2025 21:13
@prestodb-ci prestodb-ci added the from:Meta PR from Meta label Nov 20, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 20, 2025

Reviewer's Guide

The PR introduces createTime and endTime metrics into TaskContext’s RuntimeStats to match native behavior by capturing and injecting these timestamps into mergedRuntimeStats and updating TaskStats construction, along with adding end-to-end tests verifying the new metrics before and after task completion.

Entity relationship diagram for updated RuntimeStats metrics

erDiagram
    TASK_CONTEXT ||--o{ RUNTIME_STATS : updates
    RUNTIME_STATS {
        string metricName
        string metricType
        long metricValue
    }
    RUNTIME_STATS ||--|{ TASK_STATS : included_in
    TASK_STATS {
        long createTimeInMillis
        long endTimeInMillis
    }
Loading

Class diagram for updated TaskContext and TaskStats

classDiagram
    class TaskContext {
        +getTaskStats()
        -taskStateMachine
        -executionEndTime
        -mergedRuntimeStats
    }
    class TaskStats {
        +createTimeInMillis: long
        +endTimeInMillis: long
        +executionStartTime
        +lastExecutionStartTime
        +lastExecutionEndTime
        +elapsedTimeInNanos
        +queuedTimeInNanos
        +totalDrivers
    }
    class RuntimeStats {
        +addMetricValue(name: String, type, value: long)
    }
    TaskContext --> TaskStats
    TaskContext --> RuntimeStats
    TaskStats o-- "createTimeInMillis" long
    TaskStats o-- "endTimeInMillis" long
    RuntimeStats <.. TaskContext : "addMetricValue('createTime', ...)"
    RuntimeStats <.. TaskContext : "addMetricValue('endTime', ...)"
Loading

File-Level Changes

Change Details Files
Inject createTime and endTime metrics into RuntimeStats and update TaskStats fields
  • Introduce local createTimeInMillis and endTimeInMillis variables
  • Add createTime metric unconditionally and endTime metric when >0 to mergedRuntimeStats
  • Replace inline timestamp getters in TaskStats constructor with the new variables
presto-main-base/src/main/java/com/facebook/presto/operator/TaskContext.java
Add tests validating createTime and endTime metrics in TaskContext runtime stats
  • Create TestTaskContextRuntimeStats with two test methods
  • Verify createTime is present and matches task creation time
  • Ensure endTime metric appears and is >= createTime after task finishes and remains zero or absent before completion
presto-main-base/src/test/java/com/facebook/presto/operator/TestTaskContextRuntimeStats.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

tanjialiang
tanjialiang previously approved these changes Nov 20, 2025
Copy link
Contributor

@tanjialiang tanjialiang left a comment

Choose a reason for hiding this comment

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

Thanks LGTM

Copy link
Contributor

@NikhilCollooru NikhilCollooru left a comment

Choose a reason for hiding this comment

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

Lgtm

@shrinidhijoshi shrinidhijoshi merged commit c270c64 into prestodb:master Nov 21, 2025
80 of 81 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

from:Meta PR from Meta

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants