- 
                Notifications
    You must be signed in to change notification settings 
- Fork 15k
[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
  
    1a9b251    to
    dba238e      
    Compare
  
    bd084ea    to
    735490e      
    Compare
  
    cb29414    to
    f36f86e      
    Compare
  
    5c872a1    to
    cbc1f38      
    Compare
  
    8401695    to
    df30efc      
    Compare
  
    3d520d8    to
    3e3e4ea      
    Compare
  
    1e2990f    to
    c6534b6      
    Compare
  
    709be29    to
    537d1d7      
    Compare
  
    c6534b6    to
    bfe51da      
    Compare
  
    537d1d7    to
    fbaaa82      
    Compare
  
    0230277    to
    d6ce86b      
    Compare
  
    fbaaa82    to
    a69791c      
    Compare
  
    d6ce86b    to
    ee52188      
    Compare
  
    a69791c    to
    4aa6943      
    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%
4aa6943    to
    3338a34      
    Compare
  
    ee52188    to
    9808298      
    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.