How about move Yue auto generated anonymous function to upvalue with name prefix '__'
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- lua
- Lĩnh vực
- compilers, performance
Hướng nghiên cứu
Issue không nêu tên tệp, bài kiểm thử hay entry point nào. Hãy bắt đầu bằng cách xác định logic của compiler tạo ra các hàm ẩn danh và xác định những closure được tạo nào có thể chuyển sang các upvalue có tên mà không thay đổi hành vi. Được xem là hoàn tất khi triển khai một tập con được định nghĩa rõ ràng, duy trì ngữ nghĩa của closure và chứng minh rằng các trường hợp được chọn tránh việc tạo hàm lặp lại.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Yue have some nice features/syntax that make it a joy to work with like existence ?, nil coalescing ??, backcalls, destruct vargs... . But it also has big draw back that make it a bad choice for me to writing performance code with it because it auto create a new function every time a function called, this is a big performance issue. So I intent to avoid using it as much as possible.
It is a big shame that I can not use it when it very nice to have. So I intent to make a proposal to fix this issue.
We can move yue auto generated anonymous function to a upvalue named with prefix '__' in the same scope with parent function so that it with not generate a new function every time parent called, this generate a more better performance.
In many cases, we could send variables of closures as function parameters and get modified variable as function return results.
Well... let take the look at the example below to see what I mean.
buff_strength = (char, item) ->
item.buffer.strength? char.stats.strength?::ref()
To default Lua:
local buff_strength
buff_strength = function(char, item)
local _obj_0 = item.buffer.strength
if _obj_0 ~= nil then
return _obj_0((function()
local _obj_1 = char.stats.strength
if _obj_1 ~= nil then
return _obj_1:ref()
end
return nil
end)())
end
return nil
end
Maybe to Lua without inner function:
local __buff_strength__stub_0 = function(char)
local _obj_1 = char.stats.strength
if _obj_1 ~= nil then
return _obj_1:ref()
end
return nil
end
local buff_strength
buff_strength = function(char, item)
local _obj_0 = item.buffer.strength
if _obj_0 ~= nil then
return _obj_0(__buff_strength__stub_0(char))
end
return nil
end
Another more complex example:
exe_func = (func, env) ->
ok, ... = try
debug_env_before(env)
func(env)
debug_env_after(env)
catch ex
-- only access ex
error ex
return ex
if ok
return ...
else
os.exit(1)
To Lua with poor performance:
local exe_func
exe_func = function(func, env)
return (function(_arg_0, ...)
local ok = _arg_0
if ok then
return ...
else
return os.exit(1)
end
end)(xpcall(function()
debug_env_before(env)
func(env)
return debug_env_after(env)
end, function(ex)
error(ex)
return ex
end))
end
To Lua with better performance:
local __exe_func__stub_0 = function(_arg_0, ...)
local ok = _arg_0
if ok then
return ...
else
return os.exit(1)
end
end
local __exe_func__stub_1 = function(env)
debug_env_before(env)
func(env)
return debug_env_after(env)
end
local __exe_func__stub_2 = function(ex)
error(ex)
return ex
end
local exe_func
exe_func = function(func, env)
return __exe_func__stub_0(xpcall(__exe_func__stub_1, __exe_func__stub_2, env))
end
I may make some mistake in the rush, but I hope you can get the idea.
Well... this solution is not work with all cases but aleast it will save a lot of performance in some cases. And I think it is worth to try.
Thanks and regards.
- Ngôn ngữ chính
- Lua
- Star
- 620
- Fork
- 45
- Merge trung bình
- 9 giờ 5 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của IppClub/YueScript
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 64/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
-
[Feature request] Smarter macrosĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
Tất cả issue của IppClub/YueScript
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 2 ngày
-
follow-up
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
ksysoev/duet.nvim#265 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug: accuracy
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
PathOfBuildingCommunity/PathOfBuilding#10649 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
reMarkable
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
koreader/koreader#16485 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
nvim-orgmode/orgmode#1213 ·