Skip to content
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

upstream: perf: Avoid an extra function call and object clone during event emission #180

Merged
merged 2 commits into from
Apr 22, 2024

Conversation

billyvg
Copy link
Member

@billyvg billyvg commented Apr 19, 2024

performance: remove a nested function call and an object clone during event emission

  • rename event to eventWithoutTime, but maintain backwards compatibility
  • eventWithTime (with time) could be renamed to event in a future version

This is an extension of PR rrweb-io#1339 authored by: mydea mydea@users.noreply.github.com

@billyvg billyvg force-pushed the upstream-ae6908dcdcd7c732c1ce79eea19de5240bec1151 branch from 9c68c30 to 3a7f7f9 Compare April 19, 2024 16:30
@billyvg
Copy link
Member Author

billyvg commented Apr 19, 2024

Ref rrweb-io#1441

@billyvg billyvg changed the title perf: Avoid an extra function call and object clone during event emission (#1441) upstream: perf: Avoid an extra function call and object clone during event emission Apr 19, 2024
…sion (rrweb-io#1441)

performance: remove a nested function call and an object clone during event emission

 - rename `event` to `eventWithoutTime`, but maintain backwards compatibility
 - `eventWithTime` (with time) could be renamed to `event` in a future version

This is an extension of PR rrweb-io#1339 authored by: mydea <mydea@users.noreply.github.com>
@billyvg billyvg force-pushed the upstream-ae6908dcdcd7c732c1ce79eea19de5240bec1151 branch from 3a7f7f9 to 5eef4f8 Compare April 19, 2024 16:32
Comment on lines -57 to -62
function wrapEvent(e: event): eventWithTime {
const eWithTime = e as eventWithTime;
eWithTime.timestamp = nowTimestamp();
return eWithTime;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Added in #124, but removed in upstream PR which builds upon #124.

Copy link

size-limit report 📦

Path Size
rrweb - record only (gzipped) 16.84 KB (-0.04% 🔽)
rrweb - record & CanvasManager only (gzipped) 19.64 KB (-0.06% 🔽)
rrweb - record only (min) 57.35 KB (-0.17% 🔽)
rrweb - record with treeshaking flags (gzipped) 15.62 KB (-0.04% 🔽)

@billyvg billyvg marked this pull request as ready for review April 19, 2024 17:25
@billyvg billyvg requested a review from a team April 19, 2024 17:32
type: EventType.IncrementalSnapshot,
data: {
source: IncrementalSource.CanvasMutation,
...p,
Copy link
Member

Choose a reason for hiding this comment

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

more a sidenote and unrelated to this PR, but I wonder if we could/should also make a change to all of these to avoid spreading these, and instead just set the source on the data 🤔 may help a little bit with memory usage, but not sure if worth it...

Copy link
Member Author

Choose a reason for hiding this comment

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

We could run benchmark suite and see if there's anything noticable.

@billyvg billyvg merged commit e53e6a6 into sentry-v2 Apr 22, 2024
14 checks passed
@billyvg billyvg deleted the upstream-ae6908dcdcd7c732c1ce79eea19de5240bec1151 branch April 22, 2024 18:57
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.

3 participants