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 1rL4XA-005xfe-Hb for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Jan 2024 16:56:00 +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 1rL4X9-006cgZ-1i for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Jan 2024 16:55:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rL4X8-006cg0-JH for pgsql-hackers@lists.postgresql.org; Wed, 03 Jan 2024 16:55:58 +0000 Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rL4X0-00FMhu-RF for pgsql-hackers@lists.postgresql.org; Wed, 03 Jan 2024 16:55:57 +0000 Received: by mail-qk1-x730.google.com with SMTP id af79cd13be357-7815547f2c5so445651385a.3 for ; Wed, 03 Jan 2024 08:55:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunslane-net.20230601.gappssmtp.com; s=20230601; t=1704300948; x=1704905748; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=tYeVmXqNzPGWoiqK3HSXvUtcdz+Juzoaa/nj18YdxuU=; b=efzAQTbOIKj/yGVVIHbdi4jzPg8M0yuLU9nXTS4i7t1KzSdy46LEVtflknMImPAz1W 56P76qW+h4TlIcwNakr/u07zKUfNKKDCTSQ8PYMNnTshnt10YZKUIIP9AZwJ5bA6MHt7 w7dsSAmKaJ1oXOwikx1lJI7ZfSNZSSMHbsQhuRswEg08eGYFIb265esSLrV1MzSEmID1 CyDYzbIrWV8rWHkzemHtcBVU+xXepJRDgvTc87jILUstHa5ROMozEW7eB9Ka1p0uuLP9 Kiydjw1U0FplI6KCl17StzS03sAkqcbMbf5cn+yhN4qLlpeA5JQG8ND8JMiyzAg5i6X1 JOZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704300948; x=1704905748; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=tYeVmXqNzPGWoiqK3HSXvUtcdz+Juzoaa/nj18YdxuU=; b=m//5kS44XQSLeRtLffwZDp+B2J7wYDm5JJkxM39an6zG0fxUHROOjr0ej+ajmWLxKj Bbo+qmX6Vybwn7c7UksRNBfcDpSO9+RLwnXzM0e0ZK6YTVGTh/wlYXG0NzSqfos7MK9R OhjFqHegO1Pj0CNmkZiSUqGL8aagkut6OeTlG2d7u6F0PnsFZX7rDe6DYL4mKg1Q9jfq 0PBwSvlskt3thAM8KVT21kueZzkV97cZMpl77NkdAJK/nH81LdOK+LBvUGeiWF9/KvXO 9mQst9Bme8PHn3FAHrKCuiBWww6jMtC8rpxA6inAJHO41xUq6RahdkaV0IKdA0bj0YUX EJpg== X-Gm-Message-State: AOJu0YxrmOJHGCykZ+u7+DAkqoiPPHw9mnXUVPSYlfLACEZn23DcFFSM vm0nCjzT+71WmymKdw2O2tTZaNgTwfFp2QYwmQvkEnjQe+k= X-Google-Smtp-Source: AGHT+IF4fQ07NTk4S7bhzccWDKDCI44pj6V/5J2u4Nviknqu0doFH64sjqEuj/7ytTdZVMj6+26T8g== X-Received: by 2002:a05:620a:51cc:b0:781:d09a:f9e0 with SMTP id cx12-20020a05620a51cc00b00781d09af9e0mr2967167qkb.123.1704300948544; Wed, 03 Jan 2024 08:55:48 -0800 (PST) Received: from ?IPV6:2605:a601:91f3:1900::2bb? ([2605:a601:91f3:1900::2bb]) by smtp.googlemail.com with ESMTPSA id bk2-20020a05620a1a0200b0077d7cfde46csm10342961qkb.106.2024.01.03.08.55.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 03 Jan 2024 08:55:48 -0800 (PST) Message-ID: <4c6cc0e1-b002-877b-c623-6c72dbcbdd8b@dunslane.net> Date: Wed, 3 Jan 2024 11:55:47 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: WIP Incremental JSON Parser Content-Language: en-US To: Robert Haas Cc: PostgreSQL Hackers References: <7b0a51d6-0d9d-7366-3a1a-f74397a02f55@dunslane.net> <253cef9e-1360-a1a6-5091-ad4368b1b8cc@dunslane.net> <58987a44-878a-338b-31de-4543c90604f1@dunslane.net> From: Andrew Dunstan In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-01-03 We 10:12, Robert Haas wrote: > On Wed, Jan 3, 2024 at 9:59 AM Andrew Dunstan wrote: >> Say we have a document with an array 1m objects, each with a field >> called "color". As it stands we'll allocate space for that field name 1m >> times. Using a hash table we'd allocated space for it once. And >> allocating the memory isn't free, although it might be cheaper than >> doing hash lookups. >> >> I guess we can benchmark it and see what the performance impact of using >> a hash table might be. >> >> Another possibility would be simply to have the callback free the field >> name after use. for the parse_manifest code that could be a one-line >> addition to the code at the bottom of json_object_manifest_field_start(). > Yeah. So I'm arguing that allocating the memory each time and then > freeing it sounds cheaper than looking it up in the hash table every > time, discovering it's there, and thus skipping the allocate/free. > > I might be wrong about that. It's just that allocating and freeing a > small chunk of memory should boil down to popping it off of a linked > list and then pushing it back on. And that sounds cheaper than hashing > the string and looking for it in a hash bucket. OK, cleaning up in the client code will be much simpler, so let's go with that for now and revisit it later if necessary. cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com