mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Performance: accelerate project opening with parallel link creation and batch UDP port allocation
- Narrow IOU lock scope to only cover application_id allocation, allowing concurrent IOU node creation via Pool(concurrency=5) - Parallelize link creation during project.open() using Pool(concurrency=5) instead of sequential processing - Add batch UDP port allocation endpoint on compute to allocate N ports in a single HTTP call - Pre-allocate UDP ports per compute before link creation during project loading, reducing HTTP round-trips - UDPLink.create() falls back to individual port allocation if no pre-allocated port is available
This commit is contained in:
3 files changed
+131
-48
No files matched your search
@@ -55,6 +55,23 @@ def allocate_udp_port(project_id: UUID) -> dict:
|
||||
return {"udp_port": udp_port}
|
||||
|
||||
|
||||
@router.post("/projects/{project_id}/ports/udp/batch", status_code=status.HTTP_201_CREATED)
|
||||
def batch_allocate_udp_ports(project_id: UUID, body: dict) -> dict:
|
||||
"""
|
||||
Allocate multiple UDP ports on the compute in a single call.
|
||||
|
||||
Used during project loading to pre-allocate all required UDP ports
|
||||
before creating links, reducing HTTP round-trips.
|
||||
"""
|
||||
|
||||
count = body.get("count", 1)
|
||||
pm = ProjectManager.instance()
|
||||
project = pm.get_project(str(project_id))
|
||||
m = PortManager.instance()
|
||||
udp_ports = [m.get_free_udp_port(project) for _ in range(count)]
|
||||
return {"udp_ports": udp_ports}
|
||||
|
||||
|
||||
@router.get("/network/interfaces")
|
||||
def network_interfaces() -> List[dict]:
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user