Message-ID: From: "BrentDouglasB1 (@BrentDouglasB1)" To: "pgjdbc/pgjdbc" Date: Tue, 21 Nov 2023 14:34:46 +0000 Subject: Re: [pgjdbc/pgjdbc] issue #2963: BufferedOutputStream in PGStream should be replaced to something more efficient In-Reply-To: References: List-Id: X-GitHub-Author-Login: BrentDouglasB1 X-GitHub-Comment-Id: 1821042214 X-GitHub-Comment-Type: issue_comment X-GitHub-Issue: 2963 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-Type: comment X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/2963#issuecomment-1821042214 Content-Type: text/plain; charset=utf-8 I was quite interested to find this active ticket today, as I opened this repo with the intent to create one to discuss essentially the same patch as above (an unsynchonized clone of BufferedOutputStream for the usage in PGStream). I'm only bringing some anecdotal profiler images to the table at the moment, but I would be happy to assist creating some benchmarks/etc for the patch if desired. The pictures below are Zulu 21, PG 12, PGJDBC 42.5.4 This is a screenshot I have taken from a datadog profile of a benchmark for a real workload run using the unpatched driver. ![Screenshot 2023-11-21 at 6 17 08 PM](https://github.com/pgjdbc/pgjdbc/assets/83204206/0ac77dd0-ac89-4faa-86af-06eee31002cc) And this is what the profile looks like over the same run after monkey patching PGStream with a copy of BufferedOutputStream with the `synchronized` keywords removed. ![Screenshot 2023-11-21 at 10 07 15 PM](https://github.com/pgjdbc/pgjdbc/assets/83204206/bc062f1b-8c96-4319-a4dc-9d49a7d4e21b) Removing these locks seems a great start to reduce CPU usage in batch queries.