mapbox / mapbox/mapbox-java

mapbox cost too much cpu

未关闭
#1,086 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Java
星标
438
派生
117
PR 合并指标
30 天内没有已合并 PR

描述

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?

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从提供的 inRing 方法和用于 100,000 多个城市的 PointCustom 列表开始;检查其调用路径,并在每秒 100 个请求的情况下对工作负载进行性能分析。将完成定义为保留位置结果,同时证明在可比的生产环境负载下 CPU 使用率更低。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
performance
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
20/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。