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 1uU5S3-00FLzE-FI for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Jun 2025 15:20:47 +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 1uU5S1-00D1GA-FH for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Jun 2025 15:20:46 +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 1uU5S1-00D1G1-5h for pgsql-hackers@lists.postgresql.org; Tue, 24 Jun 2025 15:20:45 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uU5Rz-003qWI-2p for pgsql-hackers@postgresql.org; Tue, 24 Jun 2025 15:20:45 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-54b10594812so5512633e87.1 for ; Tue, 24 Jun 2025 08:20:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750778441; x=1751383241; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=lyJrgK3Nsy24UW14mvCj911czzpdkZcEqjiUDVlnxNo=; b=iMeIepn8iCMwcd+SgzixquSftDDtkJIJav5mesM7CHEQ8o8hEmzYFI8bNK342sWbAc cwbnLte9eMZnpGG05T0cU4/mJTxq0zYjaS61yxmTjQ+tOttrFqtvNT25jj8fN0udq1E3 FQ6QlS6gOXsvEYKKzZWsmDKjC4M7zWc97a9fNwfU9CxYbM5UCLIIibsj3DGPSNMHC1Li MDjAbIKwnWXcz8F2RXV4kALAoiaLIKaiMxVUzl+YT8QAUVv2hTyH973qQYg/LDaSgjtv y1Hxjko6vpTZwZlMINXZUAIoXq9gwO29KtaNWHm3Erh43NfuRcy2tGP8bIt3ACo8hjqg aXOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750778441; x=1751383241; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lyJrgK3Nsy24UW14mvCj911czzpdkZcEqjiUDVlnxNo=; b=hH/1dq5DPwR529pEiwcMDsRRGsE0IKBBcWKPGNHXKjZvRkLFbNRKMpkhddU0Lxtw85 sKd3RM16FXSnSy0cSd23ICVszznu/OKrKLed6WR/7bSy2gOrZG8BvCyeLxJ9utKFyYS4 +7AKFfJtgnYbpLPBtnoHaXu1TZgu+WgSr5IZtLSCHnWAtsjI5gGNi/I+6tWY/04QYdRF 8ZCP12auN0+0pTi8YmnJqKGVszIndNIukH7xpFyKAUnkc5BaBZ84PL+7IKJ9LnQYTDOe W8oLS5Idd9jCR+F+0+sPPZ+HerOK1e2lSQPH+TIBnqpb3YAAt7sjHcgdBibTFR+sDDI/ q0Jg== X-Forwarded-Encrypted: i=1; AJvYcCW/BgMlssJemg5vzhNaQKRScj0jLu0WY0+rV8nhw4IciunzsYrnWr2lm7yCiUwon7g9zIg8rhfkDy4q/FR4@postgresql.org X-Gm-Message-State: AOJu0YwgfhIwI/sBklLC0cDdiBTNr5BLf1yPaPMrfheWZamwkbyaAiFz OOanJPy2A+NiL0opAhR1A91DIptz7BnzcHlF7yMZh+3/pcn8+zq2zO7D0Kt4QQ== X-Gm-Gg: ASbGnctkN4rth0MjVrf9ZdgZYv0UoarpkW4lysv8/yW/TiFlwW3yGeHHXm9/ghsa5/p IE+zwOPuUZTHuPgQLlte/e8VdJlHADYyuxz2MmNF0vkavUYZwatv8XX/dLt5IKFSZz5i8ZTMRsa 0j8v59v/exnJaaqBlDUZbot1lvpLQyGL+y8MEInx3YHBJRRa4wlbNNP01FcxusZvLUdFtbTaFM7 qMWQjAFTuDH+kOggWOXvlL62x2f4+4YFUAmXHwEjsJmxrEBesrLuR3iDKIPijJ8E2qVTtZw3Yqp 3xSOTbJzOXI/ox8IrOKDX6nsaKMydG5giVqAIeBZNK+0c2hlC7ZHDeCRZngs8fF7A3ckBIPud9a M0ImEjJJxCeoRKFl5huClV/R3oNwMnPwJ9supuxOMYYbO X-Google-Smtp-Source: AGHT+IFicCui3TO2UV3KXto7aQ/0D+Yet4VjQX2z2t3dGBp+z2ea0O86wa9mzHq29XcJpZyai4BSQA== X-Received: by 2002:a05:6512:ea9:b0:553:277b:17b5 with SMTP id 2adb3069b0e04-553e3bef6bamr5078577e87.30.1750778440450; Tue, 24 Jun 2025 08:20:40 -0700 (PDT) Received: from [192.168.50.231] (broadband-46-242-11-65.ip.moscow.rt.ru. [46.242.11.65]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-553e4144963sm1854324e87.33.2025.06.24.08.20.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 Jun 2025 08:20:40 -0700 (PDT) Message-ID: <677cde50-6d64-474b-9ba8-bab380a111b3@gmail.com> Date: Tue, 24 Jun 2025 18:20:39 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Improve the performance of Unicode Normalization Forms. To: Jeff Davis , PostgreSQL Hackers References: <844d3dd7-2955-4794-95d1-7f4c13cb89fc@gmail.com> <4211ffd7fe154c4af693b98d78f4a3689ce8cc30.camel@j-davis.com> <16f87504-f174-450e-93cc-2db1074522bb@gmail.com> <96c54fc3dde2ebaccafbd1ffa29b8be1005c8b8c.camel@j-davis.com> Content-Language: ru From: Alexander Borisov In-Reply-To: <96c54fc3dde2ebaccafbd1ffa29b8be1005c8b8c.camel@j-davis.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 20.06.2025 20:20, Jeff Davis wrote: > On Fri, 2025-06-20 at 17:51 +0300, Alexander Borisov wrote: >> I don't quite see how this compares to the implementation on Rust. In >> the link provided, they use perfect hash, which I get rid of and get >> a x2 boost. >> If you take ICU implementations in C++, I have always considered them >> slow, at least when used in C code. >> I may well run benchmarks and compare the performance of the approach >> in Postgres and ICU. But this is beyond the scope of the patches >> under >> discussion. > > Are you saying that, with these patches, Postgres will offer the > fastest open-source Unicode normalization? If so, that would be very > cool. That's what we're aiming for - to implement the fastest approach. By applying the proposed patches (two patches) we get the fastest codepoints search by tables. This is evidenced by the measurements made here and earlier in the patch for unicode case improvement. After these patches are compiled, I will improve the C normalization code directly, optimize it. That's when we can take benchmarks and say with confidence that we're the best at speed. > The reason I'm asking is because, if there are multiple open source > implementations, we should either have the best one, or just borrow > another one as long as it has a suitable license (perhaps translating > to C as necessary). Before getting into this "fight" I studied different approaches to searching for the necessary codepoints in tables (hash, binary search, radix trees...) and came to the conclusion that the approach I proposed (range index) is the fastest for this purpose. -- Regards, Alexander Borisov