Skip to content

[CASSANDRA-21020][trunk] Optimize thread local for metrics and tracing#4831

Open
netudima wants to merge 1 commit into
apache:trunkfrom
netudima:CASSANDRA-21020-trunk
Open

[CASSANDRA-21020][trunk] Optimize thread local for metrics and tracing#4831
netudima wants to merge 1 commit into
apache:trunkfrom
netudima:CASSANDRA-21020-trunk

Conversation

@netudima
Copy link
Copy Markdown
Contributor

Implement custom CassandraThread to keep direct references to frequently used thread local objects

patch by Dmitry Konstantinov; reviewed by TBD for CASSANDRA-21020

@netudima netudima force-pushed the CASSANDRA-21020-trunk branch from a7ec5e6 to 186e3c7 Compare May 21, 2026 10:45
Implement custom CassandraThread to keep direct references to frequently used thread local objects

patch by Dmitry Konstantinov; reviewed by TBD for CASSANDRA-21020
@netudima netudima force-pushed the CASSANDRA-21020-trunk branch from 186e3c7 to 0da4a5e Compare May 21, 2026 15:31
creationTrace = Arrays.copyOfRange(creationTrace, 2, creationTrace.length);
}

public InspectableFastThreadLocalThread() { super(); setStack(); }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not completely sure we can just remove it like this, something tells me that somebody is using it outside of Cassandra tree, or just ask Sam Tunnicliffe what all these unused constructors are for.

Copy link
Copy Markdown
Contributor Author

@netudima netudima May 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've checked with Sam, he doesn't think that should be a problem

return current != null ? current : ExecutorLocals.none();
}

public void doRun()
Copy link
Copy Markdown
Contributor

@smiklosovic smiklosovic May 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is easy to get wrong, like just running doRun() with the work and not calling run() at all. It just feels strange to have empty doRun() like this.

doRun might be abstract and we would have a class like DefaultCassandraThread which would just have this doRun() explicitly empty. Just a suggestion really, maybe just java doc would do it.

Some documentation would not be bad to add either, it is a bit confusing what is called where. run calls super.run which actually runs Runnable target we pass to this constructor, then doRun() is supposed to do what exactly?

}

public void run()
public void doRun()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not to call super(...) version in CommitLogThread constructor where target would be a Runnable running this run() method? It might be anonymous Runnable passed to that constructor's super, basically. We would get rid of doRun(), no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants