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

[Merged by Bors] - [profiler] Cache StringId #2495

Closed
wants to merge 3 commits into from

Conversation

tunz
Copy link
Contributor

@tunz tunz commented Dec 20, 2022

boa_profiler was allocating new strings every time even when they are the same string, which leads to a crash when start_event is called too much. This change updates the profiler to use a hash map cache and avoid duplicate string allocations.

boa_profiler was allocating new strings every time even when they are
the same string. This change updates the profiler to use a cache and
avoid duplicate allocations.
@codecov
Copy link

codecov bot commented Dec 20, 2022

Codecov Report

Merging #2495 (d0e0686) into main (9912c37) will increase coverage by 0.62%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #2495      +/-   ##
==========================================
+ Coverage   52.40%   53.02%   +0.62%     
==========================================
  Files         339      342       +3     
  Lines       35170    34720     -450     
==========================================
- Hits        18431    18412      -19     
+ Misses      16739    16308     -431     
Impacted Files Coverage Δ
boa_profiler/src/lib.rs 66.66% <ø> (ø)
boa_interner/src/lib.rs 80.67% <0.00%> (-3.37%) ⬇️
boa_engine/src/value/conversions.rs 58.69% <0.00%> (-1.73%) ⬇️
boa_ast/src/operations.rs 77.65% <0.00%> (-1.65%) ⬇️
boa_gc/src/cell.rs 63.84% <0.00%> (-0.57%) ⬇️
boa_gc/src/trace.rs 78.26% <0.00%> (-0.18%) ⬇️
boa_engine/src/builtins/promise/mod.rs 21.01% <0.00%> (-0.14%) ⬇️
boa_cli/src/helper.rs 0.00% <0.00%> (ø)
boa_macros/src/lib.rs 0.00% <0.00%> (ø)
boa_tester/src/main.rs 0.00% <0.00%> (ø)
... and 109 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

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

Looks good! I would replace the unwraps with expects describing why unwrapping is fine though.

@jedel1043 jedel1043 added execution Issues or PRs related to code execution Internal Category for changelog labels Dec 20, 2022
@jedel1043 jedel1043 added this to the v0.17.0 milestone Dec 20, 2022
Copy link
Member

@raskad raskad left a comment

Choose a reason for hiding this comment

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

Looks fine to me, but I'd say let's change the unwraps like @jedel1043 suggested to stick to our normal lint rules.

boa_profiler/src/lib.rs Outdated Show resolved Hide resolved
@jedel1043 jedel1043 requested a review from raskad December 21, 2022 03:09
Copy link
Member

@HalidOdat HalidOdat left a comment

Choose a reason for hiding this comment

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

Looks good to me! :)

@raskad
Copy link
Member

raskad commented Dec 27, 2022

bors r+

bors bot pushed a commit that referenced this pull request Dec 27, 2022
boa_profiler was allocating new strings every time even when they are the same string, which leads to a crash when `start_event` is called too much. This change updates the profiler to use a hash map cache and avoid duplicate string allocations.
@bors
Copy link

bors bot commented Dec 27, 2022

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title [profiler] Cache StringId [Merged by Bors] - [profiler] Cache StringId Dec 27, 2022
@bors bors bot closed this Dec 27, 2022
@tunz tunz deleted the tunz/profiler-cache-string branch July 18, 2023 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
execution Issues or PRs related to code execution Internal Category for changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants