Skip to content

Commit 38b6b64

Browse files
committed
fix documentation and view naming
1 parent c6aea2a commit 38b6b64

4 files changed

Lines changed: 64 additions & 50 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,4 @@ UnityFileSystemTestData/ProjectSettings/
3535
UnityFileSystemTestData/UserSettings/
3636
UnityFileSystemTestData/Packages/
3737
*.db
38-
*.txt
3938
*.csv

Analyzer/AnalyzerTool.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public int Analyze(
6969
if (parser.CanParse(file))
7070
{
7171
foundParser = true;
72-
Console.Error.WriteLine(file);
72+
Console.WriteLine(file);
7373
try
7474
{
7575
parser.Parse(file);
@@ -119,11 +119,6 @@ public int Analyze(
119119
return 0;
120120
}
121121

122-
private bool ProcessFile(string file, string path, SQLiteWriter writer, int i, int length)
123-
{
124-
throw new NotImplementedException();
125-
}
126-
127122
int m_LastProgressMessageLength = 0;
128123

129124
void ReportProgress(string relativePath, int fileIndex, int cntFiles)

Analyzer/Resources/AddrBuildBundles.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ CREATE TABLE IF NOT EXISTS addr_build_bundles
1919
PRIMARY KEY (id, build_id)
2020
);
2121

22-
CREATE VIEW IF NOT EXISTS addr_build_cached_bundles AS SELECT build_id, concat(internal_name, '.bundle') AS cached_name, name AS catalog_name FROM addr_build_bundles;
22+
CREATE VIEW IF NOT EXISTS addr_build_cached_bundles AS SELECT build_id, concat(internal_name, '.bundle') AS cached_name, name AS name_in_catalog FROM addr_build_bundles;

Documentation/addressables-build-reports.md

Lines changed: 62 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,37 @@ Unity Data Tools provides the ability to analyse Unity Addressables build report
66

77
When you run the analyzer on a directory containing Addressables build reports, the tool will parse them and add the data to the sqlite database.
88

9+
Each build report is generated a unique id that is used as the id in addr_builds and build_id field in subsequent tables. This allows you to compare builds against each other.
10+
911
## Database Schema
1012

1113
The Addressables build data is stored across multiple related tables in the SQLite database:
1214

1315
## Concepts
1416

15-
**Builds** - a build corresponds to a content build. This can be part of a player build, or standalone through the Addressables groups window
16-
**Bundles** - asset bundles that are output by the build.
17-
**Groups** - groups in the Addressable Groups window whose settings generate one or more Asset Bundles
18-
**Schemas** - settings for groups that determine how bundles are generated
19-
**Files** - the file in the asset bundle that contains serialized files
20-
**SubFiles** - files that are bundled in the asset bundle, but not stored with the rest of the serialized files (resS, scene sharedAssets)
21-
**Explicit Assets** - these are assets that have had the Addressable checkbox checked in the Editor
22-
**Other Assets** - these are assets that are included because an explicit asset depends upon them
17+
**Builds**
18+
: a build corresponds to a content build. This can be part of a player build, or standalone through the Addressables groups window
19+
20+
**Bundles**
21+
: asset bundles that are output by the build.
22+
23+
**Groups**
24+
: groups in the Addressable Groups window whose settings generate one or more Asset Bundles
25+
26+
**Schemas**
27+
: settings for groups that determine how bundles are generated
28+
29+
**Files**
30+
: the file in the asset bundle that contains serialized files
31+
32+
**SubFiles**
33+
: files that are bundled in the asset bundle, but not stored with the rest of the serialized files (resS, scene sharedAssets)
34+
35+
**Explicit Assets**
36+
: these are assets that have had the Addressable checkbox checked in the Editor
37+
38+
**Other Assets**
39+
: these are assets that are included because an explicit asset depends upon them
2340

2441
### Core Tables
2542

@@ -47,7 +64,7 @@ Contains key value pairs of schema settings at time of build.
4764
#### `addr_build_bundles`
4865
Bundle-level information including asset counts and file sizes.
4966

50-
#### `addr_build_bundle_dependent_bundles
67+
#### `addr_build_bundle_dependent_bundles`
5168
Maps bundles to the bundles they depend upon (dependent bundles will be loaded as long as the bundle in question is loaded).
5269
* bundle_id maps to addr_build_bundles.id
5370
* dependent_bundle_rid maps to addr_build_bundles.id
@@ -57,18 +74,18 @@ List files in bundles. These are the serialized files and external files.
5774
* bundle_id maps to addr_build_bundles.id
5875
* file_rid maps to addr_build_files.id
5976

60-
### `addr_build_explicit_assets`
77+
#### `addr_build_explicit_assets`
6178
Explicit assets (marked as Addressable). Has Addressable name and asset information including paths.
6279
* bundle maps to addr_build_bundles.id
6380
* group_guid maps to addr_build_groups.guid
6481
* file maps to addr_build_files.id
6582

66-
### `addr_build_explicit_asset_internal_referenced_other_assets`
83+
#### `addr_build_explicit_asset_internal_referenced_other_assets`
6784
Map explicit assets to other assets they refer to. For instance a prefab to its underlying FBX
6885
* referencing_asset_rid maps to addr_build_explicit_assets.id
6986
* data_from_other_asset_Id maps to addr_build_data_from_other_assets.id
7087

71-
### `addr_build_data_from_other_assets`
88+
#### `addr_build_data_from_other_assets`
7289
Assets added into the build implicitly by explictly defined assets.
7390
* file maps to addr_build_files.id
7491

@@ -81,13 +98,13 @@ To analyze Addressables build reports in your project:
8198

8299
```bash
83100
# Analyze all files in a directory (automatically detects Addressables JSON files)
84-
UnityDataTools.exe "Library\com.unity.addressables\BuildReports\" -o "addressables_analysis.db"
101+
UnityDataTools.exe "Library\\com.unity.addressables\\BuildReports\\" -o "addressables_analysis.db"
85102

86103
# Include verbose output to see processing details
87-
UnityDataTools.exe "Library\com.unity.addressables\BuildReports\" -o "addressables_analysis.db" --verbose
104+
UnityDataTools.exe "Library\\com.unity.addressables\\BuildReports\\" -o "addressables_analysis.db" --verbose
88105

89106
# Analyze only JSON files specifically
90-
UnityDataTools.exe "C:\Temp\MyExtractedFiles" -o "addressables_analysis.db" -p "*.json"
107+
UnityDataTools.exe "C:\\Temp\\MyExtractedFiles" -o "addressables_analysis.db" -p "*.json"
91108
```
92109

93110
You can analyze a directory with both asset bundles (*.bundle) and json files (*.json) at the same time.
@@ -97,51 +114,54 @@ You can analyze a directory with both asset bundles (*.bundle) and json files (*
97114
Once the data is in the database, you can run queries to analyze your Addressables build:
98115

99116
#### Find the cache name for an addressables bundle
117+
Addressables renames bundles to make it possible to do content updates. Internally bundles are still named by their internal hash and are cached based upon this name. If you want to lookup how a remote bundle will be cached in Unity's [cache](https://docs.unity3d.com/ScriptReference/Caching.html) you can use the addr_build_cached_bundles view.
100118
```sql
101119
-- Find cache name for an addressables bundle
102-
SELECT cached_name
103-
FROM addr_build_cached_bundles
104-
WHERE catalog_name = 'packedassets7_assets_all_61d3358060e969d3aad2d9c5c3a7d69b.bundle';
120+
SELECT cached_namei
121+
FROM addr_build_cached_bundles
122+
WHERE name_in_catalog = 'sharedenvironment_assets_all_5935f9c20c9b10664721f1591e3d2036.bundle'
123+
AND build_id = 1;
105124
```
106125

107126
#### Bundle Size Analysis
127+
This query works for groups that are packed together. It assumes group guids stay the same between builds and compares the bundle file size for a group between builds.
108128
```sql
109-
-- Find largest bundles by file size
110-
SELECT name, file_size, asset_count, compression
111-
FROM addr_build_bundles
112-
ORDER BY file_size DESC
113-
LIMIT 10;
129+
-- Compare bundle size changes between builds
130+
SELECT second_build.name as bundle_name, second_build.file_size as second_build_file_size, second_build.asset_count as second_build_asset_count,
131+
first_build.file_size as first_build_File_size, first_build.asset_count as first_build_asset_count
132+
FROM addr_build_bundles first_build,
133+
addr_build_bundles second_build,
134+
addr_build_groups g1,
135+
addr_build_groups g2
136+
WHERE second_build.file_size > first_build.file_size
137+
AND first_build.group_rid = g1.id
138+
AND second_build.group_rid = g2.id
139+
AND g1.guid = g2.guid
140+
AND first_build.build_id = 1
141+
AND second_build.build_id = 2
142+
AND g1.build_id = first_build.build_id
143+
AND g2.build_id = second_build.build_id
144+
AND second_build.file_size != first_build.file_size
145+
ORDER BY second_build.file_size DESC;
114146
```
115147

116148
#### Build Performance Analysis
117149
```sql
118-
-- Analyze build duration and asset counts
150+
-- Analyze build duration and asset counts for successful builds
119151
SELECT
152+
a.id,
120153
a.name,
121154
a.duration,
122155
COUNT(b.id) as bundle_count,
123156
SUM(b.asset_count) as total_assets,
124157
SUM(b.file_size) as total_size
125158
FROM addr_builds a
126-
LEFT JOIN addr_build_bundles b ON a.rowid = b.build_id
127-
GROUP BY a.rowid;
159+
LEFT JOIN addr_build_bundles b ON a.id = b.build_id
160+
WHERE coalesce(a.error, '') = ''
161+
group by a.id;
128162

129163
-- Find builds with errors
130164
SELECT name, start_time, duration, error
131165
FROM addr_builds
132-
WHERE error IS NOT NULL AND error != '';
133-
```
134-
135-
#### MonoScript Analysis
136-
```sql
137-
-- Analyze MonoScript distribution across files
138-
SELECT
139-
f.name,
140-
f.mono_script_count,
141-
f.mono_script_size,
142-
b.name as bundle_name
143-
FROM addr_build_files f
144-
JOIN addr_build_bundles b ON f.bundle = b.id AND f.build_id = b.build_id
145-
WHERE f.mono_script_count > 0
146-
ORDER BY f.mono_script_size DESC;
147-
```
166+
WHERE coalesce(error, '') != '';
167+
```

0 commit comments

Comments
 (0)