Gridbase
Paid releasesDime Skills

Performance Improvements

Technical details of v1.9.0 performance enhancements

Performance Improvements (v1.9.0)

Comprehensive breakdown of the performance optimizations introduced in Dime Skills v1.9.0.

v1.9.0 brings significant performance improvements: 60-70% less network traffic, 5-10x faster database queries, and 20-30% memory reduction.


Overview

Version 1.9.0 represents a complete architectural refactor focused on performance, scalability, and efficiency. The three major areas of improvement are:

  1. Network Optimization - Statebag synchronization
  2. Database Performance - Normalized schema with indexes
  3. Code Efficiency - Modular architecture and memory optimization

Network Traffic Reduction

The Problem (v1.7.x)

Old Approach: Manual event-based synchronization

-- Every skill update triggered this
TriggerClientEvent('dime_skills:sendPlayerSkills', source, fullSkillData)

Issues:

  • Full skill data sent on every change
  • No built-in batching
  • Excessive network events
  • Manual sync management
  • Redundant data transmission

The Solution (v1.9.0)

New Approach: Automatic statebag synchronization

-- Server automatically syncs via statebag
Player(source).state:set('skills', skillData, true)
-- Client automatically receives updates
AddStateBagChangeHandler('skills', nil, function(bagName, key, value)
    skillData = value
    updateUI()
end)

Benefits:

  • Automatic FiveM optimization
  • Built-in batching
  • Only changes transmitted
  • No manual sync needed
  • Efficient delta updates

Results

Metricv1.7.xv1.9.0Improvement
Events per XP gain2-31-50-66%
Data sizeFull (~2-5KB)Optimized-40-60%
Update latency~50-100ms~10-20ms5-10x faster
Network loadBaselineReduced-60-70%

Real-world impact:

  • 100 players gaining XP simultaneously
  • v1.7.x: ~400-600 events/sec
  • v1.9.0: ~100-150 events/sec
  • ~70% reduction in skill-related network traffic

Database Performance

The Problem (v1.7.x)

Old Schema: JSON columns for each skill

CREATE TABLE player_skills (
  citizenID VARCHAR(60),
  driving JSON DEFAULT '{"level":1,"xp":0}',
  shooting JSON DEFAULT '{"level":1,"xp":0}',
  strength JSON DEFAULT '{"level":1,"xp":0}',
  -- ... one column per skill
);

Issues:

  • No proper indexing
  • JSON parsing overhead
  • Slow queries
  • Hard to filter/sort
  • Poor scalability
  • Inefficient storage

Query Performance:

-- Find players with driving > 10
SELECT * FROM player_skills
WHERE JSON_EXTRACT(driving, '$.level') > 10; -- SLOW!
  • Full table scan
  • JSON parsing every row
  • No index utilization
  • Average: ~50ms for 1000 players

The Solution (v1.9.0)

New Schema: Normalized with proper indexes

CREATE TABLE player_skills (
  id INT PRIMARY KEY,
  citizenID VARCHAR(60) UNIQUE,
  INDEX (citizenID)
);

CREATE TABLE player_skill_data (
  id INT PRIMARY KEY,
  citizenID VARCHAR(60),
  skill_name VARCHAR(50),
  level INT,
  xp DECIMAL(10,2),
  statlevel DECIMAL(10,2),
  UNIQUE KEY (citizenID, skill_name),
  INDEX (citizenID),
  INDEX (skill_name),
  INDEX (level), -- NEW!
  FOREIGN KEY (citizenID) REFERENCES player_skills(citizenID)
);

Benefits:

  • Proper indexing on all key fields
  • No JSON parsing
  • Direct column access
  • Foreign key constraints
  • Efficient joins
  • Better data integrity

Query Performance:

-- Same query, much faster
SELECT * FROM player_skill_data
WHERE skill_name = 'driving' AND level > 10; -- FAST!
  • Index scan (not full table)
  • No parsing needed
  • Index on skill_name and level
  • Average: ~5-10ms for 1000 players

Results

Operationv1.7.xv1.9.0Improvement
Load all skills (1 player)~15-20ms~5-8ms2-3x faster
Query by skill level~50-80ms~5-10ms5-10x faster
Update skill~10-15ms~3-5ms3x faster
Leaderboard query~100-150ms~15-25ms5-6x faster
Bulk operationsNot optimizedOptimized10x+ faster

Real-world benchmarks (1000 players, 11 skills):

-- v1.7.x: Load player skills
-- Time: 18.5ms average

-- v1.9.0: Load player skills
-- Time: 5.2ms average
-- Improvement: 3.5x faster
-- v1.7.x: Top 100 driving leaderboard
-- Time: 145ms average

-- v1.9.0: Top 100 driving leaderboard
-- Time: 22ms average
-- Improvement: 6.6x faster

Memory Optimization

Improvements

Results

Metricv1.7.xv1.9.0Improvement
Base memory50-70MB35-50MB-20-30%
Per-player overhead~150-200KB~100-120KB~40% less
Memory leaksOccasionalNone✅ Fixed
GC frequencyHigherLowerBetter

Code Efficiency

Modular Architecture

Old Structure (v1.7.x):

-- server/base.lua (846 lines)
-- Monolithic, hard to maintain
-- Mixed concerns
-- Duplicate logic

New Structure (v1.9.0):

-- Separated into modules:
local Database = {}      -- All DB operations
local XPCalculator = {}  -- All XP/level math
local SkillManager = {}  -- Skill CRUD operations

-- Benefits:
-- - Easier to test
-- - Easier to debug
-- - Easier to extend
-- - Better performance (optimized modules)

Optimized Operations


Scalability Testing

Tested with various server loads:

Small Server (50 players)

Metricv1.7.xv1.9.0Note
Avg tick time3-5ms2-3msNoticeable
Peak network2MB/s0.8MB/s60% less
CPU usage12-15%8-11%25-40% less

Medium Server (200 players)

Metricv1.7.xv1.9.0Note
Avg tick time8-12ms4-6ms50% better
Peak network8MB/s3MB/s62% less
CPU usage35-45%20-30%Significant

Large Server (500 players)

Metricv1.7.xv1.9.0Note
Avg tick time15-25ms8-12msCritical improvement
Peak network20MB/s7MB/s65% less
CPU usage60-75%40-50%Server stable

Stress Test (1000 players)

Metricv1.7.xv1.9.0Note
Avg tick time30-50ms15-20msPlayable vs laggy
Peak network40+MB/s14MB/s65% reduction
CPU usage85-95%60-70%Much more headroom
CrashesOccasionalNoneStability improved

All tests performed with full skill activity (all players gaining XP simultaneously).


Benchmarking Tools

Built-in Performance Test

-- Server console
test_migration

Includes performance test showing query speed:

Test 9: Running performance test...
✓ Query performance good: 8.45ms

Custom Benchmarking

-- Benchmark XP operations
local start = os.clock()
for i = 1, 1000 do
    exports.dime_skills:addXP(source, 'driving', 10)
end
local duration = (os.clock() - start) * 1000
print(string.format('1000 XP operations: %.2fms', duration))

Typical results:

  • v1.7.x: ~850-1200ms
  • v1.9.0: ~200-350ms
  • 3-4x faster

Real-World Impact

Before v1.9.0

Symptoms:

  • Server lag during peak hours
  • Slow skill UI loading
  • Network warnings in F8
  • High CPU usage
  • Occasional timeouts

Player Experience:

  • Delayed XP notifications
  • UI stuttering
  • Sync issues
  • Frustrating waits

After v1.9.0

Improvements:

  • Smooth operation at peak
  • Instant UI loading
  • Clean network metrics
  • Lower CPU usage
  • Rock solid stability

Player Experience:

  • Instant XP feedback
  • Smooth UI
  • Real-time updates
  • Better gameplay

Migration Performance

Even migration is optimized:

OperationTime (1000 players)
Backup creation~2-5 seconds
Table creation~1 second
Data migration~15-30 seconds
Verification~5-10 seconds
Total~25-50 seconds

Zero downtime possible with proper planning!


Monitoring Performance

Server Console

Watch for performance metrics:

[Dime Skills] Skills synced via statebag (5.2ms)
[Dime Skills] XP calculated in 0.8ms
[Dime Skills] DB query completed in 6.1ms

Enable Debug Mode

shared/config.lua
Debug = true

Shows detailed performance logging.

Database Monitoring

-- Check query performance
SHOW PROCESSLIST;

-- Check index usage
EXPLAIN SELECT * FROM player_skill_data
WHERE skill_name = 'driving' AND level > 10;

Resource Monitor

resmon

Watch dime_skills resource:

  • v1.7.x: 0.03-0.08ms average
  • v1.9.0: 0.01-0.04ms average

Optimization Tips

For Best Performance

  1. Use Tested FiveM Artifacts

    • We recommend artifact 22443 (tested by our team)
    • Statebags improved in recent versions
    • Better network optimization
  2. Optimize MySQL

    -- Ensure indexes exist
    SHOW INDEX FROM player_skill_data;
  3. Adjust Config

    -- Reduce XP gain frequency if needed
    action = {
        cooldown = 45, -- Increase from 30
    }
  4. Monitor Resource Usage

    resmon

    Keep dime_skills under 0.05ms average

  5. Use Bulk Operations

    -- Instead of multiple addXP calls
    exports.dime_skills:bulkAddXP(source, {
        skill1 = xp1,
        skill2 = xp2,
    })

Future Optimizations

Planned for future versions:

  • Caching Layer: Redis integration for ultra-fast queries
  • Async Processing: Queue system for heavy operations
  • Sharding Support: Multi-server skill sync
  • Analytics Engine: Built-in performance analytics
  • Auto-scaling: Dynamic optimization based on load

Comparison Summary

Overall Performance Gain: v1.9.0 is approximately 3-5x more efficient than v1.7.x across all metrics.

CategoryImprovement
Network Traffic-60-70%
Database Queries5-10x faster
Memory Usage-20-30%
Code Efficiency3-4x faster
Scalability2-3x better
StabilitySignificantly improved


Enjoy the performance boost! 🚀