feat: Complete Ollama CPU optimization for TaskMaster AI
- Optimize Ollama service configuration for maximum CPU performance - Increase OLLAMA_NUM_PARALLEL from 2 to 4 workers - Increase OLLAMA_CONTEXT_LENGTH from 4096 to 8192 tokens - Add OLLAMA_KV_CACHE_TYPE=q8_0 for memory efficiency - Set OLLAMA_LLM_LIBRARY=cpu_avx2 for optimal CPU performance - Configure OpenMP threading with 8 threads and core binding - Add comprehensive systemd resource limits and CPU quotas - Remove incompatible NUMA policy setting - Upgrade TaskMaster AI model ecosystem - Main model: qwen3:4b → qwen2.5-coder:7b (specialized coding model) - Research model: deepseek-r1:1.5b → deepseek-r1:7b (enhanced reasoning) - Fallback model: gemma3:4b-it-qat → llama3.3:8b (reliable general purpose) - Create comprehensive optimization and management scripts - Add ollama-optimize.sh for system optimization and benchmarking - Add update-taskmaster-models.sh for TaskMaster configuration management - Include model installation, performance testing, and system info functions - Update TaskMaster AI configuration - Configure optimized models with grey-area:11434 endpoint - Set performance parameters for 8192 context window - Add connection timeout and retry settings - Fix flake configuration issues - Remove nested packages attribute in packages/default.nix - Fix package references in modules/users/geir.nix - Clean up obsolete package files - Add comprehensive documentation - Document complete optimization process and results - Include performance benchmarking results - Provide deployment instructions and troubleshooting guide Successfully deployed via deploy-rs with 3-4x performance improvement estimated. All optimizations tested and verified on grey-area server (24-core Xeon, 31GB RAM).
This commit is contained in:
parent
74142365eb
commit
9d8952c4ce
14 changed files with 881 additions and 626 deletions
|
@ -1,3 +1,92 @@
|
|||
# Default.nix for lab-tool
|
||||
# Provides the lab-tool package for inclusion in other Nix expressions
|
||||
(import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz") {}).callPackage ./. {}
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
makeWrapper,
|
||||
guile_3_0,
|
||||
guile-ssh,
|
||||
guile-json,
|
||||
guile-git,
|
||||
guile-gcrypt,
|
||||
openssh,
|
||||
git,
|
||||
nixos-rebuild,
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
pname = "lab-tool";
|
||||
version = "0.1.0";
|
||||
|
||||
src = ./.;
|
||||
|
||||
buildInputs = [
|
||||
guile_3_0
|
||||
guile-ssh
|
||||
guile-json
|
||||
guile-git
|
||||
guile-gcrypt
|
||||
];
|
||||
nativeBuildInputs = [makeWrapper];
|
||||
|
||||
buildPhase = ''
|
||||
# Compile Guile modules for better performance
|
||||
mkdir -p $out/share/guile/site/3.0
|
||||
cp -r . $out/share/guile/site/3.0/lab-tool/
|
||||
|
||||
# Compile .scm files to .go files
|
||||
for file in $(find . -name "*.scm"); do
|
||||
echo "Compiling $file"
|
||||
guild compile -L . -o $out/share/guile/site/3.0/''${file%.scm}.go $file || true
|
||||
done
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
|
||||
# Create the main lab executable
|
||||
cat > $out/bin/lab << EOF
|
||||
#!/usr/bin/env bash
|
||||
export GUILE_LOAD_PATH="$out/share/guile/site/3.0/lab-tool:${guile-ssh}/share/guile/site/3.0:${guile-json}/share/guile/site/3.0:${guile-git}/share/guile/site/3.0:${guile-gcrypt}/share/guile/site/3.0:\$GUILE_LOAD_PATH"
|
||||
export GUILE_LOAD_COMPILED_PATH="$out/share/guile/site/3.0/lab-tool:${guile-ssh}/lib/guile/3.0/site-ccache:${guile-json}/lib/guile/3.0/site-ccache:${guile-git}/lib/guile/3.0/site-ccache:${guile-gcrypt}/lib/guile/3.0/site-ccache:\$GUILE_LOAD_COMPILED_PATH"
|
||||
exec ${guile_3_0}/bin/guile "$out/share/guile/site/3.0/lab-tool/main.scm" "\$@"
|
||||
EOF
|
||||
chmod +x $out/bin/lab
|
||||
|
||||
# Create MCP server executable
|
||||
cat > $out/bin/lab-mcp-server << EOF
|
||||
#!/usr/bin/env bash
|
||||
export GUILE_LOAD_PATH="$out/share/guile/site/3.0/lab-tool:${guile-ssh}/share/guile/site/3.0:${guile-json}/share/guile/site/3.0:${guile-git}/share/guile/site/3.0:${guile-gcrypt}/share/guile/site/3.0:\$GUILE_LOAD_PATH"
|
||||
export GUILE_LOAD_COMPILED_PATH="$out/share/guile/site/3.0/lab-tool:${guile-ssh}/lib/guile/3.0/site-ccache:${guile-json}/lib/guile/3.0/site-ccache:${guile-git}/lib/guile/3.0/site-ccache:${guile-gcrypt}/lib/guile/3.0/site-ccache:\$GUILE_LOAD_COMPILED_PATH"
|
||||
exec ${guile_3_0}/bin/guile -L "$out/share/guile/site/3.0/lab-tool" -c "(use-modules (mcp server)) (run-mcp-server)"
|
||||
EOF
|
||||
chmod +x $out/bin/lab-mcp-server
|
||||
|
||||
# Wrap executables with proper environment and Guile library paths
|
||||
wrapProgram $out/bin/lab \
|
||||
--prefix PATH : ${lib.makeBinPath [openssh git nixos-rebuild]} \
|
||||
--prefix GUILE_LOAD_PATH : ${guile-ssh}/share/guile/site/3.0 \
|
||||
--prefix GUILE_LOAD_PATH : ${guile-json}/share/guile/site/3.0 \
|
||||
--prefix GUILE_LOAD_PATH : ${guile-git}/share/guile/site/3.0 \
|
||||
--prefix GUILE_LOAD_PATH : ${guile-gcrypt}/share/guile/site/3.0 \
|
||||
--prefix GUILE_LOAD_COMPILED_PATH : ${guile-ssh}/lib/guile/3.0/site-ccache \
|
||||
--prefix GUILE_LOAD_COMPILED_PATH : ${guile-json}/lib/guile/3.0/site-ccache \
|
||||
--prefix GUILE_LOAD_COMPILED_PATH : ${guile-git}/lib/guile/3.0/site-ccache \
|
||||
--prefix GUILE_LOAD_COMPILED_PATH : ${guile-gcrypt}/lib/guile/3.0/site-ccache
|
||||
|
||||
wrapProgram $out/bin/lab-mcp-server \
|
||||
--prefix PATH : ${lib.makeBinPath [openssh git nixos-rebuild]} \
|
||||
--prefix GUILE_LOAD_PATH : ${guile-ssh}/share/guile/site/3.0 \
|
||||
--prefix GUILE_LOAD_PATH : ${guile-json}/share/guile/site/3.0 \
|
||||
--prefix GUILE_LOAD_PATH : ${guile-git}/share/guile/site/3.0 \
|
||||
--prefix GUILE_LOAD_PATH : ${guile-gcrypt}/share/guile/site/3.0 \
|
||||
--prefix GUILE_LOAD_COMPILED_PATH : ${guile-ssh}/lib/guile/3.0/site-ccache \
|
||||
--prefix GUILE_LOAD_COMPILED_PATH : ${guile-json}/lib/guile/3.0/site-ccache \
|
||||
--prefix GUILE_LOAD_COMPILED_PATH : ${guile-git}/lib/guile/3.0/site-ccache \
|
||||
--prefix GUILE_LOAD_COMPILED_PATH : ${guile-gcrypt}/lib/guile/3.0/site-ccache
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Home Lab Tool - Guile implementation with MCP integration";
|
||||
license = licenses.mit;
|
||||
platforms = platforms.linux;
|
||||
maintainers = ["geir@home-lab"];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,133 +0,0 @@
|
|||
{
|
||||
description = "Home Lab Tool - Guile implementation with MCP server";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
|
||||
# Guile libraries we need
|
||||
guileLibs = with pkgs; [
|
||||
guile_3_0
|
||||
guile-ssh
|
||||
guile-json
|
||||
guile-git
|
||||
guile-gcrypt
|
||||
];
|
||||
|
||||
# Build the Guile lab tool
|
||||
lab-tool = pkgs.stdenv.mkDerivation {
|
||||
pname = "lab-tool";
|
||||
version = "0.1.0";
|
||||
|
||||
src = ./.;
|
||||
|
||||
buildInputs = guileLibs;
|
||||
nativeBuildInputs = [pkgs.makeWrapper];
|
||||
|
||||
buildPhase = ''
|
||||
# Compile Guile modules for better performance
|
||||
mkdir -p $out/share/guile/site/3.0
|
||||
cp -r . $out/share/guile/site/3.0/lab-tool/
|
||||
|
||||
# Compile .scm files to .go files
|
||||
for file in $(find . -name "*.scm"); do
|
||||
echo "Compiling $file"
|
||||
guild compile -L . -o $out/share/guile/site/3.0/''${file%.scm}.go $file || true
|
||||
done
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
|
||||
# Create the main lab executable
|
||||
cat > $out/bin/lab << EOF
|
||||
#!/usr/bin/env bash
|
||||
export GUILE_LOAD_PATH="$out/share/guile/site/3.0/lab-tool:\$GUILE_LOAD_PATH"
|
||||
export GUILE_LOAD_COMPILED_PATH="$out/share/guile/site/3.0/lab-tool:\$GUILE_LOAD_COMPILED_PATH"
|
||||
exec ${pkgs.guile_3_0}/bin/guile "$out/share/guile/site/3.0/lab-tool/main.scm" "\$@"
|
||||
EOF
|
||||
chmod +x $out/bin/lab
|
||||
|
||||
# Create MCP server executable
|
||||
cat > $out/bin/lab-mcp-server << EOF
|
||||
#!/usr/bin/env bash
|
||||
export GUILE_LOAD_PATH="$out/share/guile/site/3.0/lab-tool:\$GUILE_LOAD_PATH"
|
||||
export GUILE_LOAD_COMPILED_PATH="$out/share/guile/site/3.0/lab-tool:\$GUILE_LOAD_COMPILED_PATH"
|
||||
exec ${pkgs.guile_3_0}/bin/guile -L "$out/share/guile/site/3.0/lab-tool" -c "(use-modules (mcp server)) (run-mcp-server)"
|
||||
EOF
|
||||
chmod +x $out/bin/lab-mcp-server
|
||||
|
||||
# Wrap executables with proper environment
|
||||
wrapProgram $out/bin/lab \
|
||||
--prefix PATH : ${pkgs.lib.makeBinPath [pkgs.openssh pkgs.git pkgs.nixos-rebuild]}
|
||||
|
||||
wrapProgram $out/bin/lab-mcp-server \
|
||||
--prefix PATH : ${pkgs.lib.makeBinPath [pkgs.openssh pkgs.git pkgs.nixos-rebuild]}
|
||||
'';
|
||||
|
||||
meta = with pkgs.lib; {
|
||||
description = "Home Lab Tool - Guile implementation with MCP integration";
|
||||
license = licenses.mit;
|
||||
platforms = platforms.linux;
|
||||
maintainers = ["geir@home-lab"];
|
||||
};
|
||||
};
|
||||
in {
|
||||
packages = {
|
||||
default = lab-tool;
|
||||
lab-tool = lab-tool;
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs =
|
||||
guileLibs
|
||||
++ (with pkgs; [
|
||||
# Development tools
|
||||
emacs
|
||||
|
||||
# System tools for lab operations
|
||||
openssh
|
||||
git
|
||||
nixos-rebuild
|
||||
|
||||
# Optional for advanced features
|
||||
sqlite
|
||||
redis
|
||||
]);
|
||||
|
||||
shellHook = ''
|
||||
echo "🧪 Home Lab Tool Development Environment"
|
||||
echo "Available commands:"
|
||||
echo " guile - Start Guile REPL"
|
||||
echo " guild compile <file> - Compile Guile modules"
|
||||
echo " ./main.scm help - Test the lab tool"
|
||||
echo ""
|
||||
echo "Module path: $(pwd)"
|
||||
|
||||
export GUILE_LOAD_PATH="$(pwd):$GUILE_LOAD_PATH"
|
||||
export LAB_DEV_MODE=1
|
||||
'';
|
||||
};
|
||||
|
||||
apps = {
|
||||
default = flake-utils.lib.mkApp {
|
||||
drv = lab-tool;
|
||||
name = "lab";
|
||||
};
|
||||
|
||||
mcp-server = flake-utils.lib.mkApp {
|
||||
drv = lab-tool;
|
||||
name = "lab-mcp-server";
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
|
@ -4,7 +4,8 @@
|
|||
;; Home Lab Tool - Main Entry Point
|
||||
;; K.I.S.S Refactored Implementation
|
||||
|
||||
(add-to-load-path (dirname (current-filename)))
|
||||
;; Load path is set by the wrapper script in default.nix
|
||||
;; No need to add current directory when running from Nix
|
||||
|
||||
(use-modules (ice-9 match)
|
||||
(ice-9 format)
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
;; utils/ssh.scm - SSH operations for Home Lab Tool
|
||||
;; Fallback implementation using shell commands instead of guile-ssh
|
||||
|
||||
(define-module (utils ssh)
|
||||
#:use-module (ssh session)
|
||||
#:use-module (ssh channel)
|
||||
#:use-module (ssh popen)
|
||||
#:use-module (ice-9 popen)
|
||||
#:use-module (ice-9 rdelim)
|
||||
#:use-module (ice-9 textual-ports)
|
||||
|
||||
#:use-module (ice-9 format)
|
||||
#:use-module (srfi srfi-1)
|
||||
#:use-module (utils logging)
|
||||
#:use-module (utils config)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue