Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用尾递归优化编译时栈深度过大的问题 #132

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DQinYuan
Copy link
Collaborator

@DQinYuan DQinYuan commented Mar 28, 2021

和 issue #120 相关

虽然在 3.2.1 时 qlexpress 似乎优化过一次栈的使用,但是依旧栈的深度依旧很深,比如下面一段简单的脚本,最大栈的深度就高达 152:

if (prod in ("xxx", "yyy")
        && (((product == "standard" || product == "phase_standard") && (bizIdentity == "1111" || bizIdentity == "44555"))
            || (productCode == "fack" && bizIdentity == "1212")
            || (productCode == "auth" && bizIdentity == "3323"))) {
            return "TTTTT";
    }

线上稍微长一些的脚本就有很大的 stackOverflow 风险。所以我这里将语法分析部分改成了尾递归,跑过了所有单测,能够彻底解决编译栈深度过深的问题

@DQinYuan
Copy link
Collaborator Author

DQinYuan commented Apr 1, 2021

Benchmark Mode Samples Score Score error Units
优化前 thrpt 20 858.748 31.298 ops/s
优化后 thrpt 20 1275.797 21.940 ops/s

经过测试,编译性能有大幅度提升

@baoxingjie
Copy link
Contributor

我自己研究下,谢谢你的建议

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants