Repository navigation
feat(ai): parallelize AgentSpec storage writes aligned with Skill - #15165
Merged
KomachiSion merged 1 commit intoMay 18, 2026
Merged
Conversation
- Add dedicated AGENTSPEC_STORAGE_IO_EXECUTOR in ExecutorUtils, isolated from the Skill executor and configurable via nacos.ai.agentspec.storage.io.concurrency. - Extract saveAgentSpecFilesConcurrently helper in AgentSpecOperationServiceImpl; replace serial for-loop in createDraftWithAgentSpec and writeAgentSpecToStorage with one helper call. Tasks run on the dedicated executor and unwrap NacosException from CompletionException to preserve the previous serial semantics. - Add ExecutorUtilsTest and AgentSpecConcurrentSaveTest to pin the invariants: executor isolation, dedicated thread name, save count for manifest-only and multi-resource cases, distinct StorageKeys, and NacosException propagation.
|
Thanks for your this PR. 🙏 感谢您提交的PR。 🙏 |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
KomachiSion
approved these changes
May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
When publishing or updating an AgentSpec that contains multiple resource files,
AgentSpecOperationServiceImplpreviously serialized all storage writes(manifest.json + N resources) into a single
forloop on the caller thread.Each write goes through
NacosConfigAiResourceStorageand ultimately becomes apublishConfiground-trip, so end-to-end latency grew linearly with the numberof resources in an AgentSpec.
This PR aligns AgentSpec writes with the existing
SkillOperationServiceImplimplementation by persisting all files concurrently on a dedicated executor,
preserving the original exception semantics.
Brief changelog
ai/utils/ExecutorUtilsAGENTSPEC_STORAGE_IO_EXECUTOR, a fixed-size pool isolated from theSkill executor.
nacos.ai.agentspec.storage.io.concurrency(default = available processors, min = 1).
resolveStorageIoConcurrencytoresolveSkillStorageIoConcurrency; add the AgentSpec counterpart.ai/service/agentspecs/AgentSpecOperationServiceImplsaveAgentSpecFilesConcurrently(namespaceId, agentSpec, version, uniformId)and replace the serial loop in bothcreateDraftWithAgentSpecandwriteAgentSpecToStorage.CompletableFuture.runAsyncon thededicated executor; tasks wrap the underlying
NacosExceptionin aCompletionException, which is unwrapped afterallOf().join()so theoutward exception contract is identical to the previous serial code.
resolveStorageProvider()is now invoked once per call instead of onceper file.
ai/utils/ExecutorUtilsTest: pin executor isolation, non-null contract,and the dedicated
com.alibaba.nacos.ai.agentspec.storage-iothread nameprefix.
ai/service/agentspecs/AgentSpecConcurrentSaveTest: pin save count formanifest-only and multi-resource cases, distinct StorageKeys, executor
membership, and
NacosExceptionpropagation.Verifying this change
mvn -pl ai -am test -Dtest='ExecutorUtilsTest,AgentSpecConcurrentSaveTest' -Dsurefire.failIfNoSpecifiedTests=false→ 8/8 pass.mvn -pl ai -am test(full AI module): AgentSpec suites 141/141 pass,Skill suites 66/66 pass,
SkillAdminControllerTest24/24 pass — noregression on existing tests.
mvn -pl ai -am checkstyle:check: pass.AgentSpecOperationServiceImplare intentionally leftserial (matches Skill behavior).
Follow this checklist to help us incorporate your contribution quickly and easily:
[ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.mvn -B clean package apache-rat:check spotbugs:check -DskipTeststo make sure basic checks pass. Runmvn clean installto make sure unit-test pass. Runmvn clean test-compile failsafe:integration-testto make sure integration-test pass.