[MDEV-6152] Remove calls to current_thd while creating Item Created: 2014-04-22  Updated: 2015-09-01  Resolved: 2015-08-28

Status: Closed
Project: MariaDB Server
Component/s: Parser
Fix Version/s: 10.1.7

Type: Task Priority: Minor
Reporter: Michael Widenius Assignee: Michael Widenius
Resolution: Fixed Votes: 0
Labels: performance

Issue Links:
PartOf
includes MDEV-8010 Avoid sql_alloc() in Items Closed
Epic Link: Performance: micro optimizations
Sprint: 10.1.7-2

 Description   

current_thd() is called many times while creating Items (in many cases 2 or more calls per item).

The problem is not only the number of calls to current_thd(), but also that when we create items we cause more calls, like calling sql_alloc() that calls current_thd and then uses this to call alloc_root() with the right argumetns.

By adding thd as an argument to all functions that creates Items, we can avoid most calls to current_thd(). We can also call alloc_root() directly instead of calling it trough sql_alloc().

Changes in the code as part of this task:

  • Add THD as an argument to all functions that creates an Item.
  • Replace 'new Item_xxx' with 'new (thd->memroot) Item_xxx
  • Add thd->memroot as an argument to push_back() and push_front() for lists.

Before adding this to 10.1 code base, we need to benchmark the result to see that this big change is really worth it.



 Comments   
Comment by Michael Widenius [ 2015-08-28 ]

Pushed into 10.1

Generated at Thu Feb 08 07:09:45 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.