Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v8]

2025-05-02 Thread Maurizio Cimadamore
On Fri, 2 May 2025 14:12:42 GMT, Per Minborg wrote: > The performance before this PR can be seen in the "confined" benchmarks > above. In those benchmarks, a regular `Arena.ofConfined` is created upon > every invocation. Yes - but I was referring to the performance of the native call -- not th

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v8]

2025-05-02 Thread Chen Liang
On Fri, 2 May 2025 16:08:09 GMT, Shaojin Wen wrote: >> Using an anonymous class for the cleanup action had very adverse effects on >> performance. I didn't want to use a lambda for startup performance reasons. > > If using lambda affects performance, how about using anonymous classes? > >

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v8]

2025-05-02 Thread Shaojin Wen
On Fri, 2 May 2025 14:11:19 GMT, Per Minborg wrote: >>> any reason why you didn't use a lambda here? >> >> I also think that CleanupAction should be changed to lambda > > Using an anonymous class for the cleanup action had very adverse effects on > performance. I didn't want to use a lambda for

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v8]

2025-05-02 Thread Shaojin Wen
On Fri, 2 May 2025 14:14:28 GMT, Per Minborg wrote: > Can you summarize your proposed changes below as It was a bit unclear to me > what you meant. I can create a separate PR with those changes later. My suggestion is to use two records (both PerThread and Frame) to replace the original inner

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v8]

2025-05-02 Thread Per Minborg
On Fri, 2 May 2025 11:13:27 GMT, Per Minborg wrote: >> This PR is based on the work of @mernst-github and aims to implement an >> _internal_ thread-local 'stack' allocator, which works like a dynamically >> sized arena, but with reset functionality to reset the allocated size back >> to a cert

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v8]

2025-05-02 Thread Per Minborg
On Fri, 2 May 2025 11:56:31 GMT, Shaojin Wen wrote: >> And, if you do that, you then don't need the `of` factory -- clients can >> just use `new` > >> any reason why you didn't use a lambda here? > > I also think that CleanupAction should be changed to lambda Using an anonymous class for the c

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v7]

2025-05-02 Thread Shaojin Wen
On Fri, 2 May 2025 10:41:38 GMT, Per Minborg wrote: >> Per Minborg has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Address comments > > Updated benchmarks: > > > Benchmark(ELEM_SIZE) Mode Cnt Score Err

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v8]

2025-05-02 Thread Shaojin Wen
On Fri, 2 May 2025 11:47:15 GMT, Maurizio Cimadamore wrote: >> Also, not a big fan of records here -- it seems that many implementation >> details such as cleanup action, lock and slicing allocator are "leaked out" >> to the caller, that is now responsible to set things up correctly. I think a

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v8]

2025-05-02 Thread Maurizio Cimadamore
On Fri, 2 May 2025 11:45:33 GMT, Maurizio Cimadamore wrote: >> src/java.base/share/classes/jdk/internal/foreign/BufferStack.java line 127: >> >>> 125: arena, >>> 126: new SlicingAllocator(arena.allocate(byteSize, >>> byteAlignment)), >>> 127:

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v8]

2025-05-02 Thread Jorn Vernee
On Fri, 2 May 2025 11:13:27 GMT, Per Minborg wrote: >> This PR is based on the work of @mernst-github and aims to implement an >> _internal_ thread-local 'stack' allocator, which works like a dynamically >> sized arena, but with reset functionality to reset the allocated size back >> to a cert

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v8]

2025-05-02 Thread Maurizio Cimadamore
On Fri, 2 May 2025 11:36:56 GMT, Maurizio Cimadamore wrote: >> Per Minborg has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Cleanup and only create CleanupAction once per thread > > src/java.base/share/classes/jdk/internal/foreign/Buffer

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v8]

2025-05-02 Thread Maurizio Cimadamore
On Fri, 2 May 2025 11:13:27 GMT, Per Minborg wrote: >> This PR is based on the work of @mernst-github and aims to implement an >> _internal_ thread-local 'stack' allocator, which works like a dynamically >> sized arena, but with reset functionality to reset the allocated size back >> to a cert

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v7]

2025-05-02 Thread Maurizio Cimadamore
On Fri, 2 May 2025 10:41:38 GMT, Per Minborg wrote: > Updated benchmarks: > > ``` > Benchmark(ELEM_SIZE) Mode Cnt Score Error > Units > BufferStackBench.OfVirtual.buffer 8 avgt 15 12.695 ± 0.205 > ns/op > BufferStackBench.OfVirtual.buffer

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v8]

2025-05-02 Thread Maurizio Cimadamore
On Fri, 2 May 2025 11:13:27 GMT, Per Minborg wrote: >> This PR is based on the work of @mernst-github and aims to implement an >> _internal_ thread-local 'stack' allocator, which works like a dynamically >> sized arena, but with reset functionality to reset the allocated size back >> to a cert

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v8]

2025-05-02 Thread Shaojin Wen
On Fri, 2 May 2025 11:13:27 GMT, Per Minborg wrote: >> This PR is based on the work of @mernst-github and aims to implement an >> _internal_ thread-local 'stack' allocator, which works like a dynamically >> sized arena, but with reset functionality to reset the allocated size back >> to a cert

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v7]

2025-05-02 Thread Shaojin Wen
On Fri, 2 May 2025 10:40:04 GMT, Per Minborg wrote: >> This PR is based on the work of @mernst-github and aims to implement an >> _internal_ thread-local 'stack' allocator, which works like a dynamically >> sized arena, but with reset functionality to reset the allocated size back >> to a cert

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v8]

2025-05-02 Thread Per Minborg
> This PR is based on the work of @mernst-github and aims to implement an > _internal_ thread-local 'stack' allocator, which works like a dynamically > sized arena, but with reset functionality to reset the allocated size back to > a certain level. The underlying memory could stay around between

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v7]

2025-05-02 Thread Per Minborg
On Fri, 2 May 2025 10:40:04 GMT, Per Minborg wrote: >> This PR is based on the work of @mernst-github and aims to implement an >> _internal_ thread-local 'stack' allocator, which works like a dynamically >> sized arena, but with reset functionality to reset the allocated size back >> to a cert

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v7]

2025-05-02 Thread Per Minborg
> This PR is based on the work of @mernst-github and aims to implement an > _internal_ thread-local 'stack' allocator, which works like a dynamically > sized arena, but with reset functionality to reset the allocated size back to > a certain level. The underlying memory could stay around between

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v6]

2025-05-02 Thread Shaojin Wen
On Wed, 30 Apr 2025 15:33:52 GMT, Per Minborg wrote: >> This PR is based on the work of @mernst-github and aims to implement an >> _internal_ thread-local 'stack' allocator, which works like a dynamically >> sized arena, but with reset functionality to reset the allocated size back >> to a cer

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v6]

2025-05-02 Thread Per Minborg
On Thu, 1 May 2025 09:09:16 GMT, Maurizio Cimadamore wrote: >> Ugh - it's a record, I see. Which brings up the question -- should it be a >> record? Should it advertize its `size and `tl` components (they seem rather >> implementation specific?). > > Was this done so that the final field could

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v6]

2025-05-02 Thread Per Minborg
On Wed, 30 Apr 2025 17:59:31 GMT, Jorn Vernee wrote: >> Per Minborg has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Improve on comments > > test/jdk/java/foreign/TestBufferStackStress2.java line 98: > >> 96: Syst

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v6]

2025-05-01 Thread Jorn Vernee
On Thu, 1 May 2025 10:20:44 GMT, Maurizio Cimadamore wrote: >> src/java.base/share/classes/jdk/internal/foreign/BufferStack.java line 163: >> >>> 161: lock.unlock(); >>> 162: } >>> 163: Reference.reachabilityFence(arena); >> >> I'm not sure t

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v6]

2025-05-01 Thread Maurizio Cimadamore
On Wed, 30 Apr 2025 15:33:52 GMT, Per Minborg wrote: >> This PR is based on the work of @mernst-github and aims to implement an >> _internal_ thread-local 'stack' allocator, which works like a dynamically >> sized arena, but with reset functionality to reset the allocated size back >> to a cer

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v6]

2025-05-01 Thread Maurizio Cimadamore
On Thu, 1 May 2025 09:22:57 GMT, Maurizio Cimadamore wrote: >> Per Minborg has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Improve on comments > > src/java.base/share/classes/jdk/internal/foreign/BufferStack.java line 163: > >> 161:

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v6]

2025-05-01 Thread Maurizio Cimadamore
On Wed, 30 Apr 2025 15:33:52 GMT, Per Minborg wrote: >> This PR is based on the work of @mernst-github and aims to implement an >> _internal_ thread-local 'stack' allocator, which works like a dynamically >> sized arena, but with reset functionality to reset the allocated size back >> to a cer

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v6]

2025-05-01 Thread Maurizio Cimadamore
On Wed, 30 Apr 2025 15:33:52 GMT, Per Minborg wrote: >> This PR is based on the work of @mernst-github and aims to implement an >> _internal_ thread-local 'stack' allocator, which works like a dynamically >> sized arena, but with reset functionality to reset the allocated size back >> to a cer

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v6]

2025-05-01 Thread Maurizio Cimadamore
On Thu, 1 May 2025 09:04:00 GMT, Maurizio Cimadamore wrote: >> Per Minborg has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Improve on comments > > src/java.base/share/classes/jdk/internal/foreign/BufferStack.java line 81: > >> 79:

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v6]

2025-05-01 Thread Maurizio Cimadamore
On Wed, 30 Apr 2025 15:33:52 GMT, Per Minborg wrote: >> This PR is based on the work of @mernst-github and aims to implement an >> _internal_ thread-local 'stack' allocator, which works like a dynamically >> sized arena, but with reset functionality to reset the allocated size back >> to a cer

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v6]

2025-05-01 Thread Maurizio Cimadamore
On Thu, 1 May 2025 09:05:58 GMT, Maurizio Cimadamore wrote: >> src/java.base/share/classes/jdk/internal/foreign/BufferStack.java line 81: >> >>> 79: @Override >>> 80: public int hashCode() { >>> 81: return System.identityHashCode(this); >> >> What's the value in these overloads

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v6]

2025-05-01 Thread Maurizio Cimadamore
On Wed, 30 Apr 2025 15:33:52 GMT, Per Minborg wrote: >> This PR is based on the work of @mernst-github and aims to implement an >> _internal_ thread-local 'stack' allocator, which works like a dynamically >> sized arena, but with reset functionality to reset the allocated size back >> to a cer

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v6]

2025-04-30 Thread Jorn Vernee
On Wed, 30 Apr 2025 15:33:52 GMT, Per Minborg wrote: >> This PR is based on the work of @mernst-github and aims to implement an >> _internal_ thread-local 'stack' allocator, which works like a dynamically >> sized arena, but with reset functionality to reset the allocated size back >> to a cer

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v6]

2025-04-30 Thread Per Minborg
On Wed, 30 Apr 2025 15:33:52 GMT, Per Minborg wrote: >> This PR is based on the work of @mernst-github and aims to implement an >> _internal_ thread-local 'stack' allocator, which works like a dynamically >> sized arena, but with reset functionality to reset the allocated size back >> to a cer

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v6]

2025-04-30 Thread Per Minborg
> This PR is based on the work of @mernst-github and aims to implement an > _internal_ thread-local 'stack' allocator, which works like a dynamically > sized arena, but with reset functionality to reset the allocated size back to > a certain level. The underlying memory could stay around between

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v5]

2025-04-30 Thread Per Minborg
> This PR is based on the work of @mernst-github and aims to implement an > _internal_ thread-local 'stack' allocator, which works like a dynamically > sized arena, but with reset functionality to reset the allocated size back to > a certain level. The underlying memory could stay around between

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v4]

2025-04-30 Thread Per Minborg
On Wed, 30 Apr 2025 10:55:41 GMT, Per Minborg wrote: >> This PR is based on the work of @mernst-github and aims to implement an >> _internal_ thread-local 'stack' allocator, which works like a dynamically >> sized arena, but with reset functionality to reset the allocated size back >> to a cer

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v4]

2025-04-30 Thread Jorn Vernee
On Wed, 30 Apr 2025 10:55:41 GMT, Per Minborg wrote: >> This PR is based on the work of @mernst-github and aims to implement an >> _internal_ thread-local 'stack' allocator, which works like a dynamically >> sized arena, but with reset functionality to reset the allocated size back >> to a cer

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v4]

2025-04-30 Thread Per Minborg
> This PR is based on the work of @mernst-github and aims to implement an > _internal_ thread-local 'stack' allocator, which works like a dynamically > sized arena, but with reset functionality to reset the allocated size back to > a certain level. The underlying memory could stay around between

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v3]

2025-04-30 Thread Per Minborg
> This PR is based on the work of @mernst-github and aims to implement an > _internal_ thread-local 'stack' allocator, which works like a dynamically > sized arena, but with reset functionality to reset the allocated size back to > a certain level. The underlying memory could stay around between

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls [v2]

2025-04-30 Thread Per Minborg
> This PR is based on the work of @mernst-github and aims to implement an > _internal_ thread-local 'stack' allocator, which works like a dynamically > sized arena, but with reset functionality to reset the allocated size back to > a certain level. The underlying memory could stay around between

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls

2025-04-29 Thread Jorn Vernee
On Tue, 29 Apr 2025 19:54:07 GMT, Per Minborg wrote: > maybe we should problem list or exclude macOS testing? Yes, I think we should. The issue is quite intermittent, and last time it only started showing up in CI as well. I think we should move the `stress()` test to a separate file./jtreg te

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls

2025-04-29 Thread Per Minborg
On Wed, 23 Apr 2025 14:05:58 GMT, Per Minborg wrote: > This PR is based on the work of @mernst-github and aims to implement an > _internal_ thread-local 'stack' allocator, which works like a dynamically > sized arena, but with reset functionality to reset the allocated size back to > a certain

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls

2025-04-29 Thread Jorn Vernee
On Wed, 23 Apr 2025 14:05:58 GMT, Per Minborg wrote: > This PR is based on the work of @mernst-github and aims to implement an > _internal_ thread-local 'stack' allocator, which works like a dynamically > sized arena, but with reset functionality to reset the allocated size back to > a certain

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls

2025-04-23 Thread Per Minborg
On Wed, 23 Apr 2025 14:05:58 GMT, Per Minborg wrote: > This PR is based on the work of @mernst-github and aims to implement an > _internal_ thread-local 'stack' allocator, which works like a dynamically > sized arena, but with reset functionality to reset the allocated size back to > a certain

Re: RFR: 8349146: [REDO] Implement a better allocator for downcalls

2025-04-23 Thread Chen Liang
On Wed, 23 Apr 2025 14:05:58 GMT, Per Minborg wrote: > This PR is based on the work of @mernst-github and aims to implement an > _internal_ thread-local 'stack' allocator, which works like a dynamically > sized arena, but with reset functionality to reset the allocated size back to > a certain

RFR: 8349146: [REDO] Implement a better allocator for downcalls

2025-04-23 Thread Per Minborg
This PR is based on the work of @mernst-github and aims to implement an _internal_ thread-local 'stack' allocator, which works like a dynamically sized arena, but with reset functionality to reset the allocated size back to a certain level. The underlying memory could stay around between calls,