Skip to content

Add more benchmarks and improve framework#299

Merged
JonoPrest merged 4 commits into
mainfrom
jp/more-benchmark
Oct 28, 2024
Merged

Add more benchmarks and improve framework#299
JonoPrest merged 4 commits into
mainfrom
jp/more-benchmark

Conversation

@JonoPrest

Copy link
Copy Markdown
Collaborator
  1. Adds a benchmark for every event handler to help identify handler hotspots
  2. Improves the framework where SummaryData is not an array of floats as a data point but a rolling accumulation. This helps with not having continuous memory increasing as pushing to these arrays. But it's not yet safe to leave running on an indexer since there's no safety added to the continuous float multiplication/summing. So at some point it could overflow the js number. We could look at converting to bigint but then we loose floating points.
  3. Improve the json file write scheduler to only write every 500ms rather than on every benchmark update. It's helpful so you can fire off many more smaller benchmarks to the data set like the per handler one I added without slowing things down too much.

@JonoPrest JonoPrest requested a review from DZakh October 25, 2024 16:59
Comment on lines +57 to +58
sum: self.sum +. val,
sumOfSquares: self.sumOfSquares +. val *. val,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

These are the two places where a long running benchmark could eventually overflow.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is no longer relevant I just changed this to using BigDecimal type.

@as("std-dev") stdDev: float,
min: float,
max: float,
last: float,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I actually never meant to keep last in before. I don't think it's very useful. And it won't work with this model of accumulated data rather than saving all data points in the data set.

@DZakh DZakh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good 👍

Comment on lines +152 to +154
let _ = Js.Global.setTimeout(() => {
start()->ignore
}, intervalMillis - timeSinceLastRun->Belt.Float.toInt)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This can be scheduled multiple times. Nothing should break, just a risk of unexpected execution.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It can but it overwrites the scheduled function on each schedule. So more like it just calls start multiple times.

Maybe it's best to just add the "isWriting" if check here or in the start function again.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added the check in "start" 👍🏼

@@ -187,8 +261,7 @@ module Summary = {
@as("std-dev") stdDev: float,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Never worked with std-dev before. I usually look at mean and avg

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I use it quite a lot. It will essentially give you an idea of how much variance your data has.
Screenshot 2024-10-28 at 09 33 56
For eg. the circle in green has low variance and the mean should be an accurate representation.

The red circle has high variance so something makes it inconsistent. Could speak to something that is cached vs not-cached on different runs etc.

let eventsPerSecond =
batchSizesSum
->BigDecimal.div(BigDecimal.fromFloat(totalRuntimeSeconds))
->BigDecimal.decimalPlaces(2)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we have decimals here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It doesn't really matter I suppose. I just kept it at 2.

@JonoPrest JonoPrest merged commit f02cc02 into main Oct 28, 2024
@JonoPrest JonoPrest deleted the jp/more-benchmark branch October 28, 2024 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants