Skip to content

Commit

Permalink
Log slow grist cost generator item lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
kirderf1 committed Apr 14, 2024
1 parent f315900 commit 42bec0b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]

### Fixed

- More logging for grist cost generator to help identify bottlenecks

## [1.20.1-1.12.0.0] - 2024-04-13

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import com.mraof.minestuck.Minestuck;
import com.mraof.minestuck.MinestuckConfig;
import com.mraof.minestuck.api.alchemy.GristSet;
import com.mraof.minestuck.api.alchemy.recipe.generator.GeneratedCostProvider;
import com.mraof.minestuck.api.alchemy.recipe.GristCostRecipe;
import com.mraof.minestuck.api.alchemy.recipe.generator.GeneratedCostProvider;
import com.mraof.minestuck.api.alchemy.recipe.generator.GristCostResult;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
Expand Down Expand Up @@ -80,9 +80,15 @@ private static void run(RecipeManager recipes)
//Iterate through items
process.providersByItem.keySet().stream()
.sorted(Comparator.comparingInt(item -> -lookupCount.getInt(item)))
.forEach(item ->
lookupCost(process, new GenerationContext(item, (context1) -> lookupCost(process, context1)))
);
.forEach(item -> {
long itemStartTime = System.currentTimeMillis();

lookupCost(process, new GenerationContext(item, (context1) -> lookupCost(process, context1)));

double itemTime = (System.currentTimeMillis() - itemStartTime)/1000D;
if(itemTime > 0.5)
LOGGER.warn("Cost generation for {} took {}s", ForgeRegistries.ITEMS.getKey(item), itemTime);
});

for(GeneratedCostProvider provider : process.providers)
{
Expand All @@ -95,7 +101,7 @@ private static void run(RecipeManager recipes)
}
}

LOGGER.debug("Finished grist cost generation in {}s", (System.currentTimeMillis() - startTime)/1000D);
LOGGER.info("Finished grist cost generation in {}s", (System.currentTimeMillis() - startTime)/1000D);
}

private static GristSet lookupCost(GeneratorProcess process, GenerationContext context)
Expand Down

0 comments on commit 42bec0b

Please sign in to comment.