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

Profiling improvements #591

Merged
merged 11 commits into from
Jan 12, 2023
Merged

Profiling improvements #591

merged 11 commits into from
Jan 12, 2023

Conversation

JohnnyMorganz
Copy link
Owner

contains_comments turns out is a very expensive function for big files...

We do some reorganisation and reduce the reliance on this function.
We should try and remove its use completely.

For large files (6MB+), this change makes formatting complete in time :)
https://github.com/WeakAuras/WeakAuras2/blob/main/WeakAurasModelPaths/ModelPaths.lua originally did not complete formatting (20min+), but now completes in <=100s.

Still some room for improvements

@codecov
Copy link

codecov bot commented Sep 23, 2022

Codecov Report

Base: 97.64% // Head: 97.61% // Decreases project coverage by -0.02% ⚠️

Coverage data is based on head (579fdda) compared to base (3e3fd03).
Patch coverage: 94.87% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #591      +/-   ##
==========================================
- Coverage   97.64%   97.61%   -0.03%     
==========================================
  Files          14       14              
  Lines        5595     5615      +20     
==========================================
+ Hits         5463     5481      +18     
- Misses        132      134       +2     
Impacted Files Coverage Δ
src/formatters/trivia_util.rs 95.07% <93.10%> (-0.11%) ⬇️
src/formatters/assignment.rs 97.97% <100.00%> (-0.03%) ⬇️
src/formatters/block.rs 97.90% <100.00%> (-0.02%) ⬇️
src/formatters/table.rs 98.72% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2022

Repo Comparison Test

diff --git ORI/zombie-strike/src/hub/StarterGui/MainGui/App/Shopkeeper2/init.lua ALT/zombie-strike/src/hub/StarterGui/MainGui/App/Shopkeeper2/init.lua
index 5de9236..9e24393 100644
--- ORI/zombie-strike/src/hub/StarterGui/MainGui/App/Shopkeeper2/init.lua
+++ ALT/zombie-strike/src/hub/StarterGui/MainGui/App/Shopkeeper2/init.lua
@@ -349,126 +349,125 @@ function OpenedItem:render()
 				e(GoldCount),
 			}),
 
-			PerkDetails = self.props.itemTypeData.UpgradePerks
-				and e(PerkDetails, {
-					Perks = self.props.item.Perks,
-					Seed = self.props.item.Seed,
+			PerkDetails = self.props.itemTypeData.UpgradePerks and e(PerkDetails, {
+				Perks = self.props.item.Perks,
+				Seed = self.props.item.Seed,
+
+				RenderParent = function(element, size)
+					return e(HoverStack, {
+						Render = function(hovered, hover, unhover)
+							local upgradeButtons = {}
+
+							for perkIndex, perk in ipairs(self.props.item.Perks) do
+								if perk.Upgrades < PerkUtil.MAX_PERK_UPGRADES then
+									local upgradeCost = Upgrades.CostToUpgradePerk(perk)
+									local tooltipSize = TextService:GetTextSize(
+										upgradeCost,
+										22,
+										Enum.Font.GothamBold,
+										Vector2.new(250, math.huge)
+									)
+
+									upgradeButtons["Perk" .. perkIndex] = e("ImageButton", {
+										AnchorPoint = Vector2.new(0, 0),
+										BackgroundTransparency = 1,
+										Image = "rbxassetid://711219057",
+										LayoutOrder = perkIndex,
+										Position = UDim2.fromScale(1, 0),
+										Size = UDim2.fromScale(1, 1),
+										ZIndex = -perkIndex,
 
-					RenderParent = function(element, size)
-						return e(HoverStack, {
-							Render = function(hovered, hover, unhover)
-								local upgradeButtons = {}
-
-								for perkIndex, perk in ipairs(self.props.item.Perks) do
-									if perk.Upgrades < PerkUtil.MAX_PERK_UPGRADES then
-										local upgradeCost = Upgrades.CostToUpgradePerk(perk)
-										local tooltipSize = TextService:GetTextSize(
-											upgradeCost,
-											22,
-											Enum.Font.GothamBold,
-											Vector2.new(250, math.huge)
-										)
-
-										upgradeButtons["Perk" .. perkIndex] = e("ImageButton", {
-											AnchorPoint = Vector2.new(0, 0),
-											BackgroundTransparency = 1,
-											Image = "rbxassetid://711219057",
-											LayoutOrder = perkIndex,
-											Position = UDim2.fromScale(1, 0),
-											Size = UDim2.fromScale(1, 1),
-											ZIndex = -perkIndex,
-
-											[Roact.Event.Activated] = self.createUpgradePerk(perkIndex, upgradeCost),
-											[Roact.Event.MouseEnter] = hover(perkIndex),
-											[Roact.Event.MouseLeave] = unhover(perkIndex),
-										}, {
-											e("UIAspectRatioConstraint"),
-
-											Tooltip = e(Tooltip, {
-												Open = hovered == perkIndex,
-												Size = UDim2.fromOffset(tooltipSize.X + 50, tooltipSize.Y + 16),
-												Render = function(transparency)
-													return {
-														Inner = e("Frame", {
+										[Roact.Event.Activated] = self.createUpgradePerk(perkIndex, upgradeCost),
+										[Roact.Event.MouseEnter] = hover(perkIndex),
+										[Roact.Event.MouseLeave] = unhover(perkIndex),
+									}, {
+										e("UIAspectRatioConstraint"),
+
+										Tooltip = e(Tooltip, {
+											Open = hovered == perkIndex,
+											Size = UDim2.fromOffset(tooltipSize.X + 50, tooltipSize.Y + 16),
+											Render = function(transparency)
+												return {
+													Inner = e("Frame", {
+														BackgroundTransparency = 1,
+														Position = UDim2.fromOffset(0, 12),
+														Size = UDim2.new(1, 0, 1, -12),
+													}, {
+														UIListLayout = e("UIListLayout", {
+															FillDirection = Enum.FillDirection.Horizontal,
+															HorizontalAlignment = Enum.HorizontalAlignment.Center,
+															SortOrder = Enum.SortOrder.LayoutOrder,
+															VerticalAlignment = Enum.VerticalAlignment.Center,
+														}),
+
+														Label = e("TextLabel", {
+															BackgroundTransparency = 1,
+															Font = Enum.Font.GothamBold,
+															Size = UDim2.new(0, tooltipSize.X, 1, 0),
+															Text = upgradeCost,
+															TextColor3 = Color3.new(1, 1, 1),
+															TextSize = 22,
+															TextTransparency = transparency,
+														}),
+
+														CapIcon = e("ImageLabel", {
 															BackgroundTransparency = 1,
-															Position = UDim2.fromOffset(0, 12),
-															Size = UDim2.new(1, 0, 1, -12),
+															Image = ImageCap,
+															ImageTransparency = transparency,
+															LayoutOrder = 2,
+															Size = UDim2.fromScale(1, 1),
 														}, {
-															UIListLayout = e("UIListLayout", {
-																FillDirection = Enum.FillDirection.Horizontal,
-																HorizontalAlignment = Enum.HorizontalAlignment.Center,
-																SortOrder = Enum.SortOrder.LayoutOrder,
-																VerticalAlignment = Enum.VerticalAlignment.Center,
-															}),
-
-															Label = e("TextLabel", {
-																BackgroundTransparency = 1,
-																Font = Enum.Font.GothamBold,
-																Size = UDim2.new(0, tooltipSize.X, 1, 0),
-																Text = upgradeCost,
-																TextColor3 = Color3.new(1, 1, 1),
-																TextSize = 22,
-																TextTransparency = transparency,
-															}),
-
-															CapIcon = e("ImageLabel", {
-																BackgroundTransparency = 1,
-																Image = ImageCap,
-																ImageTransparency = transparency,
-																LayoutOrder = 2,
-																Size = UDim2.fromScale(1, 1),
-															}, {
-																UIAspectRatioConstraint = e("UIAspectRatioConstraint"),
-															}),
+															UIAspectRatioConstraint = e("UIAspectRatioConstraint"),
 														}),
-													}
-												end,
-											}),
-										})
-									else
-										-- Take up space
-										upgradeButtons["Perk" .. perkIndex] = e("Frame", {
-											AnchorPoint = Vector2.new(0, 0),
-											BackgroundTransparency = 1,
-											LayoutOrder = perkIndex,
-											Position = UDim2.fromScale(1, 0),
-											Size = UDim2.fromScale(1, 1),
-										}, {
-											e("UIAspectRatioConstraint"),
-										})
-									end
+													}),
+												}
+											end,
+										}),
+									})
+								else
+									-- Take up space
+									upgradeButtons["Perk" .. perkIndex] = e("Frame", {
+										AnchorPoint = Vector2.new(0, 0),
+										BackgroundTransparency = 1,
+										LayoutOrder = perkIndex,
+										Position = UDim2.fromScale(1, 0),
+										Size = UDim2.fromScale(1, 1),
+									}, {
+										e("UIAspectRatioConstraint"),
+									})
 								end
+							end
+
+							return e("Frame", {
+								AnchorPoint = Vector2.new(1, 0.5),
+								BackgroundTransparency = 1,
+								Position = UDim2.fromScale(1, 0.5),
+								Size = size,
+							}, {
+								PerkDetails = element,
+
+								UIScale = e("UIScale", {
+									Scale = 1.4,
+								}),
 
-								return e("Frame", {
-									AnchorPoint = Vector2.new(1, 0.5),
+								UpgradeButton = e("Frame", {
 									BackgroundTransparency = 1,
-									Position = UDim2.fromScale(1, 0.5),
-									Size = size,
+									Position = UDim2.fromScale(1, 0),
+									Size = UDim2.new(0, 45, 1, 0),
 								}, {
-									PerkDetails = element,
-
-									UIScale = e("UIScale", {
-										Scale = 1.4,
+									UIListLayout = e("UIListLayout", {
+										Padding = UDim.new(1 / (3 * #self.props.item.Perks), 0),
+										SortOrder = Enum.SortOrder.LayoutOrder,
+										VerticalAlignment = Enum.VerticalAlignment.Center,
 									}),
 
-									UpgradeButton = e("Frame", {
-										BackgroundTransparency = 1,
-										Position = UDim2.fromScale(1, 0),
-										Size = UDim2.new(0, 45, 1, 0),
-									}, {
-										UIListLayout = e("UIListLayout", {
-											Padding = UDim.new(1 / (3 * #self.props.item.Perks), 0),
-											SortOrder = Enum.SortOrder.LayoutOrder,
-											VerticalAlignment = Enum.VerticalAlignment.Center,
-										}),
-
-										UpgradeButtons = Roact.createFragment(upgradeButtons),
-									}),
-								})
-							end,
-						})
-					end,
-				}),
+									UpgradeButtons = Roact.createFragment(upgradeButtons),
+								}),
+							})
+						end,
+					})
+				end,
+			}),
 
 			BasicUpgrade = self.props.itemTypeData.UpgradeBasic and e("Frame", {
 				AnchorPoint = Vector2.new(1, 0.5),
diff --git ORI/lit/deps/coro-wrapper.lua ALT/lit/deps/coro-wrapper.lua
index c4c43d6..f943b65 100644
--- ORI/lit/deps/coro-wrapper.lua
+++ ALT/lit/deps/coro-wrapper.lua
@@ -50,13 +50,12 @@ local function merger(read, scan)
 				return chunk
 			end
 		end
-	end,
-		
-		-- This is used to update or disable the scan function.  It's useful for
-		-- protocols that change mid-stream (like HTTP upgrades in websockets)
+	end, 
+	-- This is used to update or disable the scan function.  It's useful for
+	-- protocols that change mid-stream (like HTTP upgrades in websockets)
 function(newScan)
-			scan = newScan
-		end
+		scan = newScan
+	end
 end
 
 -- Decoder takes in a read function and a decode function and returns a new
@@ -123,10 +122,9 @@ local function decoder(read, decode)
 				return item
 			end
 		end
-	end,
-		function(newDecode)
-			decode = newDecode
-		end
+	end, function(newDecode)
+		decode = newDecode
+	end
 end
 
 local function encoder(write, encode)

@JohnnyMorganz JohnnyMorganz added this to the 0.16 milestone Dec 7, 2022
@github-actions
Copy link
Contributor

Repo Comparison Test

diff --git ORI/zombie-strike/src/hub/StarterGui/MainGui/App/Shopkeeper2/init.lua ALT/zombie-strike/src/hub/StarterGui/MainGui/App/Shopkeeper2/init.lua
index 5de9236..9e24393 100644
--- ORI/zombie-strike/src/hub/StarterGui/MainGui/App/Shopkeeper2/init.lua
+++ ALT/zombie-strike/src/hub/StarterGui/MainGui/App/Shopkeeper2/init.lua
@@ -349,126 +349,125 @@ function OpenedItem:render()
 				e(GoldCount),
 			}),
 
-			PerkDetails = self.props.itemTypeData.UpgradePerks
-				and e(PerkDetails, {
-					Perks = self.props.item.Perks,
-					Seed = self.props.item.Seed,
+			PerkDetails = self.props.itemTypeData.UpgradePerks and e(PerkDetails, {
+				Perks = self.props.item.Perks,
+				Seed = self.props.item.Seed,
+
+				RenderParent = function(element, size)
+					return e(HoverStack, {
+						Render = function(hovered, hover, unhover)
+							local upgradeButtons = {}
+
+							for perkIndex, perk in ipairs(self.props.item.Perks) do
+								if perk.Upgrades < PerkUtil.MAX_PERK_UPGRADES then
+									local upgradeCost = Upgrades.CostToUpgradePerk(perk)
+									local tooltipSize = TextService:GetTextSize(
+										upgradeCost,
+										22,
+										Enum.Font.GothamBold,
+										Vector2.new(250, math.huge)
+									)
+
+									upgradeButtons["Perk" .. perkIndex] = e("ImageButton", {
+										AnchorPoint = Vector2.new(0, 0),
+										BackgroundTransparency = 1,
+										Image = "rbxassetid://711219057",
+										LayoutOrder = perkIndex,
+										Position = UDim2.fromScale(1, 0),
+										Size = UDim2.fromScale(1, 1),
+										ZIndex = -perkIndex,
 
-					RenderParent = function(element, size)
-						return e(HoverStack, {
-							Render = function(hovered, hover, unhover)
-								local upgradeButtons = {}
-
-								for perkIndex, perk in ipairs(self.props.item.Perks) do
-									if perk.Upgrades < PerkUtil.MAX_PERK_UPGRADES then
-										local upgradeCost = Upgrades.CostToUpgradePerk(perk)
-										local tooltipSize = TextService:GetTextSize(
-											upgradeCost,
-											22,
-											Enum.Font.GothamBold,
-											Vector2.new(250, math.huge)
-										)
-
-										upgradeButtons["Perk" .. perkIndex] = e("ImageButton", {
-											AnchorPoint = Vector2.new(0, 0),
-											BackgroundTransparency = 1,
-											Image = "rbxassetid://711219057",
-											LayoutOrder = perkIndex,
-											Position = UDim2.fromScale(1, 0),
-											Size = UDim2.fromScale(1, 1),
-											ZIndex = -perkIndex,
-
-											[Roact.Event.Activated] = self.createUpgradePerk(perkIndex, upgradeCost),
-											[Roact.Event.MouseEnter] = hover(perkIndex),
-											[Roact.Event.MouseLeave] = unhover(perkIndex),
-										}, {
-											e("UIAspectRatioConstraint"),
-
-											Tooltip = e(Tooltip, {
-												Open = hovered == perkIndex,
-												Size = UDim2.fromOffset(tooltipSize.X + 50, tooltipSize.Y + 16),
-												Render = function(transparency)
-													return {
-														Inner = e("Frame", {
+										[Roact.Event.Activated] = self.createUpgradePerk(perkIndex, upgradeCost),
+										[Roact.Event.MouseEnter] = hover(perkIndex),
+										[Roact.Event.MouseLeave] = unhover(perkIndex),
+									}, {
+										e("UIAspectRatioConstraint"),
+
+										Tooltip = e(Tooltip, {
+											Open = hovered == perkIndex,
+											Size = UDim2.fromOffset(tooltipSize.X + 50, tooltipSize.Y + 16),
+											Render = function(transparency)
+												return {
+													Inner = e("Frame", {
+														BackgroundTransparency = 1,
+														Position = UDim2.fromOffset(0, 12),
+														Size = UDim2.new(1, 0, 1, -12),
+													}, {
+														UIListLayout = e("UIListLayout", {
+															FillDirection = Enum.FillDirection.Horizontal,
+															HorizontalAlignment = Enum.HorizontalAlignment.Center,
+															SortOrder = Enum.SortOrder.LayoutOrder,
+															VerticalAlignment = Enum.VerticalAlignment.Center,
+														}),
+
+														Label = e("TextLabel", {
+															BackgroundTransparency = 1,
+															Font = Enum.Font.GothamBold,
+															Size = UDim2.new(0, tooltipSize.X, 1, 0),
+															Text = upgradeCost,
+															TextColor3 = Color3.new(1, 1, 1),
+															TextSize = 22,
+															TextTransparency = transparency,
+														}),
+
+														CapIcon = e("ImageLabel", {
 															BackgroundTransparency = 1,
-															Position = UDim2.fromOffset(0, 12),
-															Size = UDim2.new(1, 0, 1, -12),
+															Image = ImageCap,
+															ImageTransparency = transparency,
+															LayoutOrder = 2,
+															Size = UDim2.fromScale(1, 1),
 														}, {
-															UIListLayout = e("UIListLayout", {
-																FillDirection = Enum.FillDirection.Horizontal,
-																HorizontalAlignment = Enum.HorizontalAlignment.Center,
-																SortOrder = Enum.SortOrder.LayoutOrder,
-																VerticalAlignment = Enum.VerticalAlignment.Center,
-															}),
-
-															Label = e("TextLabel", {
-																BackgroundTransparency = 1,
-																Font = Enum.Font.GothamBold,
-																Size = UDim2.new(0, tooltipSize.X, 1, 0),
-																Text = upgradeCost,
-																TextColor3 = Color3.new(1, 1, 1),
-																TextSize = 22,
-																TextTransparency = transparency,
-															}),
-
-															CapIcon = e("ImageLabel", {
-																BackgroundTransparency = 1,
-																Image = ImageCap,
-																ImageTransparency = transparency,
-																LayoutOrder = 2,
-																Size = UDim2.fromScale(1, 1),
-															}, {
-																UIAspectRatioConstraint = e("UIAspectRatioConstraint"),
-															}),
+															UIAspectRatioConstraint = e("UIAspectRatioConstraint"),
 														}),
-													}
-												end,
-											}),
-										})
-									else
-										-- Take up space
-										upgradeButtons["Perk" .. perkIndex] = e("Frame", {
-											AnchorPoint = Vector2.new(0, 0),
-											BackgroundTransparency = 1,
-											LayoutOrder = perkIndex,
-											Position = UDim2.fromScale(1, 0),
-											Size = UDim2.fromScale(1, 1),
-										}, {
-											e("UIAspectRatioConstraint"),
-										})
-									end
+													}),
+												}
+											end,
+										}),
+									})
+								else
+									-- Take up space
+									upgradeButtons["Perk" .. perkIndex] = e("Frame", {
+										AnchorPoint = Vector2.new(0, 0),
+										BackgroundTransparency = 1,
+										LayoutOrder = perkIndex,
+										Position = UDim2.fromScale(1, 0),
+										Size = UDim2.fromScale(1, 1),
+									}, {
+										e("UIAspectRatioConstraint"),
+									})
 								end
+							end
+
+							return e("Frame", {
+								AnchorPoint = Vector2.new(1, 0.5),
+								BackgroundTransparency = 1,
+								Position = UDim2.fromScale(1, 0.5),
+								Size = size,
+							}, {
+								PerkDetails = element,
+
+								UIScale = e("UIScale", {
+									Scale = 1.4,
+								}),
 
-								return e("Frame", {
-									AnchorPoint = Vector2.new(1, 0.5),
+								UpgradeButton = e("Frame", {
 									BackgroundTransparency = 1,
-									Position = UDim2.fromScale(1, 0.5),
-									Size = size,
+									Position = UDim2.fromScale(1, 0),
+									Size = UDim2.new(0, 45, 1, 0),
 								}, {
-									PerkDetails = element,
-
-									UIScale = e("UIScale", {
-										Scale = 1.4,
+									UIListLayout = e("UIListLayout", {
+										Padding = UDim.new(1 / (3 * #self.props.item.Perks), 0),
+										SortOrder = Enum.SortOrder.LayoutOrder,
+										VerticalAlignment = Enum.VerticalAlignment.Center,
 									}),
 
-									UpgradeButton = e("Frame", {
-										BackgroundTransparency = 1,
-										Position = UDim2.fromScale(1, 0),
-										Size = UDim2.new(0, 45, 1, 0),
-									}, {
-										UIListLayout = e("UIListLayout", {
-											Padding = UDim.new(1 / (3 * #self.props.item.Perks), 0),
-											SortOrder = Enum.SortOrder.LayoutOrder,
-											VerticalAlignment = Enum.VerticalAlignment.Center,
-										}),
-
-										UpgradeButtons = Roact.createFragment(upgradeButtons),
-									}),
-								})
-							end,
-						})
-					end,
-				}),
+									UpgradeButtons = Roact.createFragment(upgradeButtons),
+								}),
+							})
+						end,
+					})
+				end,
+			}),
 
 			BasicUpgrade = self.props.itemTypeData.UpgradeBasic and e("Frame", {
 				AnchorPoint = Vector2.new(1, 0.5),
diff --git ORI/lit/deps/coro-wrapper.lua ALT/lit/deps/coro-wrapper.lua
index c4c43d6..f943b65 100644
--- ORI/lit/deps/coro-wrapper.lua
+++ ALT/lit/deps/coro-wrapper.lua
@@ -50,13 +50,12 @@ local function merger(read, scan)
 				return chunk
 			end
 		end
-	end,
-		
-		-- This is used to update or disable the scan function.  It's useful for
-		-- protocols that change mid-stream (like HTTP upgrades in websockets)
+	end, 
+	-- This is used to update or disable the scan function.  It's useful for
+	-- protocols that change mid-stream (like HTTP upgrades in websockets)
 function(newScan)
-			scan = newScan
-		end
+		scan = newScan
+	end
 end
 
 -- Decoder takes in a read function and a decode function and returns a new
@@ -123,10 +122,9 @@ local function decoder(read, decode)
 				return item
 			end
 		end
-	end,
-		function(newDecode)
-			decode = newDecode
-		end
+	end, function(newDecode)
+		decode = newDecode
+	end
 end
 
 local function encoder(write, encode)

@JohnnyMorganz JohnnyMorganz merged commit 94732ec into main Jan 12, 2023
@JohnnyMorganz JohnnyMorganz deleted the profiling-improvements branch January 12, 2023 13:29
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