oldmanpushcart / greys-anatomy

Java诊断工具
Apache License 2.0
4.02k stars 1.22k forks source link

【建议】trace的method里面把接口的实例类打印出来 #220

Closed zhaiyuyong closed 6 years ago

zhaiyuyong commented 6 years ago

比如:

public Plan plan(Analysis analysis, Stage stage)
    {
        PlanNode root = planStatement(analysis, analysis.getStatement());

        PlanSanityChecker.validateIntermediatePlan(root, session, metadata, sqlParser, symbolAllocator.getTypes());

        if (stage.ordinal() >= Stage.OPTIMIZED.ordinal()) {
            for (PlanOptimizer optimizer : planOptimizers) {
                root = optimizer.optimize(root, session, symbolAllocator.getTypes(), symbolAllocator, idAllocator);
                requireNonNull(root, format("%s returned a null plan", optimizer.getClass().getName()));
            }
        }

        if (stage.ordinal() >= Stage.OPTIMIZED_AND_VALIDATED.ordinal()) {
            // make sure we produce a valid plan after optimizations run. This is mainly to catch programming errors
            PlanSanityChecker.validateFinalPlan(root, session, metadata, sqlParser, symbolAllocator.getTypes());
        }

        Map<PlanNodeId, PlanNodeCost> planNodeCosts = costCalculator.calculateCostForPlan(session, symbolAllocator.getTypes(), root);

        return new Plan(root, symbolAllocator.getTypes(), planNodeCosts);
    }

PlanOptimizer是个接口,有58个实现,for遍历不知道具体哪个实例耗时严重

oldmanpushcart commented 6 years ago

受限于JVM规范,这个属于动态调用,是不可能拿到的。不过你确定了是这个方法有问题嫌疑,可以用ptrace命令进一步的适配,能满足你的需求

ptrace com.xxx.service.PlanService plan --path com.xxx.*.PlanOptimizer

可以试试这样