From f568f388ff2e6e8bc10221725bd5569678faac98 Mon Sep 17 00:00:00 2001 From: Roberto Aloi Date: Tue, 2 Apr 2024 11:24:53 -0700 Subject: [PATCH] Configurable chunk for project-wide eqwalization Summary: As per title. Default to 100. Reviewed By: alanz Differential Revision: D55639108 fbshipit-source-id: 3dc0dbf6c6c2ca26933ee2be278376a715044710 --- crates/elp/src/config.rs | 12 +++++++++++- crates/elp/src/server.rs | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/elp/src/config.rs b/crates/elp/src/config.rs index b2db17d0b7..d43afc19a6 100644 --- a/crates/elp/src/config.rs +++ b/crates/elp/src/config.rs @@ -44,6 +44,8 @@ config_data! { eqwalizer_all: bool = json! { false }, /// Maximum number of tasks to run in parallel for project-wide eqwalization. eqwalizer_maxTasks: usize = json! { 32 }, + /// Chunk size to use for project-wide eqwalization. + eqwalizer_chunkSize: usize = json! { 100 }, /// Whether to show Hover Actions. hoverActions_enable: bool = json! { false }, /// Whether to show Hover Actions of type 'docs'. Only applies when @@ -105,6 +107,7 @@ pub struct LensConfig { pub struct EqwalizerConfig { pub all: bool, pub max_tasks: usize, + pub chunk_size: usize, } macro_rules! try_ { @@ -254,6 +257,7 @@ impl Config { EqwalizerConfig { all: self.data.eqwalizer_all, max_tasks: self.data.eqwalizer_maxTasks, + chunk_size: self.data.eqwalizer_chunkSize, } } @@ -483,7 +487,7 @@ mod tests { let s = remove_ws(&schema); - expect![[r#""elp.ai.enable":{"default":false,"markdownDescription":"EnablesupportforAI-basedcompletions.","type":"boolean"},"elp.diagnostics.disabled":{"default":[],"items":{"type":"string"},"markdownDescription":"ListofELPdiagnosticstodisable.","type":"array","uniqueItems":true},"elp.diagnostics.enableExperimental":{"default":false,"markdownDescription":"WhethertoshowexperimentalELPdiagnosticsthatmight\nhavemorefalsepositivesthanusual.","type":"boolean"},"elp.eqwalizer.all":{"default":false,"markdownDescription":"WhethertoreportEqwalizerdiagnosticsforthewholeprojectandnotonlyforopenedfiles.","type":"boolean"},"elp.eqwalizer.maxTasks":{"default":32,"markdownDescription":"Maximumnumberoftaskstoruninparallelforproject-wideeqwalization.","minimum":0,"type":"integer"},"elp.hoverActions.docLinks.enable":{"default":false,"markdownDescription":"WhethertoshowHoverActionsoftype'docs'.Onlyapplieswhen\n`#elp.hoverActions.enable#`isset.","type":"boolean"},"elp.hoverActions.enable":{"default":false,"markdownDescription":"WhethertoshowHoverActions.","type":"boolean"},"elp.inlayHints.parameterHints.enable":{"default":false,"markdownDescription":"Whethertoshowfunctionparameternameinlayhintsatthecall\nsite.","type":"boolean"},"elp.lens.debug.enable":{"default":false,"markdownDescription":"Whethertoshowthe`Debug`lenses.Onlyapplieswhen\n`#elp.lens.enable#`isset.","type":"boolean"},"elp.lens.enable":{"default":false,"markdownDescription":"WhethertoshowCodeLensesinErlangfiles.","type":"boolean"},"elp.lens.links.enable":{"default":false,"markdownDescription":"Whethertoshowthe`Link`lenses.Onlyapplieswhen\n`#elp.lens.enable#`isset.","type":"boolean"},"elp.lens.run.coverage.enable":{"default":false,"markdownDescription":"Displaycodecoverageinformationwhenrunningtestsviathe\nCodeLenses.Onlyapplieswhen`#elp.lens.enabled`and\n`#elp.lens.run.enable#`areset.","type":"boolean"},"elp.lens.run.enable":{"default":false,"markdownDescription":"Whethertoshowthe`Run`lenses.Onlyapplieswhen\n`#elp.lens.enable#`isset.","type":"boolean"},"elp.lens.run.interactive.enable":{"default":false,"markdownDescription":"Whethertoshowthe`RunInteractive`lenses.Onlyapplieswhen\n`#elp.lens.enable#`isset.","type":"boolean"},"elp.log":{"default":"error","markdownDescription":"ConfigureLSP-basedloggingusingenv_loggersyntax.","type":"string"},"elp.signatureHelp.enable":{"default":false,"markdownDescription":"WhethertoshowSignatureHelp.","type":"boolean"},"elp.typesOnHover.enable":{"default":false,"markdownDescription":"Displaytypeswhenhoveringoverexpressions.","type":"boolean"},"#]] + expect![[r#""elp.ai.enable":{"default":false,"markdownDescription":"EnablesupportforAI-basedcompletions.","type":"boolean"},"elp.diagnostics.disabled":{"default":[],"items":{"type":"string"},"markdownDescription":"ListofELPdiagnosticstodisable.","type":"array","uniqueItems":true},"elp.diagnostics.enableExperimental":{"default":false,"markdownDescription":"WhethertoshowexperimentalELPdiagnosticsthatmight\nhavemorefalsepositivesthanusual.","type":"boolean"},"elp.eqwalizer.all":{"default":false,"markdownDescription":"WhethertoreportEqwalizerdiagnosticsforthewholeprojectandnotonlyforopenedfiles.","type":"boolean"},"elp.eqwalizer.chunkSize":{"default":100,"markdownDescription":"Chunksizetouseforproject-wideeqwalization.","minimum":0,"type":"integer"},"elp.eqwalizer.maxTasks":{"default":32,"markdownDescription":"Maximumnumberoftaskstoruninparallelforproject-wideeqwalization.","minimum":0,"type":"integer"},"elp.hoverActions.docLinks.enable":{"default":false,"markdownDescription":"WhethertoshowHoverActionsoftype'docs'.Onlyapplieswhen\n`#elp.hoverActions.enable#`isset.","type":"boolean"},"elp.hoverActions.enable":{"default":false,"markdownDescription":"WhethertoshowHoverActions.","type":"boolean"},"elp.inlayHints.parameterHints.enable":{"default":false,"markdownDescription":"Whethertoshowfunctionparameternameinlayhintsatthecall\nsite.","type":"boolean"},"elp.lens.debug.enable":{"default":false,"markdownDescription":"Whethertoshowthe`Debug`lenses.Onlyapplieswhen\n`#elp.lens.enable#`isset.","type":"boolean"},"elp.lens.enable":{"default":false,"markdownDescription":"WhethertoshowCodeLensesinErlangfiles.","type":"boolean"},"elp.lens.links.enable":{"default":false,"markdownDescription":"Whethertoshowthe`Link`lenses.Onlyapplieswhen\n`#elp.lens.enable#`isset.","type":"boolean"},"elp.lens.run.coverage.enable":{"default":false,"markdownDescription":"Displaycodecoverageinformationwhenrunningtestsviathe\nCodeLenses.Onlyapplieswhen`#elp.lens.enabled`and\n`#elp.lens.run.enable#`areset.","type":"boolean"},"elp.lens.run.enable":{"default":false,"markdownDescription":"Whethertoshowthe`Run`lenses.Onlyapplieswhen\n`#elp.lens.enable#`isset.","type":"boolean"},"elp.lens.run.interactive.enable":{"default":false,"markdownDescription":"Whethertoshowthe`RunInteractive`lenses.Onlyapplieswhen\n`#elp.lens.enable#`isset.","type":"boolean"},"elp.log":{"default":"error","markdownDescription":"ConfigureLSP-basedloggingusingenv_loggersyntax.","type":"string"},"elp.signatureHelp.enable":{"default":false,"markdownDescription":"WhethertoshowSignatureHelp.","type":"boolean"},"elp.typesOnHover.enable":{"default":false,"markdownDescription":"Displaytypeswhenhoveringoverexpressions.","type":"boolean"},"#]] .assert_eq(s.as_str()); expect![[r#" @@ -511,6 +515,12 @@ mod tests { "markdownDescription": "Whether to report Eqwalizer diagnostics for the whole project and not only for opened files.", "type": "boolean" }, + "elp.eqwalizer.chunkSize": { + "default": 100, + "markdownDescription": "Chunk size to use for project-wide eqwalization.", + "minimum": 0, + "type": "integer" + }, "elp.eqwalizer.maxTasks": { "default": 32, "markdownDescription": "Maximum number of tasks to run in parallel for project-wide eqwalization.", diff --git a/crates/elp/src/server.rs b/crates/elp/src/server.rs index f71aa77bc3..701dcddf37 100644 --- a/crates/elp/src/server.rs +++ b/crates/elp/src/server.rs @@ -1534,7 +1534,7 @@ impl Server { return; } let snapshot = self.snapshot(); - let chunk_size = 100; + let chunk_size = self.config.eqwalizer().chunk_size; let max_tasks = self.config.eqwalizer().max_tasks; self.eqwalizer_pool.handle.spawn_with_sender(move |sender| { let total = files.len();