From nobody Sun Feb 8 23:26:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613750104; cv=none; d=zohomail.com; s=zohoarc; b=APokzKEzOGRXU9FpNsiJmeRKSudu9V99H12Cd5KpYG/iVuwUmX19SI7/BdaUgN/ZXITJJds3w+tgndrn9aJOAFweyfMSbVrdV+0j5FGeTsXOcKZn9wWOVHBc7tYTTUczxAPxMsY3e4vtHyZCO/l1/e+9C+mGe58IqIf1bpSUb1U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613750104; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0JliDZ3ls2bkrNSVr9/bLLPFjYc7JAu0/9JzduJQrSI=; b=S6UI3BqZDI0QpKtenmNdzN3E1bk+Ht1iWNnhg7ieOZ5+tZeVJKG8xP9WzjuIZAVG5CDnyR6Z5zHM5DX4hk6A/Yd4gFxBjhBJeRA2a19Atj17DMJq3dez8d6BMCsJm4OWSznCUzZ5cmXyf97ROtoP8CBByXoRLAPRXnzzzDGIK3o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1613750103830104.38373312346516; Fri, 19 Feb 2021 07:55:03 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-544-2SeWUn72NzOmGe8UtnsChw-1; Fri, 19 Feb 2021 10:54:58 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 517F0192FDA2; Fri, 19 Feb 2021 15:54:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0921F60BE5; Fri, 19 Feb 2021 15:54:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A4FE218095C7; Fri, 19 Feb 2021 15:54:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11JFrS1m007594 for ; Fri, 19 Feb 2021 10:53:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id E83201971D; Fri, 19 Feb 2021 15:53:28 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DDD81970D for ; Fri, 19 Feb 2021 15:53:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613750101; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=0JliDZ3ls2bkrNSVr9/bLLPFjYc7JAu0/9JzduJQrSI=; b=br5n0TfYqSU+loJ93tT/lz/qIplj/kLCmRpzkWPfpG0bP3vXKEfMmEqQnAQvHVb9Jdr/eh SdZf61SYIaet3X6ip2JkMyF8VYnFeYG0RiMtCNnZLSB8X9vjnof9iNo1cuWy2wmrrPYsvG hAPKW8RCkJ+/ZDTXgJEWSzuyr2CbOVo= X-MC-Unique: 2SeWUn72NzOmGe8UtnsChw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/4] qemuxml2argvtest: Cache QAPI schema between tests Date: Fri, 19 Feb 2021 16:53:18 +0100 Message-Id: <8f5418f2981d4f240967197df5bc2ea47161544d.1613749935.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" It's quite wasteful to reparse the QAPI schema for each _CAPS_ test. Add a simple cache filled lazily by encountered schemas. The time saving on my box is quite significant: real 0m3.318s user 0m3.203s sys 0m0.107s vs real 0m2.223s user 0m2.134s sys 0m0.084s Signed-off-by: Peter Krempa --- tests/qemuxml2argvtest.c | 17 ++++++++++++++--- tests/testutilsqemu.h | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index db438c5466..647187404c 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -523,13 +523,22 @@ testCompareXMLToArgvValidateSchema(virQEMUDriverPtr d= rv, qemuDomainObjPrivatePtr priv =3D NULL; size_t nargs =3D 0; size_t i; - g_autoptr(GHashTable) schema =3D NULL; + GHashTable *schema =3D NULL; g_autoptr(virCommand) cmd =3D NULL; unsigned int parseFlags =3D info->parseFlags; bool netdevQAPIfied =3D false; - if (info->schemafile) - schema =3D testQEMUSchemaLoad(info->schemafile); + if (info->schemafile) { + /* lookup and insert into cache if not found */ + if (!g_hash_table_lookup_extended(info->qapiSchemaCache, + info->schemafile, + NULL, (void **) &schema)) { + schema =3D testQEMUSchemaLoad(info->schemafile); + g_hash_table_insert(info->qapiSchemaCache, + g_strdup(info->schemafile), + schema); + } + } /* comment out with line comment to enable schema checking for non _CA= PS tests if (!schema) @@ -779,6 +788,7 @@ mymain(void) int ret =3D 0; g_autofree char *fakerootdir =3D NULL; g_autoptr(GHashTable) capslatest =3D NULL; + g_autoptr(GHashTable) qapiSchemaCache =3D virHashNew((GDestroyNotify) = virHashFree); fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); @@ -872,6 +882,7 @@ mymain(void) static struct testQemuInfo info =3D { \ .name =3D _name, \ }; \ + info.qapiSchemaCache =3D qapiSchemaCache; \ if (testQemuInfoSetArgs(&info, capslatest, \ __VA_ARGS__, ARG_END) < 0) \ return EXIT_FAILURE; \ diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index 0c6f0ea378..86ba69e96b 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -66,6 +66,7 @@ struct testQemuInfo { unsigned int parseFlags; virArch arch; char *schemafile; + GHashTable *qapiSchemaCache; }; virCapsPtr testQemuCapsInit(void); --=20 2.29.2