Skip to content

Conversation

dhiltgen
Copy link
Collaborator

Ensure the cleanup step completes before starting to build targets

llama/Makefile Outdated
@@ -278,7 +278,7 @@ DIST_RUNNERS = $(addprefix $(RUNNERS_DIST_DIR)/,$(addsuffix /ollama_llama_server
PAYLOAD_RUNNERS = $(addprefix $(RUNNERS_PAYLOAD_DIR)/,$(addsuffix /ollama_llama_server$(EXE_EXT).gz,$(RUNNERS)))
BUILD_RUNNERS = $(addprefix $(RUNNERS_BUILD_DIR)/,$(addsuffix /ollama_llama_server$(EXE_EXT),$(RUNNERS)))

all: clean-payload dist payload
all: clean-payload .WAIT dist payload
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This didn't fix the problem on my system but I guess there might be multiple similar races.

For me, it looks like there is a race within clean-payload itself - between rm and mkdir. Adding this solves the problem:
.NOTPARALLEL clean-payload

We probably still the need the .WAIT in all to solve the race between those dependencies.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

.NOTPARALLEL: ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also suggest not depending on clean in the default target

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean-payload just cleans the final build products, not everything. We need to do it so we can switch between old and new runners.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worth noting this might not work as expected. .NOTPARALLEL is used to signal its prerequisites, clean-payload in this case, should be run sequentially. all will still execute its prerequisites in parallel. what you probably want is to make all .NOTPARALLEL

https://www.gnu.org/software/make/manual/html_node/Special-Targets.html#index-parallel-execution_002c-overriding

@dhiltgen dhiltgen force-pushed the go_server_race branch 2 times, most recently from f1da9b2 to ce1415e Compare September 20, 2024 16:04
Ensure the cleanup step completes before starting to build targets
@jessegross
Copy link
Contributor

It looks like .NOTPARALLEL is recursive so this prevents the entire build from being parallel, which is a significant slowdown. Surprisingly (to me at least), if I apply it to only clean-payload it also prevents parallel compilation. I don't see this with .WAIT, as expected. I'm not sure what the best syntax is to allow compilation to happen in parallel but all of the pre- and post-requisits to be serialized around it.

@dhiltgen
Copy link
Collaborator Author

Closing in favor of a more extensive refactoring in #6924

@dhiltgen dhiltgen closed this Sep 23, 2024
@dhiltgen dhiltgen deleted the go_server_race branch September 23, 2024 19:04
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.

3 participants