Bug #107806 AIO systerm optimize
Submitted: 8 Jul 2022 3:22 Modified: 12 Aug 2022 11:40
Reporter: alex xing (OCA) Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S5 (Performance)
Version:8.0.19 OS:Any
Assigned to: CPU Architecture:Any

[8 Jul 2022 3:22] alex xing
Description:
 For AIO systerm, slot management relies on full scan, which is inefficient.
 In order to locate the slot which is working I/O or idle in the slot array quickly, and reduce the overhead of adding/removing I/O requests to the slot array, it is better to maintain the two type slot separately

How to repeat:
just read the code

Suggested fix:
add std::set<int> slot_set in AIO, which used to manage idle slot
[8 Jul 2022 3:25] alex xing
pseudo-code is as follows
void AIO::release(Slot *slot) {
    slot->is_reserved = false;

    int i = slot - at(0);
	//modify here
    slot_set.insert(i);

    --m_n_reserved;

    if (m_n_reserved == m_slots.size() - 1) {
        os_event_set(m_not_full);
    }

    if (m_n_reserved == 0) {
        os_event_set(m_is_empty);
    }
}

dberr_t AIO::init_slots() {
    for (ulint i = 0; i < m_slots.size(); ++i) {
        Slot& slot = m_slots[i];

        slot.pos = static_cast<uint16_t>(i);

        slot.is_reserved = false;
        //modify here
        slot_set.insert(static_cast<int>(i));
    }

    return DB_SUCCESS;
}

Slot* BosonAIO::reserve_slot(){
    //no need to full scan
    auto itup = slot_set.upper_bound(local_seg * slots_per_seg - 1);
    if (itup == slot_set.end()) {
        itup = slot_set.upper_bound(-1);
    }
    ut_a(itup != slot_set.end());
    ulint i = *itup;
    slot = at(i);
    slot_set.erase(itup);
}
[8 Jul 2022 3:28] alex xing
Slot* AIO::reserve_slot(){
    //no need to full scan
    auto itup = slot_set.upper_bound(local_seg * slots_per_seg - 1);
    if (itup == slot_set.end()) {
        itup = slot_set.upper_bound(-1);
    }
    ut_a(itup != slot_set.end());
    ulint i = *itup;
    slot = at(i);
    slot_set.erase(itup);
}
[8 Jul 2022 11:37] MySQL Verification Team
Hi Mr. xing,

Thank you for your performance improvement request.

We have analysed latest source code from 8.0.29 and 8.0.30 and your analysis, based on 8.0.19, is outdated.

First of all, we support native AIO on Linux and Windows. We do have added code for the platforms that do not support it.

Hence, you have to be very specific about which code are you actually referring to. Using several slots is native to some of the operating systems.

Also, code has been changed so much, that it seems that your request has been taken care of, already ...

We do require your feedback on our questions ....
[11 Jul 2022 1:55] alex xing
This optimization is for imulated-AIO
[11 Jul 2022 1:55] alex xing
This optimization is for simulated-AIO
[11 Jul 2022 11:50] MySQL Verification Team
Hi Mr. xing,

We think that this has been addressed in the 8.0.29 and 8.0.30 (yet to be released). Hence, if you could base your analysis on those sources, it would be appreciated.

Also, your code is based on an ancient release.
[12 Aug 2022 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".