-
-
Notifications
You must be signed in to change notification settings - Fork 82
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
Heavy refactor of namespacing #266
Conversation
a2cfe4d
to
1fa3e66
Compare
I did not like how namespacing turned out, two tasks, one with a lot of code that didn't have defined responsibilities, it was hard to understand, and left the code in a bad state. After looking at some of the files in a release, it occurred to me that we had all we needed was to perform namepacing on those files rather than messing up the _build directory with namespaced beams. This path lead to here, where we rewrite things in the release's directory and its artifacts. The effect of this is that you can make namespacing happen much more quickly, without the clean / build / namespace / clean process that we had before. Oh yeah, I parallelized writing the beams. It's super fast now.
1fa3e66
to
9d123e8
Compare
There's a huge increase in speed.👍 one issues: if
no plugin diagnostics then do a |
@scottming thats due to the protocols, rebuild deps and things should continue working |
actually, @scottming, that seems like a problem with namespacing being applied to the plugin and reloading the module. |
I've already reopened the editor. this problem still exists. |
And I found another bug: if you 2023-07-15T09:05:43.471323+08:00 error: ** Task 'Elixir.LXRelease.Plugin.Runner.Coordinator' terminating, ** Started from <0.9330.0>, ** When function == fun 'Elixir.LexicalCredo':diagnose/1, ** arguments == [#{'__struct__' => 'Elixir.LXRelease.Project',env_variables => #{},mix_env => nil,mix_exs_uri => <<"file:///Users/scottming/Code/lexical/mix.exs">>,'mix_project?' => true,mix_target => nil,project_module => 'Elixir.Lexical.LanguageServer.MixProject',root_uri => <<"file:///Users/scottming/Code/lexical">>}], ** Reason for termination == , ** {function_clause,[{'Elixir.LexicalCredo',diagnose,[#{'__struct__' => 'Elixir.LXRelease.Project',env_variables => #{},mix_env => nil,mix_exs_uri => <<"file:///Users/scottming/Code/lexical/mix.exs">>,'mix_project?' => true,mix_target => nil,project_module => 'Elixir.Lexical.LanguageServer.MixProject',root_uri => <<"file:///Users/scottming/Code/lexical">>}],[{file,"lib/lexical_credo.ex"},{line,24}]},{'Elixir.Task.Supervised',invoke_mfa,2,[{file,"lib/task/supervised.ex"},{line,89}]},{'Elixir.Task.Supervised',reply,4,[{file,"lib/task/supervised.ex"},{line,34}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]}
2023-07-15T09:05:43.489678+08:00 error: crasher: initial call: 'Elixir.LexicalCredo':diagnose/1, pid: <0.9330.0>, registered_name: [], error: {function_clause,[{'Elixir.LexicalCredo',diagnose,[#{'__struct__' => 'Elixir.LXRelease.Project',env_variables => #{},mix_env => nil,mix_exs_uri => <<"file:///Users/scottming/Code/lexical/mix.exs">>,'mix_project?' => true,mix_target => nil,project_module => 'Elixir.Lexical.LanguageServer.MixProject',root_uri => <<"file:///Users/scottming/Code/lexical">>}],[{file,"lib/lexical_credo.ex"},{line,24}]},{'Elixir.Task.Supervised',invoke_mfa,2,[{file,"lib/task/supervised.ex"},{line,89}]},{'Elixir.Task.Supervised',reply,4,[{file,"lib/task/supervised.ex"},{line,34}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]}, ancestors: ['Elixir.LXRelease.Plugin.Runner.Supervisor.TaskSupervisor','Elixir.LXRelease.Plugin.Runner.Application.Supervisor',<0.164.0>], message_queue_len: 0, messages: [], links: [<0.166.0>], dictionary: [{'$callers',[<0.167.0>]}], trap_exit: false, status: running, heap_size: 28690, stack_size: 28, reductions: 17271; neighbours:
2023-07-15T09:05:43.490007+08:00 error: supervisor: {local,'Elixir.LXRelease.Plugin.Runner.Supervisor.TaskSupervisor'}, errorContext: child_terminated, reason: {function_clause,[{'Elixir.LexicalCredo',diagnose,[#{'__struct__' => 'Elixir.LXRelease.Project',env_variables => #{},mix_env => nil,mix_exs_uri => <<"file:///Users/scottming/Code/lexical/mix.exs">>,'mix_project?' => true,mix_target => nil,project_module => 'Elixir.Lexical.LanguageServer.MixProject',root_uri => <<"file:///Users/scottming/Code/lexical">>}],[{file,"lib/lexical_credo.ex"},{line,24}]},{'Elixir.Task.Supervised',invoke_mfa,2,[{file,"lib/task/supervised.ex"},{line,89}]},{'Elixir.Task.Supervised',reply,4,[{file,"lib/task/supervised.ex"},{line,34}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]}, offender: [{pid,<0.9330.0>},{id,undefined},{mfargs,{'Elixir.Task.Supervised',start_link,undefined}},{restart_type,temporary},{shutdown,5000},{child_type,worker}]
2023-07-15T09:05:43.494741+08:00 error: Task Elixir.LexicalCredo failed because {:function_clause, [{LexicalCredo, :diagnose, [%LXRelease.Project{root_uri: "file:///Users/scottming/Code/lexical", mix_exs_uri: "file:///Users/scottming/Code/lexical/mix.exs", mix_project?: true, mix_env: nil, mix_target: nil, env_variables: %{}, project_module: Lexical.LanguageServer.MixProject}], [file: 'lib/lexical_credo.ex', line: 24]}, {Task.Supervised, :invoke_mfa, 2, [file: 'lib/task/supervised.ex', line: 89]}, {Task.Supervised, :reply, 4, [file: 'lib/task/supervised.ex', line: 34]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 240]}]} and just like you said, restarting the LSP will fix this. but I haven't tested in another project yest, just lexical itself. |
@scottming I think that second one is due to protocols being missing, can you check? |
Improvement: Rather than call Namespace.init(), moved to computing values on load. Bugfix: If namespacing was applied to the mix tasks, the module attributes would get rewriteten, which meant the root modules were incorrect for several apps. Having them as strings "hides" them from the namespacing code, and things work on first load again.
@scottming please take another look, I made a change that addresses both issues. |
Namespaced completions are noise, we don't ever want them to show up.
8878201
to
8f94927
Compare
This problem is fixed: #266 (comment) And this problem still exists: #266 (comment), you can reproduced by: |
@scottming I'm not seeing that problem, can you give me detailed reproduction steps? Like: In other words, remove the build and deps directories and give me instructions to reproduce the error.
This is not a valid command, it namespaces the first time and doesn't namespace the second time, and that definitely causes problems. |
Okay, that's what I did. And it looks like we're now namespacing fast enough that we don't need to worry about this problem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Just some minor comments.
I did not like how namespacing turned out: Two separate mix tasks, one of which had a lot of code that didn't have defined responsibilities. it was hard to understand, and left the
_build
directory in a bad state.After looking at some of the files in a release, it occurred to me that we had all we needed was to perform namepacing on those files rather than messing up the _build directory with namespaced beams. This path lead to here, where we rewrite the artifacts in the release directory, and leave our current project alone.
The effect of this is that you can make namespacing happen much more quickly, without the clean / build / namespace / clean process that we had before.
Oh yeah, I parallelized writing the beams. It's super fast now.
This approach has the following advantages:
remote_control
will be auto-namespacednamespace.ex
_build
directory is still usable after you runmix release