jackrabbit-oak-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Mueller (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OAK-3153) Make it possible to disable recording of stack trace in SessionStats
Date Tue, 04 Aug 2015 07:15:04 GMT

    [ https://issues.apache.org/jira/browse/OAK-3153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14653187#comment-14653187

Thomas Mueller commented on OAK-3153:

I'm not quite sure what problem we wanted to solve with recording the stack trace. If we want
to find session leaks, then it's not clear to me what kind of leak: (a) more and more sessions
are referenced in memory, or (b) do we want to track those where logout was not called.

Depending on that, it may or may not make sense to make it configurable. Making it configurable,
and disabled by default, would slow down solving the problem because people would first have
to manually enable the feature. It would be better if this feature is automatically enabled
in some way. To enable it automatically, we could count the live sessions and enable it after
we have more than 2000 sessions (for example). To count live sessions, PhantomReferences can
be used as follows:

import java.lang.ref.PhantomReference;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.util.HashSet;
import java.util.LinkedList;

public class Test {
    public static void main(String... a) {
        System.out.println("create & gc 1000 sessions...");
        for (int i = 0; i < 1000; i++) {
            new Session();
            if (i % 100 == 0) {
        System.out.println("create & keep 1000 sessions...");
        LinkedList<Session> list = new LinkedList<Session>();
        for (int i = 0; i < 1000; i++) {
            list.add(new Session());

    static class Session {
        static HashSet<Reference<Session>> references = 
                new HashSet<Reference<Session>>();
        static ReferenceQueue<Session> queue = 
                new ReferenceQueue<Session>();
        byte[] data = new byte[1024 * 1024];
            synchronized (Session.class) {
                Reference<Session> ref = 
                        new PhantomReference<Session>(this, queue);
                while (true) {
                    Reference<? extends Session> r = queue.poll();
                    if (r == null) {
                int s = references.size();
                if (s > 100 && s % 100 == 0) {
                    System.out.println("size: about " + s);

> Make it possible to disable recording of stack trace in SessionStats
> --------------------------------------------------------------------
>                 Key: OAK-3153
>                 URL: https://issues.apache.org/jira/browse/OAK-3153
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.3.3
>            Reporter: Joel Richard
>              Labels: performance
> For the rendering of some pages we have to create a lot of sessions. Around 9% of the
rendering time is spent inside of RepositoryImpl.login. Half of this time is spent creating
the exception in SessionStats. Therefore, it would be useful if the recording of the exception
could be disabled to improve the performance.

This message was sent by Atlassian JIRA

View raw message