Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rL1Yl-005fhk-4b for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Jan 2024 13:45:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rL1Yh-005Rt2-Pw for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Jan 2024 13:45:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rL1Yh-005Rs9-FT for pgsql-hackers@lists.postgresql.org; Wed, 03 Jan 2024 13:45:23 +0000 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rL1Ye-00DXUh-HR for pgsql-hackers@lists.postgresql.org; Wed, 03 Jan 2024 13:45:21 +0000 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-a235eb41251so1178983566b.3 for ; Wed, 03 Jan 2024 05:45:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704289519; x=1704894319; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=32VdS2M02V+heAkXKajUSArgk4RDRWe9pvRwYjWrF0Y=; b=mBJ0mbv0uiaXpzrdC/CYcoN9D7RqvZSuzeTZaP9XEbeO9aZULSspaStt36dkVNIDmw j5N9MJdEbQTWUxsCxfNX3VVzk3rKDQddExOFs3AyKg3ob2wlJbzLD3sIUfrc0iSHa0IZ DGHqYUsEjAWJqUrKa2GXh4pgc2OOgQAvKxciUOeMkb7o7SvndJUIMnApIDO5Vo2zo9tb FoBfDTnOiuv+8QViBcPqa5VEK/Iw+JjHROLr9wz5JgWKlo+mz8PIlCGH3KACiylN8TaX NJmUnlCPepCgJWzf7648uHCtRt0U9jWoxNLysNLOJJm/EsG+jd3m3qWF/UnRMDsXeShN OVyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704289519; x=1704894319; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=32VdS2M02V+heAkXKajUSArgk4RDRWe9pvRwYjWrF0Y=; b=a/5UwEqHAXMoD7n4GSGTBgbKKbCXtMO4tJzdSHwhumw5SYYvY9YM0b9yhdlTXp8PDt DUb1LY8SQ38yOczNZ23OoYGDzcs6I9kK8q8hC7MLrplromMJd1XevVj2hylzGKHQ0M13 lAbGwrBKPtEGWoYWDBKuTIkPjuQsYLRk9syUze/8gea7CHBvSSAe05+VZSx2F0GLHhTq zK56Zs8+af9kIbuUnKj/tS6Y5m74qUUJumdwi5WzSxTnIjjvtr1ED6u4um6qnamNSl9x 3gYKm7qZGJMMOtJ9ks+rTl7ODSC/PBolS/BUh4m3ctPE8/PqzoskHlvXmACj1qyWB4ch FOKA== X-Gm-Message-State: AOJu0YzYwz604rNE82QcMRD3RO7hUnfQueM7Htl/nJ00hTOZHq0uyPxF a3HRDsPZYjMjaWwmvpemBmd+0NTl9KRQ09rukLs= X-Google-Smtp-Source: AGHT+IFMjMyGngOj+L6E5Njt/YNi3KWFGQgCSeImfEV2uXlOjsAEmb0XjsX69eF8DY4mwXTFo3gnzJ/gA/b9zVr+jcQ= X-Received: by 2002:a17:906:fd8b:b0:a28:6317:ceb3 with SMTP id xa11-20020a170906fd8b00b00a286317ceb3mr1044785ejb.7.1704289518576; Wed, 03 Jan 2024 05:45:18 -0800 (PST) MIME-Version: 1.0 References: <7b0a51d6-0d9d-7366-3a1a-f74397a02f55@dunslane.net> <253cef9e-1360-a1a6-5091-ad4368b1b8cc@dunslane.net> In-Reply-To: <253cef9e-1360-a1a6-5091-ad4368b1b8cc@dunslane.net> From: Robert Haas Date: Wed, 3 Jan 2024 08:45:06 -0500 Message-ID: Subject: Re: WIP Incremental JSON Parser To: Andrew Dunstan Cc: PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jan 3, 2024 at 6:57=E2=80=AFAM Andrew Dunstan = wrote: > Yeah. One idea I had yesterday was to stash the field names, which in > large JSON docs tent to be pretty repetitive, in a hash table instead of > pstrduping each instance. The name would be valid until the end of the > parse, and would only need to be duplicated by the callback function if > it were needed beyond that. That's not the case currently with the > parse_manifest code. I'll work on using a hash table. IMHO, this is not a good direction. Anybody who is parsing JSON probably wants to discard the duplicated labels and convert other heavily duplicated strings to enum values or something. (e.g. if every record has {"color":"red"} or {"color":"green"}). So the hash table lookups will cost but won't really save anything more than just freeing the memory not needed, but will probably be more expensive. > The parse_manifest code does seem to pfree the scalar values it no > longer needs fairly well, so maybe we don't need to to anything there. Hmm. This makes me wonder if you've measured how much actual leakage there = is? --=20 Robert Haas EDB: http://www.enterprisedb.com