Skip to content

Commit

Permalink
fix: armv7 null_smartengine updates to track sm/seng updates
Browse files Browse the repository at this point in the history
  • Loading branch information
digikata committed Aug 4, 2023
1 parent 6263ef9 commit befc11f
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 19 deletions.
1 change: 0 additions & 1 deletion crates/fluvio-run/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,5 @@ tracing-subscriber = { workspace = true }
# regardless of TLS, sc and spu always use openssl_tls for now because we need cert API
fluvio-future = { workspace = true, features = ["subscriber"] }
fluvio-extension-common = { workspace = true }

fluvio-sc = { path = "../fluvio-sc", default-features = false }
fluvio-spu = { path = "../fluvio-spu", default-features = false }
4 changes: 0 additions & 4 deletions crates/fluvio-spu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,3 @@ portpicker = { workspace = true }
flv-util = { workspace = true, features = ["fixture"] }
fluvio-future = { workspace = true,features = ["fixture", "subscriber"] }
fluvio-protocol = { workspace = true, features = ["fixture"] }

# not used?
# [target.armv7-unknown-linux-gnueabi]
# linker="armv7-unknown-linux-gnueabi-gcc"
6 changes: 3 additions & 3 deletions crates/fluvio-spu/src/smartengine/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ use fluvio_protocol::link::ErrorCode;
use fluvio_spu_schema::server::smartmodule::SmartModuleInvocation;

#[cfg(feature = "smartengine")]
use fluvio_smartengine::{
EngineError, SmartModuleChainBuilder, SmartModuleConfig, SmartModuleInitialData,
};
use fluvio_smartengine::{EngineError, SmartModuleConfig, SmartModuleInitialData};

#[cfg(feature = "smartengine")]
use fluvio_spu_schema::server::smartmodule::{SmartModuleContextData, SmartModuleKind};

use crate::smartengine::SmartModuleChainBuilder;
use crate::smartengine::SmartEngine;
use crate::smartengine::SmartModuleChainInstance;

#[cfg(not(feature = "smartengine"))]
pub(crate) fn build_chain(
mut _chain_builder: SmartModuleChainBuilder,
_invocations: Vec<SmartModuleInvocation>,
_version: i16,
_engine: SmartEngine,
Expand Down
2 changes: 1 addition & 1 deletion crates/fluvio-spu/src/smartengine/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::time::Duration;

use async_rwlock::RwLock;
use chrono::Utc;
use fluvio::SmartModuleChainBuilder;
use fluvio_protocol::link::ErrorCode;
use fluvio_smartmodule::Record;
use fluvio_spu_schema::server::smartmodule::{SmartModuleInvocation, SmartModuleInvocationWasm};
Expand All @@ -18,6 +17,7 @@ use crate::replication::leader::LeaderReplicaState;
use crate::smartengine::chain;
use crate::smartengine::file_batch::{FileRecordIterator, FileBatchIterator};
use crate::smartengine::Lookback;
use crate::smartengine::SmartModuleChainBuilder;
use crate::smartengine::SmartModuleChainInstance;
use crate::smartengine::Version;

Expand Down
35 changes: 30 additions & 5 deletions crates/fluvio-spu/src/smartengine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ mod chain;

#[cfg(feature = "smartengine")]
pub(crate) use fluvio_smartengine::{
EngineError, metrics::SmartModuleChainMetrics, SmartEngine, SmartModuleChainInstance, Version,
Lookback,
EngineError, Lookback, SmartModuleChainBuilder, metrics::SmartModuleChainMetrics, SmartEngine,
SmartModuleChainInstance, Version,
};

// Stub structures to support a null smartengine config
#[cfg(not(feature = "smartengine"))]
mod null_smartengine {
use std::future::Future;
use std::sync::atomic::{AtomicU64, Ordering};
use std::time::Duration;

use anyhow::Result;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -81,6 +82,14 @@ mod null_smartengine {
}
}

#[derive(Default)]
pub struct SmartModuleChainBuilder;

impl SmartModuleChainBuilder {
pub fn set_store_memory_limit(&mut self, _max_memory_bytes: usize) {}
}

#[derive(Debug)]
pub struct SmartModuleChainInstance;

impl SmartModuleChainInstance {
Expand All @@ -101,7 +110,12 @@ mod null_smartengine {
input: SmartModuleInput,
_metric: &SmartModuleChainMetrics,
) -> Result<SmartModuleOutput> {
let out = SmartModuleOutput::new(input.try_into()?);
use fluvio_smartmodule::SMARTMODULE_TIMESTAMPS_VERSION;
const DEFAULT_SMARTENGINE_VERSION: Version = SMARTMODULE_TIMESTAMPS_VERSION;

#[allow(deprecated)]
let records = input.try_into_records(DEFAULT_SMARTENGINE_VERSION)?;
let out = SmartModuleOutput::new(records);
Ok(out)
}
}
Expand All @@ -117,8 +131,19 @@ mod null_smartengine {
}

#[allow(dead_code)]
#[derive(Debug)]
pub enum EngineError {}
#[derive(thiserror::Error, Debug)]
pub enum EngineError {
#[error("No valid smartmodule found")]
UnknownSmartModule,
#[error("Failed to instantiate: {0}")]
Instantiate(anyhow::Error),
#[error("Requested memory {requested}b exceeded max allowed {max}b")]
StoreMemoryExceeded {
current: usize,
requested: usize,
max: usize,
},
}
}

#[cfg(not(feature = "smartengine"))]
Expand Down
24 changes: 21 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,31 @@
default:
just -l

# build smoketest for native and armv7
check:
just build-spu-def
just build-spu
just build-run

check-mk:
cargo clean -p fluvio-run
make build-cluster TARGET=armv7-unknown-linux-gnueabihf

# arm7 spu build (works), odd part is the cmd line needs to add --no-default-features for the target
build-run:
cargo build --bin fluvio-run -p fluvio-run --release --target=armv7-unknown-linux-gnueabihf --no-default-features

# arm7 spu build (works)
build-spu:
cargo build --target=armv7-unknown-linux-gnueabi -p fluvio-spu --no-default-features --release
cargo build --target=armv7-unknown-linux-gnueabihf -p fluvio-spu --no-default-features --release

# default spu build
build-spu-def:
cargo build -p fluvio-spu --release

# cross build armv7 (works)
build-spu-cross:
cross build --target=armv7-unknown-linux-gnueabi -p fluvio-spu --no-default-features
cross build --target=armv7-unknown-linux-gnueabihf -p fluvio-spu --no-default-features

# cross build armv7 musl (works)
build-spu-cross-musl:
Expand All @@ -20,7 +38,7 @@ build-spu-musl:

# cargo zigbuild armv7 gnu (link issue)
build-spu-zig-gnu:
cargo zigbuild --target=armv7-unknown-linux-gnueabi -p fluvio-spu --no-default-features --release
cargo zigbuild --target=armv7-unknown-linux-gnueabihf -p fluvio-spu --no-default-features --release

# cargo zigbuild armv7 musl (issue)
build-spu-zig-musl:
Expand Down
10 changes: 8 additions & 2 deletions makefiles/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ build-cli-minimal: install_rustup_target
cargo build --bin fluvio -p fluvio-cli $(RELEASE_FLAG) $(TARGET_FLAG) $(VERBOSE_FLAG) \
--no-default-features --features consumer,producer-file-io

build-cluster: install_rustup_target
cargo build --bin fluvio-run -p fluvio-run $(RELEASE_FLAG) $(TARGET_FLAG) $(VERBOSE_FLAG) $(DEBUG_SMARTMODULE_FLAG)
# note: careful that the if statement branches are leading spaces, tabs
ifeq ($(TARGET), armv7-unknown-linux-gnueabihf)
fluvio_run_extra=--no-default-features
else
fluvio_run_extra=
endif
build-cluster:
cargo build --bin fluvio-run -p fluvio-run $(RELEASE_FLAG) $(TARGET_FLAG) $(VERBOSE_FLAG) $(DEBUG_SMARTMODULE_FLAG) $(fluvio_run_extra)

build-test: install_rustup_target
cargo build --bin fluvio-test -p fluvio-test $(RELEASE_FLAG) $(TARGET_FLAG) $(VERBOSE_FLAG)
Expand Down

0 comments on commit befc11f

Please sign in to comment.