qxo opened a new pull request #3175: improve ContextCarrier: reduce unnecessary 
object creation -- reduce gc
URL: https://github.com/apache/skywalking/pull/3175
 
 
   Please answer these questions before submitting pull request
   
   - Why submit this pull request?
   - [ ] Bug fix
   - [ ] New feature provided
   - [x] Improve performance
   
   - Related issues
   
   ___
   ### Bug fix
   - Bug description.
   
   - How to fix?
   
   ___
   ### New feature or improvement
   - Describe the details and related test reports.
   improve ContextCarrier: reduce unnecessary object creation -- reduce gc
   sample and benchmark at ContextCarrierBenchmark
   provider two version:
   ```
    final Map<String, String> headers = getHeaders();
           ContextCarrier contextCarrier =  null;
           CarrierItem next = ContextCarrier.topItem(null);
           do {
               final String headKey = next.getHeadKey();
               final String hv = headers.get(headKey);
               if (hv == null) {
                   continue;
               }
               next.setHeadValue(hv, contextCarrier == null ? contextCarrier = 
new ContextCarrier() : contextCarrier);
               headers.remove(headKey);
           } while ((next = next.next()) != null);
           
           withSpan(contextCarrier);
   ```
   and 
   ```
           final Map<String, String> headers = getHeaders();
           ContextCarrier contextCarrier =  null;
           final HeaderVersion[] headerNames = 
ContextCarrier.getHeaderVersions();
           for (final ContextCarrier.HeaderVersion h : headerNames) {
               final String headKey = h.getHeadKey();
               final String hv = headers.get(headKey);
               if (hv == null) {
                   continue;
               }
               if (contextCarrier == null) {
                   contextCarrier =  new ContextCarrier();
               }
               contextCarrier.deserialize(hv, h);
               headers.remove(headKey);
           } 
   
   ``
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to