Skip to content

Quadtree query performance in multi-threaded environments due to synchronized items list #1169

@leeshinyook

Description

@leeshinyook

Hello. JTS Team.

First, I'm using the JTS library very well in my service. Thank you for your hard work.
While using the JTS quadtree index, we noticed that the query api was slow.
The cause was that the Node Itmes within the query tree were implemented using Collections.synchronizedList(new ArrayList()); and the synchronized lock was used during the iteration process of the items. As a result, calling Query in a multithreaded env may cause performance issues due to locks.
Upon researching related issues, it appears to have been written to ensure thread safety for the quadtree

i don't think this implementation is flawed, but in a pattern where an index is created once and then queried in a multithreaded env, it may not be the best approach. In my opinion, purpose of using an index is maximize read-query performance, but the fact that a lock is acquired on read-query seems counterproductive to that goal.

if someone needs a thread-safe quadtree index, it might be appropriate to provide a separate ConcurrentQuadtree or leaving the handling to the user (Purhaps, there would be limitations)

If there's anything I can contribute to this issue, please let me know!
Thank you again for maintaining such a great library—it's been incredibly helpful for our project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions