dferstay opened a new pull request #316:
URL: https://github.com/apache/pulsar-client-go/pull/316


   An int occupies one word of memory; on 64-bit machines, this is 8 bytes.
   
   As a result, the messageID struct is 56-bytes:
   * ledgerID - 8 bytes
   * entryID - 8 bytes
   * batchIdx - 8 bytes
   * partitionIdx - 8 bytes
   * tracker - 8 bytes
   * consumer - 16 bytes (1 word for type, 1 word for data address)
   
   This commit changes the type batchIdx and partitionIdx fields to int32,
   which saves one word of memory and maintains alignment of struct fields.
   
   Reducing the size of the MessageID structs is important as they are
   currently allocated on the heap for every message produced or consumed.
   
   Signed-off-by: Daniel Ferstay <dfers...@splunk.com>
   
   <--
   ### Contribution Checklist
     
     - Name the pull request in the form "[Issue XYZ][component] Title of the 
pull request", where *XYZ* should be replaced by the actual issue number.
       Skip *Issue XYZ* if there is no associated github issue for this pull 
request.
       Skip *component* if you are unsure about which is the best component. 
E.g. `[docs] Fix typo in produce method`.
   
     - Fill out the template below to describe the changes contributed by the 
pull request. That will give reviewers the context they need to do the review.
     
     - Each pull request should address only one issue, not mix up code from 
multiple issues.
     
     - Each commit in the pull request has a meaningful commit message
   
     - Once all items of the checklist are addressed, remove the above text and 
this checklist, leaving only the filled out template below.
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ### Motivation
   
   The motivation is to reduce the amount of heap allocated memory for each 
message produced and consumed.
   
   ### Modifications
   
   This commit changes the type batchIdx and partitionIdx fields to int32,
   which saves one word of memory and maintains alignment of struct fields.
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   This change is already covered by existing tests that produce or consume 
messages.
   
   ### Does this pull request potentially affect one of the following parts:
   
   *If `yes` was chosen, please highlight the changes*
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API: no
     - The schema: no
     - The default values of configurations: no
     - The wire protocol: no
   
   ### Documentation
   
     - Does this pull request introduce a new feature? no
   


----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to