Any way to speed up InsertService

Hi there. I’m a developer for Noob Tower Defense. We have a lot of humanoids with a lot of hats/meshes/shirts in 1 package which our game loads using InsertService.

This package is massive, and takes a full 6 to 10 seconds to load each time, which causes a massive lag spike and makes the game un-playable for that time. We’re using :LoadAssetVersion(). We use packages as these characters need to be replicated across multiple places.

I’m aware that this isn’t the best way of doing this, but this is a pretty old system written by someone else that I don’t want to rewrite unless I absolutely have to. So I’m asking here if anyone has advice on if it’s possible to make this faster or not lag the whole server. If not, no worries and I’ll probably rewrite it to either split the large package up into smaller packages or find some way of reducing the total size.
image

local success, result = pcall(function()
	local lastest_version = InsertService:GetLatestAssetVersionAsync(UnitSkins_AssetID)
	return InsertService:LoadAssetVersion(lastest_version) :: Instance
end)

Thanks!
-Emma

I guess the main way is to split it up using either Coroutines or task.spawn.

Note that you’ll need to have a counter going so you know when all the skins have either loaded or errored, so you know when the code can proceed.

Preloading is the best and simplest option if you dont want to rewrite, store any loaded in replicated storage- should not affect server load at all besides the preload part.

Multithreading difference would be useless here because LoadAssetVersion yields regardless. That’s where your wait time is coming from, not because your code cant execute fast enough.

This being said, as stated above, if you’re loading 30 assets back to back on the same serial thread, those wait times add up. Take a look at roblox’s rate limits, and see if you can make multiple requests at once. Best thing to do would be to write a module that manages and throttles all of that traffic, and caches returns.

If you really want to go crazy with this, you could go as far as to break up the assets into smaller chunks further decreasing load times.

If you’re loading one object then no. There isn’t. Unless you use packages. They pretty much do what you want here in a better way.

If you are loading multiple things then use parallel execution using task.spawn(function() end).

please dont use task.spawn omg coroutine.wrap(func)() is better :handshake: :handshake:

local function FastLoad()
   task.spawn(function()
     local success, result = pcall(function()
	     local lastest_version = InsertService:GetLatestAssetVersionAsync(UnitSkins_AssetID)
	     return InsertService:LoadAssetVersion(lastest_version) :: Instance
      end)
   end)
end

No need to give credits

This won’t solve anything. It’s not loading several smaller assets, it’s loading 1 large asset. I’m looking for a way to do it without needing to split up the package as that’ll be really painful and take a while. I already know how to load several things in parallel.