Closed LukeButters closed 5 years ago
LinkedBlockingDeque is thread-safe while LinkedList is not, it is important to make sure whether thread-safety is required. @LukeButters
It would be preferable to change it from:
private void constructFailureStates() {
final Queue<State> queue = new LinkedList<>();
to:
private void constructFailureStates() {
final Queue<State> queue = createFailureStateQueue();
// ...
}
protected Queue<State> createFailureStateQueue() {
return new LinkedList<>();
}
However, that's all moot since Trie has been refactored extensively.
If performance is still an issue, please open another ticket showing the bottleneck.
Hi @YuyuZha0 thanks for replying! I think that in this case it was never possible for two threads to be sharing that data structure although it was so long ago I hardly remember.
@DaveJarvis I will try out the new trie, thanks!
In this case, I would say ArrayDeque
may be a good choice, it relies on array, should be more CPU-Cache friendlly. @LukeButters
Hi
My profiler seems to show that a bunch of time is being spent in:
inside of
LinkedList
is a faster implementation ofQueue
thanLinkedBlockingDeque
, I am measuring it to be about 3-4 times faster. Could:be changed to: