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 1rotdg-003xru-2C for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Mar 2024 23:22: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 1rotde-0093fJ-Mi for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Mar 2024 23:21:59 +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 1rotde-0093KS-DK for pgsql-hackers@lists.postgresql.org; Mon, 25 Mar 2024 23:21:58 +0000 Received: from mail-qv1-xf2d.google.com ([2607:f8b0:4864:20::f2d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rotdW-006QBZ-W5 for pgsql-hackers@lists.postgresql.org; Mon, 25 Mar 2024 23:21:57 +0000 Received: by mail-qv1-xf2d.google.com with SMTP id 6a1803df08f44-690e2d194f6so34765816d6.0 for ; Mon, 25 Mar 2024 16:21:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1711408911; x=1712013711; 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=v48D6gGPMygcOZLk7sqTnGnoNQFnkpLsqif5Po/1r/8=; b=M7RxBv0dq0mJ1gvJy08yFukBPnzI/SGMQgeI2pWxpkOybRw+5sIN2HudgvMTLvsRTS XiYzQlFNdfXqEiAHDjTDShe/Z9D+Qr89lnVTEcHFuSj50SNdnhv2VYx9nJRD53IkgpPh WFpn/yvVtKTGhmkBnkE12fzfxRBKLIgg3XIFf3eaTpP6UGEnpvdMsinCDNfbv5uG1YVK sd4eVV2DoG8NMtYPj51ALXsAdoiU/zE1JVeDtm3QCugGwWygq2XFQWWIl+Ag2ECpZOlu yirckE18L03txcD996LSITTe+3RRhDxVaMQdS2hZOOcYI6Oxh2+EEuPtcPFsOQ3EVxF/ 9fWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711408911; x=1712013711; 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=v48D6gGPMygcOZLk7sqTnGnoNQFnkpLsqif5Po/1r/8=; b=XsHrBp3JeCtUYgxko1ay1+g3WjykqqVVCcOq49AsAlINGisJ1UIA4gJHmiEJEtzYOS rSSGm94ANXHDqXYf+w5l++OSNjEG+glS6vGJ2lOPayY9q8ukxpbeS6uKl5BhzWR2Pfnt 8Uewv5GVHrULN7MHna2MzHKxFTNvDCL5mAgiMYPLm6Ksg11k0ZJX0y8KFXidN+AuJeEe ynpLwzebhzb8KkHU8frIrAtqxojXxUkIYffWwDkVfeoVRnLlPU+ivR4hs+lMXkgowaEo AHht31lefAGP7DtY4qMXroee2uZHjs+StYxdq1q+jVl0NUfW25qnWFd/SezHrMSykwD5 Ladg== X-Forwarded-Encrypted: i=1; AJvYcCXCuIfFbjt7mkzZ/MuvhB6FOs1zNjJKCMjqoRezi4crmttM+L9swmQzb99zpdyVv6QbYnZ/IKTD5JY+ZGyp1FDH8/v/WDO2vzaOJZtdQN8+SHPA X-Gm-Message-State: AOJu0YxQ7nR+AQlQz9WkZmbNlrLqxUnIxcOGciut+pSO6WOyEHCKiB+N pujBk3cA1Zr6S4VgZIZwy2hIw4mLQzQA8owBPz9p7KNiqhnl8V3rx+8I/cW6d0KvN3KNBhmSvIW 3xvQ4SPCFIq4YGzNFx9ZGThUJq3TEIm7XCuaC X-Google-Smtp-Source: AGHT+IGfYvibU6yT9qo7QiMJGHTuPYRKDR2RAFPZj3LWTG0CI64GYm5gl8YqWKXwHDUwfvUVgYw94001BEwdFJyJ7qU= X-Received: by 2002:a05:6214:e89:b0:696:801a:9864 with SMTP id hf9-20020a0562140e8900b00696801a9864mr8827608qvb.13.1711408911126; Mon, 25 Mar 2024 16:21:51 -0700 (PDT) MIME-Version: 1.0 References: <7b0a51d6-0d9d-7366-3a1a-f74397a02f55@dunslane.net> <3892d996-0ec8-3a56-1a6c-b397a3c31516@dunslane.net> <3efe8333-3285-1d9d-5ad3-0f9784d5c1c4@dunslane.net> <1778cdac-bb93-5bbd-1505-5684e95b0094@dunslane.net> <1b30469a-9d29-c021-f28a-74e248760aa4@dunslane.net> <682c8fff-355c-a04f-57ac-81055c4ccda8@dunslane.net> <70705cf3-c875-d489-c6a9-7dd61f1dc1af@dunslane.net> <694fd815-0414-0f09-98b3-db28d77fa37f@dunslane.net> In-Reply-To: From: Jacob Champion Date: Mon, 25 Mar 2024 16:21:40 -0700 Message-ID: Subject: Re: WIP Incremental JSON Parser To: Andrew Dunstan Cc: Robert Haas , Peter Smith , 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 Mon, Mar 25, 2024 at 4:12=E2=80=AFPM Jacob Champion wrote: > Stack size should be pretty limited, at least on the platforms I'm > familiar with. So yeah, the recursive descent will segfault pretty > quickly, but it won't repalloc() an unbounded amount of heap space. > The alternative would just be to go back to a hardcoded limit in the > short term, I think. And I should mention that there are other ways to consume a bunch of memory, but I think they're bounded by the size of the JSON file. Looks like the repalloc()s amplify the JSON size by a factor of ~20 (JS_MAX_PROD_LEN + sizeof(char*) + sizeof(bool)). That may or may not be enough to be concerned about in the end, since I think it's still linear, but I wanted to make sure it was known. --Jacob