Giter Club home page Giter Club logo

Comments (4)

sam-goodwin avatar sam-goodwin commented on July 20, 2024 1

Isn't the maximum size of a "group" 2? So it's not really that much extra processing - the finds are constant time

from eventual.

cfraz89 avatar cfraz89 commented on July 20, 2024

The code is matching activities right now, but don't see why it can't be broadened to match any schedule/end event, using the same heuristic style as your sampel code. While I do generally like more declarative code, I think in this case doing the grouping / find thing results in a lot of extra processing, doing a bunch of passes over nested lists. It can just be done in one pass by building the output map as you go:

let spanningActivities = Record<seq, TimelineActivity>{}
const otherActivities = TimelineActivity[]
 events.forEach((event) => {
    if (match(event, isWorkflowStarted)) {
      start = event;
    } else if (match(event, isScheduledEvent)) {
      //creates timelineactivity with start time and event type
      spanningActivities[event.seq] = {type: activityType(event.type), start: event.start}
    } else if (match(event, or(isCompletedEvent, isFailedEvent, isWorkflowTimedOut)) {
    //update timelineactivity with state and end time
     spanningActivities[event.seq].state = {status: activityStatus(event), end: event.end}
    } else if (event.match(or(isSignalReceived, isWorkflowStarted, isWorkflowFailed, isWorkflowCompleted, isWorkflowTimedOut)) {
    otherActivities.push(activityOf(event))
    }
}

return  [...Object.entries(spanningActivities), ...otherActivities]

As far as I can tell the outcome is the same, just a bit lower level, a bit more verbose, but saving a bunch of computation.

from eventual.

thantos avatar thantos commented on July 20, 2024

After grouping, the nested lists should be small, I doubt you'd be able to come up with a realistic history where you'd tell the performance difference. The groupby is doing most of the work here.

Clean/correct code > micro-optimizations. Then optimize if there is an actual issue.

Your implementation:

  1. relies on the order
  2. will always take the last event that matches the condition (mine takes the first)
  3. depends on both events existing in order (not fault tolerant)
  4. doesn't filter out the start or end event from "other"
  5. ignores the non-state/end events that may relate to an "Eventual"/activity.

If your stateful accumulator can resolve this issues (with more code), then I think it would be fine, but... correct > micro-optimized.

from eventual.

thantos avatar thantos commented on July 20, 2024

Maybe not max (ex: we may get a "timeout" and then later get the "complete") or we may have intra-activity events in the future like a heartbeat checkpoint that gets stored in the workflow.

Though I'd constrain the size of a group to an average of < magnitude 10. (aka essentially constant).

from eventual.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.