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

faster String allocation #29254

Merged
merged 1 commit into from
Oct 1, 2018
Merged

faster String allocation #29254

merged 1 commit into from
Oct 1, 2018

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Sep 18, 2018

Only a few % difference in performance measurements (the majority of time is usually spent in examining the current state of the pool), but this essentially removes the cost of computing the sizeclass, so it should save on processor resources (frontend, BTP) especially.

I'm also hoping this will help unstick #21959, since it makes changing the size classes easy.

only a few %, but essentially removes the cost of computing the sizeclass,
so this should save on processor resources (frontend, BTP) also
@vtjnash vtjnash requested a review from yuyichao September 18, 2018 17:53
@@ -476,7 +477,8 @@ JL_DLLEXPORT jl_value_t *jl_pchar_to_string(const char *str, size_t len)

JL_DLLEXPORT jl_value_t *jl_alloc_string(size_t len)
{
jl_value_t *s = jl_gc_alloc(jl_get_ptls_states(), sizeof(size_t)+len+1, jl_string_type);
size_t sz = sizeof(size_t) + len + 1; // add space for trailing \nul protector and size
jl_value_t *s = jl_gc_alloc_(jl_get_ptls_states(), sz, jl_string_type); // force inlining
Copy link
Member

Choose a reason for hiding this comment

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

These are starting to get fairly repetitive. Maybe factor out into a common subroutine?

Copy link
Member Author

Choose a reason for hiding this comment

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

there's only two of them, so it's not worthwhile

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, this method technically is that common subroutine. The code is duplicated in jl_pchar_to_string for performance.

@vtjnash
Copy link
Member Author

vtjnash commented Sep 19, 2018

@nanosoldier runbenchmarks(ALL, vs=":master")

@nanosoldier
Copy link
Collaborator

Something went wrong when running your job:

NanosoldierError: failed to run benchmarks against comparison commit: failed process: Process(`/home/nanosoldier/workdir/tmp4OzZOM/julia -e 'VERSION >= v"0.7.0-DEV.3656" && using Pkg; Pkg.update()'`, ProcessExited(1)) [1]

Logs and partial data can be found here
cc @ararslan

@JeffBezanson
Copy link
Member

@nanosoldier runbenchmarks(ALL, vs=":master")

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

@vtjnash
Copy link
Member Author

vtjnash commented Sep 26, 2018

Why would this affect allocation numbers? Are those tests known to be flaky, or did I mess up the size-class computation (either old or new)?

@vtjnash
Copy link
Member Author

vtjnash commented Sep 28, 2018

@nanosoldier runbenchmarks("collection" || "micro" || "misc" || "problem", vs=":master")

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

@vtjnash
Copy link
Member Author

vtjnash commented Oct 1, 2018

Double-checked the formula, and confirmed the old one was slightly offset, leading to larger allocations than necessary in some rare cases. So we'll add to the benefits of this PR that the size-classes are also now computed correctly 😜.

@vtjnash vtjnash merged commit e721d35 into master Oct 1, 2018
@vtjnash vtjnash deleted the jn/faster-String-alloc branch October 1, 2018 15:53
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.

5 participants