Git Packfiles: Otimizando o Armazenamento
+------------------------+
| Packfile |
| |
| Objects + Index |
| Delta Compression |
| Network Transfer |
| |
| .git/objects/pack/ |
+------------------------+
Estrutura dos Packfiles
Componentes Principais
+------------------+
| PACKFILE |
+------------------+
| • Header |
| • Objects |
| • Deltas |
| • Index |
+------------------+
Formato do Arquivo
pack-<SHA-1>.pack
pack-<SHA-1>.idx
Compressão Delta
Como Funciona
Tipos de Delta
+-----------------+
| DELTA TYPES |
+-----------------+
| • REF_DELTA |
| • OFS_DELTA |
+-----------------+
Criação de Packfiles
Processo Automático
Comandos Manuais
# Criar packfile
git gc
# Repack otimizado
git repack -ad
# Verificar packfiles
git verify-pack -v .git/objects/pack/*.idx
Otimização de Performance
Estratégias
Delta compression
Object reuse
Network transfer
Index optimization
Configurações
# Ajustar compressão
git config pack.compression 9
# Limite de window
git config pack.windowMemory "100m"
# Delta cache size
git config core.deltaBaseCacheLimit "1g"
Rede e Transferência
Protocolo de Transferência
Otimizações de Rede
+------------------+
| TRANSFER OPT |
+------------------+
| • Thin pack |
| • Multi-pack |
| • Smart proto |
+------------------+
Manutenção
Rotinas de Manutenção
Comandos de Manutenção
# Repack total
git repack -a -d -f --window=250 --depth=250
# Verificar packfiles
git fsck --full
# Limpar objetos
git prune-packed
Troubleshooting
Problemas Comuns
+----------------------+
| PROBLEMAS |
| |
| • Packfile corrupto |
| • Delta muito grande |
| • Memória insuf. |
| • Fragmentação |
+----------------------+
Diagnóstico
# Listar objetos grandes
git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n
# Verificar integridade
git fsck --full
# EstatÃsticas
git count-objects -v
Boas Práticas
Recomendações
Repack periódico
Monitorar tamanho
Backup antes de repack
Verificar integridade
Configurações Recomendadas
# Para repositórios grandes
git config pack.deltaCacheSize 1g
git config pack.windowMemory 1g
git config pack.threads 4
Ferramentas e Scripts
Utilitários Úteis
# Análise de packfile
git show-index < .git/objects/pack/*.idx
# Extrair objeto
git unpack-objects < .git/objects/pack/*.pack
# EstatÃsticas detalhadas
git count-objects --verbose
Próximos Passos
Tópicos Relacionados
22 abril 2025