-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[llvm][mustache] Avoid redundant saves in accessor splitting #159197
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
base: users/ilovepi/mustache-tokeniser-opt
Are you sure you want to change the base?
[llvm][mustache] Avoid redundant saves in accessor splitting #159197
Conversation
@llvm/pr-subscribers-llvm-support Author: Paul Kirth (ilovepi) ChangesThe splitMustacheString function was saving StringRefs that This optimization provides a small but measurable performance
Full diff: https://github.com/llvm/llvm-project/pull/159197.diff 1 Files Affected:
diff --git a/llvm/lib/Support/Mustache.cpp b/llvm/lib/Support/Mustache.cpp
index 63798c50f57ee..fcb55c4edd815 100644
--- a/llvm/lib/Support/Mustache.cpp
+++ b/llvm/lib/Support/Mustache.cpp
@@ -52,7 +52,7 @@ static Accessor splitMustacheString(StringRef Str, MustacheContext &Ctx) {
std::tie(Part, Str) = Str.split('.');
// Each part of the accessor needs to be saved to the arena
// to ensure it has a stable address.
- Tokens.push_back(Ctx.Saver.save(Part.trim()));
+ Tokens.push_back(Part.trim());
}
}
// Now, allocate memory for the array of StringRefs in the arena.
|
b2db0c9
to
b68de04
Compare
3ac408e
to
b929e27
Compare
1acd655
to
bd084ea
Compare
b929e27
to
1a9b251
Compare
The splitMustacheString function was saving StringRefs that were already backed by an arena-allocated string. This was unnecessary work. This change removes the redundant Ctx.Saver.save() call. This optimization provides a small but measurable performance improvement on top of the single-pass tokenizer, most notably reducing branch misses. Metric | Baseline | Optimized | Change -------------- | -------- | --------- | ------- Time (ms) | 35.77 | 35.57 | -0.56% Cycles | 35.16M | 34.91M | -0.71% Instructions | 85.77M | 85.54M | -0.27% Branch Misses | 113.9K | 111.9K | -1.76% Cache Misses | 237.7K | 242.1K | +1.85%
1a9b251
to
dba238e
Compare
bd084ea
to
735490e
Compare
The splitMustacheString function was saving StringRefs that
were already backed by an arena-allocated string. This was
unnecessary work. This change removes the redundant
Ctx.Saver.save() call.
This optimization provides a small but measurable performance
improvement on top of the single-pass tokenizer, most notably
reducing branch misses.