Comment 7 for bug 2052419

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to neutron (stable/2023.2)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/908586
Committed: https://opendev.org/openstack/neutron/commit/aad8dd867744cee76ec90b314bea70989ca8cae9
Submitter: "Zuul (22348)"
Branch: stable/2023.2

commit aad8dd867744cee76ec90b314bea70989ca8cae9
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Thu Feb 8 21:56:06 2024 +0000

    Change SG rules backref load method to "joined"

    Since [1], we introduced a way to skip the load of the OVO synthetic
    fields depending on the resource fields retrieved. In the case of the
    security groups (SG), the SG rules are child objects to the SGs. The SG
    rules are retrieved when a SG OVO is created.

    The improvement done in [1] is to make the SG rules load dynamically,
    that means using the load mode "lazy='dynamic'". That will issue a SQL
    query only if the SG rules are read; if not, the query is never issued.

    However since [2] (and this is previous to the [1] optimization), we
    always add the field "shared" to the filters and thus to the fields to
    retrieve, because it is a policy required field. Because "shared" is a
    synthetic field [3], that will force the SG "synthetic_fields" load and
    the retrieval of the SG rules always. This is undoing any performance
    improvement.

    This patch is changing the loading method to "joined"; that will request
    the SG rules in the same SQL query, instead of issuing separate queries
    for the SG rules. Until a method to load the SG "shared" field,
    independently of the synthetic OVO fields is implemented, this change
    will improve the SG retrieval performance. In a testing environment
    with around 5500K SG and 4 rules (default ones) per SG:
    * lazy='dynamic': 38 seconds
    * lazy='select': 20 seconds
    * lazy='joined': 12 seconds

    [1]https://review.opendev.org/q/topic:%22bug/1810563%22
    [2]https://review.opendev.org/c/openstack/neutron/+/328313
    [3]https://github.com/openstack/neutron/blob/b85b19e3846fa74975ba5d703336b6e7cd8af433/neutron/objects/rbac_db.py#L349

    Related-Bug: #2052419
    Change-Id: I300464472f2348d148f2a3ddac384c883d9d815b
    (cherry picked from commit 52662cad7a07f9bb3b954366eeccd9795ae21503)