RFR: JDK-8304723: Statically allocate global mutexes
Thomas Stuefe
stuefe at openjdk.org
Thu Mar 23 15:54:05 UTC 2023
On Thu, 23 Mar 2023 14:37:11 GMT, Justin King <jcking at openjdk.org> wrote:
> > I'd be very happy if startup would be fast enough for ~150 fewer mallocs to matter.
> > A blank hello world with no args to speak of calls into malloc >10k times. ~150(?) mallocs less are a step in the right direction.
>
> Baby steps. :)
>
> As a compromise I'll shift to keeping the pointers and just use a static storage variable in the `def` macros, as suggested. It accomplishes the goal if not malloc'ing but is not as safe due to the two aforementioned bugs. I'll also add an assert to catch the "created twice" problem. But having the mutex pointer always be nullptr is a different story that cannot be caught with that approach.
The create twice problem is admittedly evil. The nullptr problem not so much, since we will access it anyway and crash right there, or?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13143#issuecomment-1481440808
More information about the hotspot-dev
mailing list