Skip to content

Improve the insert performance in the server #75

Open

Description

@vaibhav-kaushal

We are performing way too many allocations in the StartWritingLogs function in the server log writer file. We need to optimize that so that high bursts of incoming log traffic could be ingested. Things we can try:

  1. We can move the code in the BarkLogDao.InsertBatch function to the StartWritingLogs function - that should avoid the memory copy required for making the function call and the memory allocations happening inside the InsertBatch function.
  2. We can allocate a variable for large, medium and small batches. These should be arrays instead of slices so that the loop does not have to reallocate the slice on append.

Activity

  1. added this to the Version 1.2 milestone on Oct 19, 2023
  2. itishrishikesh commented on Oct 26, 2023

    @itishrishikesh
    Contributor

    working on this

  3. bhagatvansh commented on Oct 26, 2023

    @bhagatvansh
    Contributor

    Great, do you wanna collaborate on this? Seems like a good issue to work on.

  4. itishrishikesh commented on Oct 27, 2023

    @itishrishikesh
    Contributor

    Sure @bhagatvansh! Created a draft PR of the solution that I thought of, let me know what you think

  5. bhagatvansh commented on Oct 27, 2023

    @bhagatvansh
    Contributor

    Sure, did you compare the memory performance?

  6. itishrishikesh commented on Oct 27, 2023

    @itishrishikesh
    Contributor

    @bhagatvansh Hadn't done it before, but checked just now, here's what I found,
    The right side figures are the code on the main branch, and the left one is what I have written.
    image

    One weird thing is, for small batch size when we were creating multiple slices with append the difference between allocations are huge when compared with new code, but for medium and large size logs the difference is negligible, but still it's a little less.

    I have added a test files, you can run the tests on your end once to verify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions