Merge branch 'sharp/fix-ci' into 'master'

Fix benchmarks and profile overrides.

See merge request veloren/veloren!736
This commit is contained in:
Joshua Yanovski 2020-01-20 13:49:48 +00:00
commit f0350cd24f
4 changed files with 101 additions and 70 deletions

View File

@ -107,8 +107,6 @@ coverage:
tags:
- veloren-docker
script:
- sed -i '/cargo-features/d' Cargo.toml
- sed -i '/profile.dev.overrides/,+1d' Cargo.toml
- cargo tarpaulin -v
allow_failure: true

View File

@ -22,21 +22,21 @@ codegen-units = 8
lto = false
incremental = true
# All dependencies (but not this crate itself)
[profile.dev.overrides."*"]
[profile.dev.package."*"]
opt-level = 3
[profile.dev.overrides."veloren-common"]
[profile.dev.package."veloren-common"]
opt-level = 2
[profile.dev.overrides."veloren-client"]
[profile.dev.package."veloren-client"]
opt-level = 2
[profile.dev.overrides."veloren-chat-cli"]
[profile.dev.package."veloren-chat-cli"]
opt-level = 2
[profile.dev.overrides."veloren-server"]
[profile.dev.package."veloren-server"]
opt-level = 2
[profile.dev.overrides."veloren-server-cli"]
[profile.dev.package."veloren-server-cli"]
opt-level = 2
[profile.dev.overrides."veloren-voxygen"]
[profile.dev.package."veloren-voxygen"]
opt-level = 2
[profile.dev.overrides."veloren-world"]
[profile.dev.package."veloren-world"]
opt-level = 2
# this profile is used by developers if dev doesn't has enough debug information, the name must != debug, as debug is used by dev because....

View File

@ -2,7 +2,7 @@ use common::terrain::Block;
use common::terrain::TerrainGrid;
use common::vol::SampleVol;
use common::vol::Vox;
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use criterion::{black_box, criterion_group, criterion_main, Benchmark, Criterion};
use std::sync::Arc;
use vek::*;
use veloren_voxygen::mesh::Meshable;
@ -12,8 +12,6 @@ const CENTER: Vec2<i32> = Vec2 { x: 512, y: 512 };
const GEN_SIZE: i32 = 4;
pub fn criterion_benchmark(c: &mut Criterion) {
// Lower sample size to save time
c = c.sample_size(15);
// Generate chunks here to test
let mut terrain = TerrainGrid::new().unwrap();
let world = World::generate(42);
@ -57,69 +55,79 @@ pub fn criterion_benchmark(c: &mut Criterion) {
// Test speed of cloning voxel sample into a flat array
let (volume, range) = sample(Vec2::new(1, 1));
c.bench_function("copying 1,1 into flat array", |b| {
b.iter(|| {
let mut flat = vec![Block::empty(); range.size().product() as usize];
let mut i = 0;
let mut volume = volume.cached();
for x in 0..range.size().w {
for y in 0..range.size().h {
for z in 0..range.size().d {
flat[i] = *volume.get(range.min + Vec3::new(x, y, z)).unwrap();
i += 1;
c.bench(
"meshing",
Benchmark::new("copying 1,1 into flat array", move |b| {
b.iter(|| {
let mut flat = vec![Block::empty(); range.size().product() as usize];
let mut i = 0;
let mut volume = volume.cached();
for x in 0..range.size().w {
for y in 0..range.size().h {
for z in 0..range.size().d {
flat[i] = *volume.get(range.min + Vec3::new(x, y, z)).unwrap();
i += 1;
}
}
}
}
/*let (w, h, d) = range.size().into_tuple();
for (chunk_key, chunk) in volume.iter() {
let chunk_pos = volume.key_pos(chunk_key);
let min = chunk_pos.map2(
Vec2::new(range.min.x, range.min.y),
|cmin: i32, rmin: i32| (rmin - cmin).max(0),
);
// Chunk not in area of interest
if min
.map2(TerrainGrid::chunk_size(), |m, size| m >= size as i32)
.reduce_and()
{
// TODO: comment after ensuing no panics
panic!("Shouldn't happen in this case");
continue;
}
let min = min.map(|m| m.min(31));
// TODO: Don't hardcode 31
let max = chunk_pos.map2(Vec2::new(range.max.x, range.max.y), |cmin, rmax| {
(rmax - cmin).min(31)
});
if max.map(|m| m < 0).reduce_and() {
panic!("Shouldn't happen in this case: {:?}", max);
continue;
}
let max = max.map(|m| m.max(0));
// Add z dims
let min = Vec3::new(min.x, min.y, range.min.z);
let max = Vec3::new(max.x, max.y, range.max.z);
// Offset of chunk in sample being cloned
let offset = Vec3::new(
chunk_pos.x - range.min.x,
chunk_pos.y - range.min.y,
-range.min.z,
);
for (pos, &block) in chunk.vol_iter(min, max) {
let pos = pos + offset;
flat[(w * h * pos.z + w * pos.y + pos.x) as usize] = block;
}
}*/
black_box(flat);
});
});
/*let (w, h, d) = range.size().into_tuple();
for (chunk_key, chunk) in volume.iter() {
let chunk_pos = volume.key_pos(chunk_key);
let min = chunk_pos.map2(
Vec2::new(range.min.x, range.min.y),
|cmin: i32, rmin: i32| (rmin - cmin).max(0),
);
// Chunk not in area of interest
if min
.map2(TerrainGrid::chunk_size(), |m, size| m >= size as i32)
.reduce_and()
{
// TODO: comment after ensuing no panics
panic!("Shouldn't happen in this case");
continue;
}
let min = min.map(|m| m.min(31));
// TODO: Don't hardcode 31
let max = chunk_pos.map2(Vec2::new(range.max.x, range.max.y), |cmin, rmax| {
(rmax - cmin).min(31)
});
if max.map(|m| m < 0).reduce_and() {
panic!("Shouldn't happen in this case: {:?}", max);
continue;
}
let max = max.map(|m| m.max(0));
// Add z dims
let min = Vec3::new(min.x, min.y, range.min.z);
let max = Vec3::new(max.x, max.y, range.max.z);
// Offset of chunk in sample being cloned
let offset = Vec3::new(
chunk_pos.x - range.min.x,
chunk_pos.y - range.min.y,
-range.min.z,
);
for (pos, &block) in chunk.vol_iter(min, max) {
let pos = pos + offset;
flat[(w * h * pos.z + w * pos.y + pos.x) as usize] = block;
}
}*/
black_box(flat);
});
})
// Lower sample size to save time
.sample_size(15),
);
for x in 1..GEN_SIZE - 1 {
for y in 1..GEN_SIZE - 1 {
let (volume, range) = sample(Vec2::new(x, y));
c.bench_function(&format!("Terrain mesh {}, {}", x, y), |b| {
b.iter(|| volume.generate_mesh(black_box(range)))
});
c.bench(
"meshing",
Benchmark::new(&format!("Terrain mesh {}, {}", x, y), move |b| {
b.iter(|| volume.generate_mesh(black_box(range)))
})
// Lower sample size to save time
.sample_size(15),
);
}
}
}

View File

@ -1231,6 +1231,12 @@ impl<'a> Widget for SettingsWindow<'a> {
\n\
Dodge\n\
\n\
Roll\n\
\n\
Climb\n\
\n\
Climb down\n\
\n\
Auto Walk\n\
\n\
Sheathe/Draw Weapons\n\
@ -1239,6 +1245,10 @@ impl<'a> Widget for SettingsWindow<'a> {
\n\
Sit\n\
\n\
Mount\n\
\n\
Interact\n\
\n\
\n\
Basic Attack\n\
Secondary Attack/Block/Aim\n\
@ -1318,6 +1328,16 @@ impl<'a> Widget for SettingsWindow<'a> {
\n\
{}\n\
\n\
{}\n\
\n\
{}\n\
\n\
{}\n\
\n\
{}\n\
\n\
{}\n\
\n\
\n\
{}\n\
{}\n\
@ -1369,10 +1389,15 @@ impl<'a> Widget for SettingsWindow<'a> {
controls.jump,
controls.glide,
"??", // Dodge
controls.roll,
controls.climb,
controls.climb_down,
"??", // Auto Walk
controls.toggle_wield,
"??", // Put on/Remove Helmet
controls.sit,
controls.mount,
controls.interact,
controls.primary,
controls.secondary,
"1", // Skillbar Slot 1