Re: fast way to infer caller

2022-04-08 Thread Kasper Nielsen
On Fri, 8 Apr 2022 at 06:57, Michael Kuhlmann wrote: > Good morning! > > On 4/7/22 23:59, Kasper Nielsen wrote: > > Hi Michael, > > > > I don't really have an opinion on how you obtain a logger. But one > > particular > > use-case I've had was that I would like to perform some access checks >

Re: fast way to infer caller

2022-04-07 Thread Michael Kuhlmann
Good morning! On 4/7/22 23:59, Kasper Nielsen wrote: Hi Michael, I don't really have an opinion on how you obtain a logger. But one particular use-case I've had was that I would like to perform some access checks based on the module of the caller. Something similar to how Panama checks for

Re: fast way to infer caller

2022-04-07 Thread Kasper Nielsen
> > Hi Kasper, > > sorry to jump in here as an uninvolved onlooker, but I can't resist. > I really don't see why this should matter. Getting the caller class is a > rare edge case that you just do in exceptional situations; most often > it's more for debugging or something. > > What users really

Re: fast way to infer caller

2022-04-07 Thread Ceki Gülcü
>> ____ >> From: core-libs-dev on behalf of >> Michael Kuhlmann >> Sent: Thursday, April 7, 2022 7:55:16 PM >> To: core-libs-dev@openjdk.java.net >> Subject: Re: fast way to infer caller >> >> >> >> On 4/7

Re: fast way to infer caller

2022-04-07 Thread Jason Mehrens
concerns perhaps there is some more work to be done improving StackWalker? :) Jason From: core-libs-dev on behalf of Bernd Eckenfels Sent: Thursday, April 7, 2022 1:02 PM To: core-libs-dev@openjdk.java.net Subject: Re: fast way to infer caller Some

Re: fast way to infer caller

2022-04-07 Thread Ralph Goers
uhlmann > Sent: Thursday, April 7, 2022 7:55:16 PM > To: core-libs-dev@openjdk.java.net > Subject: Re: fast way to infer caller > > > > On 4/7/22 19:27, Kasper Nielsen wrote: >>> >>> nope, see my previous mail to Ceki, the VM is cheating here if it can >

Re: fast way to infer caller

2022-04-07 Thread Bernd Eckenfels
: Thursday, April 7, 2022 7:55:16 PM To: core-libs-dev@openjdk.java.net Subject: Re: fast way to infer caller On 4/7/22 19:27, Kasper Nielsen wrote: >> >> nope, see my previous mail to Ceki, the VM is cheating here if it can >> inline the call to MethodHandles.lookup() >

Re: fast way to infer caller

2022-04-07 Thread Michael Kuhlmann
On 4/7/22 19:27, Kasper Nielsen wrote: nope, see my previous mail to Ceki, the VM is cheating here if it can inline the call to MethodHandles.lookup() Does how the VM cheats really matter? The fact is that the code in the JDK can get the calling class and implement something like

Re: fast way to infer caller

2022-04-07 Thread Kasper Nielsen
> > nope, see my previous mail to Ceki, the VM is cheating here if it can > inline the call to MethodHandles.lookup() > Does how the VM cheats really matter? The fact is that the code in the JDK can get the calling class and implement something like MethodHandles.lookup() so it takes ~3 ns. If

Re: fast way to infer caller

2022-04-07 Thread Ceki Gülcü
Rémi, Jason, Steven, Kasper, Thank you all for your thoughtful feedback. I forgot to mention that in addition to obtaining the appropriate logger by inferring caller class, the caller class may also be a data point written with each logging event, aka LogRecord. If the cost of writing a log

Re: fast way to infer caller

2022-04-07 Thread forax
> From: "Kasper Nielsen" > To: "Remi Forax" > Cc: "Ceki Gülcü" , "core-libs-dev" > > Sent: Thursday, April 7, 2022 2:42:46 PM > Subject: Re: fast way to infer caller > On Thu, 7 Apr 2022 at 13:33, Remi Forax < [ mailto:fo...

Re: fast way to infer caller

2022-04-07 Thread Kasper Nielsen
On Thu, 7 Apr 2022 at 13:33, Remi Forax wrote: > - Original Message - > > From: "Kasper Nielsen" > > To: "Ceki Gülcü" > > Cc: "core-libs-dev" > > Sent: Thursday, April 7, 2022 1:53:33 PM > > Subject: Re: fast way to infe

Re: fast way to infer caller

2022-04-07 Thread Remi Forax
- Original Message - > From: "Kasper Nielsen" > To: "Ceki Gülcü" > Cc: "core-libs-dev" > Sent: Thursday, April 7, 2022 1:53:33 PM > Subject: Re: fast way to infer caller >> >> MethodHandles.lookup().lookupClass() looks very prom

Re: fast way to infer caller

2022-04-07 Thread Kasper Nielsen
> > MethodHandles.lookup().lookupClass() looks very promising except that > there is no way to specify the depth. > > I am looking for a method to obtain the Nth caller at a cost of around > 100 to 200 nanoseconds of CPU time. Do you think the JDK could cater > for this use case? > Hi Ceki, I

Re: fast way to infer caller

2022-04-06 Thread Remi Forax
- Original Message - > From: "Ceki Gülcü" > To: "core-libs-dev" > Sent: Thursday, April 7, 2022 1:04:11 AM > Subject: Re: fast way to infer caller > Hi Jason, > > Yes, the code was mentioned in SLF4J PR 271. > > The benchmark can b

Re: fast way to infer caller

2022-04-06 Thread Steven Schlansker
> On Apr 6, 2022, at 3:54 PM, Remi Forax wrote: > > - Original Message - >> From: "Ceki Gülcü" >> To: "core-libs-dev" >> Sent: Wednesday, April 6, 2022 11:26:39 PM >> Subject: Re: fast way to infer caller > >> Hi Rém

Re: fast way to infer caller

2022-04-06 Thread Ceki Gülcü
c/java.logging/share/classes/java/util/logging/LogRecord.java#L754 > > Jason > > > From: core-libs-dev on behalf of Ceki > Gülcü > Sent: Wednesday, April 6, 2022 4:26 PM > To: core-libs-dev > Subject: Re: fast way to

Re: fast way to infer caller

2022-04-06 Thread Remi Forax
- Original Message - > From: "Ceki Gülcü" > To: "core-libs-dev" > Sent: Wednesday, April 6, 2022 11:26:39 PM > Subject: Re: fast way to infer caller > Hi Rémi, > > Thank you for your answer. > > According to some benchmarks on a

Re: fast way to infer caller

2022-04-06 Thread Jason Mehrens
? https://github.com/openjdk/jdk/blob/master/src/java.logging/share/classes/java/util/logging/LogRecord.java#L754 Jason From: core-libs-dev on behalf of Ceki Gülcü Sent: Wednesday, April 6, 2022 4:26 PM To: core-libs-dev Subject: Re: fast way to infer caller

Re: fast way to infer caller

2022-04-06 Thread Ceki Gülcü
make sense? How difficult would it be to add such a method? -- Ceki Gülcü On 4/6/2022 5:52 PM, Remi Forax wrote: > - Original Message - >> From: "Ceki Gülcü" >> To: "core-libs-dev" >> Sent: Wednesday, April 6, 2022 5:30:51 PM >> Subject: f

Re: fast way to infer caller

2022-04-06 Thread Remi Forax
- Original Message - > From: "Ceki Gülcü" > To: "core-libs-dev" > Sent: Wednesday, April 6, 2022 5:30:51 PM > Subject: fast way to infer caller > Hello, Hello, > > As you are probably aware, one of the important primitives used in &g

fast way to infer caller

2022-04-06 Thread Ceki Gülcü
Hello, As you are probably aware, one of the important primitives used in logging libraries is inferring the caller of a given logging statement. The current common practice is to create a throwable and process its stack trace. This is rather wasteful and rather slow. As an alternative, I have