mapbox / mapbox/mapbox-java

mapbox cost too much cpu

Open
#1,086 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
438
Forks
117
PR merge metrics
No merged PRs in 30d

Description

I overwrite the code like here:

public static boolean inRing(PointCustom pt, List<PointCustom> pointCustomList) {
        boolean isInside = false;
        for (int i = 0, j = pointCustomList.size() - 1; i < pointCustomList.size(); j = i++) {
            double xi = pointCustomList.get(i).getLongitude();
            double yi = pointCustomList.get(i).getLatitude();
            double xj = pointCustomList.get(j).getLongitude();
            double yj = pointCustomList.get(j).getLatitude();
            boolean intersect = (
                    (yi > pt.getLatitude()) != (yj > pt.getLatitude()))
                    && (pt.getLongitude() < (xj - xi) * (pt.getLatitude() - yi) / (yj - yi) + xi);
            if (intersect) {
                isInside = !isInside;
            }
        }
        return isInside;
    }

but i run it on the production.and find that the cpu of server cost too much ,200% CPU is consumed frequently when send 100 requests per second.
My demand is to locate in the longitude and latitude data of 100000 cities through longitude and latitude。
And the args of varible : pointCustomList storage 100000+ CityInfo object.
What problem can reduce the cost of CPU?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided inRing method and the PointCustom list used for 100,000+ cities; inspect its call path and profile the workload at 100 requests per second. Define completion as preserving the location results while demonstrating lower CPU usage under a comparable production-like load.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.