Stop creating and destroying unnecessary vectors in checkAndAssertTypes

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • 7.3.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • Repl 2023-11-13, Repl 2023-11-27
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The IDL parser generator produces code of the form var.checkAndAssertTypes("Context", {BSONType1, BSONType2, ...}) , i.e. it produces code where a BSONType[] is passed to checkAndAssertTypes(). However, since this function expects a vector, the BSONType[] is repeatedly converted to a vector and then destroyed right after the function call.

      Instead we can pass in pointers and make this a lot quicker to avoid many allocations and frees.

      In the attached screenshots, the functions highlighted in purple represent amount of time spent doing this. The more elaborate screenshot is from a debug build, and there we see that the construction & destruction of vectors take about 40% of parse time. In the opt=on build, the construction & destruction take 20% of the total time

            Assignee:
            Vishnu Kaushik
            Reporter:
            Vishnu Kaushik
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: